Merge lp:~ted/ubuntu-app-launch/application-starting into lp:ubuntu-app-launch/14.04
- application-starting
- Merge into trunk.14.04
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Charles Kerr | ||||
Approved revision: | 120 | ||||
Merged at revision: | 92 | ||||
Proposed branch: | lp:~ted/ubuntu-app-launch/application-starting | ||||
Merge into: | lp:ubuntu-app-launch/14.04 | ||||
Diff against target: |
869 lines (+454/-61) 18 files modified
click-exec-trace.tp (+4/-0) click-exec.c (+13/-0) data/com.canonical.UpstartAppLaunch.xml (+20/-0) debian/control (+5/-3) debian/libupstart-app-launch2.install (+1/-1) debian/libupstart-app-launch2.symbols (+5/-3) desktop-exec-trace.tp (+3/-1) desktop-exec.c (+12/-1) helpers.c (+82/-0) helpers.h (+4/-0) libupstart-app-launch/CMakeLists.txt (+2/-2) libupstart-app-launch/upstart-app-launch.c (+39/-15) libupstart-app-launch/upstart-app-launch.h (+45/-20) tests/CMakeLists.txt (+8/-0) tests/helper-handshake-test.cc (+120/-0) tests/libual-test.cc (+75/-2) tests/second-exec-test.cc (+0/-6) upstart-app-watch.c (+16/-7) |
||||
To merge this branch: | bzr merge lp:~ted/ubuntu-app-launch/application-starting | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Charles Kerr (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Gerry Boland (community) | Needs Fixing | ||
Review via email: mp+198027@code.launchpad.net |
Commit message
Handshake for starting applications
Description of the change
Adding a other observer with a handshake so that we can ensure that Unity knows about an app before we start it.
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:110
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 111. By Ted Gould
-
Unsubscribe to the signal when cleaning up
- 112. By Ted Gould
-
Track the timer and clean it up
- 113. By Ted Gould
-
Make sure to clean up on tear down not in the test
- 114. By Ted Gould
-
Clear the timeout signal handler when it gets hit
- 115. By Ted Gould
-
Killing some returns
- 116. By Ted Gould
-
Putting expected value first to clean up error messages
- 117. By Ted Gould
-
Removing duplicate definitions
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:114
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Gerry Boland (gerboland) wrote : | # |
If you must change the package name, please have it replace the old package.
Selecting previously unselected package libupstart-
Unpacking libupstart-
dpkg: error processing libupstart-
trying to overwrite '/usr/lib/
Why not just increment the package version?
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:118
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:120
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Gerry Boland (gerboland) wrote : | # |
Reasoning behind name change was explained to me, withdrawing objection.
FYI, here is the branch that implements support for this change in unity-mir if it eases testing
https:/
Charles Kerr (charlesk) wrote : | # |
Ted, thanks for fixing all those nitpicks I threw at you.
Preview Diff
1 | === modified file 'click-exec-trace.tp' | |||
2 | --- click-exec-trace.tp 2013-12-04 12:55:59 +0000 | |||
3 | +++ click-exec-trace.tp 2013-12-06 12:27:28 +0000 | |||
4 | @@ -1,6 +1,10 @@ | |||
5 | 1 | 1 | ||
6 | 2 | TRACEPOINT_EVENT(upstart_app_launch, click_start, TP_ARGS(0), TP_FIELDS()) | 2 | TRACEPOINT_EVENT(upstart_app_launch, click_start, TP_ARGS(0), TP_FIELDS()) |
7 | 3 | TRACEPOINT_EVENT(upstart_app_launch, click_starting_sent, TP_ARGS(0), TP_FIELDS()) | ||
8 | 3 | TRACEPOINT_EVENT(upstart_app_launch, click_found_pkgdir, TP_ARGS(0), TP_FIELDS()) | 4 | TRACEPOINT_EVENT(upstart_app_launch, click_found_pkgdir, TP_ARGS(0), TP_FIELDS()) |
9 | 4 | TRACEPOINT_EVENT(upstart_app_launch, click_configured_env, TP_ARGS(0), TP_FIELDS()) | 5 | TRACEPOINT_EVENT(upstart_app_launch, click_configured_env, TP_ARGS(0), TP_FIELDS()) |
10 | 5 | TRACEPOINT_EVENT(upstart_app_launch, click_read_manifest, TP_ARGS(0), TP_FIELDS()) | 6 | TRACEPOINT_EVENT(upstart_app_launch, click_read_manifest, TP_ARGS(0), TP_FIELDS()) |
11 | 6 | TRACEPOINT_EVENT(upstart_app_launch, click_read_desktop, TP_ARGS(0), TP_FIELDS()) | 7 | TRACEPOINT_EVENT(upstart_app_launch, click_read_desktop, TP_ARGS(0), TP_FIELDS()) |
12 | 8 | TRACEPOINT_EVENT(upstart_app_launch, click_handshake_wait, TP_ARGS(0), TP_FIELDS()) | ||
13 | 9 | TRACEPOINT_EVENT(upstart_app_launch, click_handshake_complete, TP_ARGS(0), TP_FIELDS()) | ||
14 | 10 | |||
15 | 7 | 11 | ||
16 | === modified file 'click-exec.c' | |||
17 | --- click-exec.c 2013-12-04 12:55:59 +0000 | |||
18 | +++ click-exec.c 2013-12-06 12:27:28 +0000 | |||
19 | @@ -55,6 +55,13 @@ | |||
20 | 55 | 55 | ||
21 | 56 | tracepoint(upstart_app_launch, click_start); | 56 | tracepoint(upstart_app_launch, click_start); |
22 | 57 | 57 | ||
23 | 58 | handshake_t * handshake = starting_handshake_start(app_id); | ||
24 | 59 | if (handshake == NULL) { | ||
25 | 60 | g_warning("Unable to setup starting handshake"); | ||
26 | 61 | } | ||
27 | 62 | |||
28 | 63 | tracepoint(upstart_app_launch, click_starting_sent); | ||
29 | 64 | |||
30 | 58 | GError * error = NULL; | 65 | GError * error = NULL; |
31 | 59 | gchar * package = NULL; | 66 | gchar * package = NULL; |
32 | 60 | /* 'Parse' the App ID */ | 67 | /* 'Parse' the App ID */ |
33 | @@ -140,5 +147,11 @@ | |||
34 | 140 | g_free(userdesktopfile); | 147 | g_free(userdesktopfile); |
35 | 141 | g_free(userdesktoppath); | 148 | g_free(userdesktoppath); |
36 | 142 | 149 | ||
37 | 150 | tracepoint(upstart_app_launch, click_handshake_wait); | ||
38 | 151 | |||
39 | 152 | starting_handshake_wait(handshake); | ||
40 | 153 | |||
41 | 154 | tracepoint(upstart_app_launch, click_handshake_complete); | ||
42 | 155 | |||
43 | 143 | return 0; | 156 | return 0; |
44 | 144 | } | 157 | } |
45 | 145 | 158 | ||
46 | === added directory 'data' | |||
47 | === added file 'data/com.canonical.UpstartAppLaunch.xml' | |||
48 | --- data/com.canonical.UpstartAppLaunch.xml 1970-01-01 00:00:00 +0000 | |||
49 | +++ data/com.canonical.UpstartAppLaunch.xml 2013-12-06 12:27:28 +0000 | |||
50 | @@ -0,0 +1,20 @@ | |||
51 | 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
52 | 2 | <node> | ||
53 | 3 | <interface name="com.canonical.UpstartAppLaunch"> | ||
54 | 4 | <signal name="UnityResumeRequest"> | ||
55 | 5 | <arg type="s" name="appid" /> | ||
56 | 6 | </signal> | ||
57 | 7 | <signal name="UnityResumeResponse"> | ||
58 | 8 | <arg type="s" name="appid" /> | ||
59 | 9 | </signal> | ||
60 | 10 | <signal name="UnityFocusRequest"> | ||
61 | 11 | <arg type="s" name="appid" /> | ||
62 | 12 | </signal> | ||
63 | 13 | <signal name="UnityStartingBroadcast"> | ||
64 | 14 | <arg type="s" name="appid" /> | ||
65 | 15 | </signal> | ||
66 | 16 | <signal name="UnityStartingSignal"> | ||
67 | 17 | <arg type="s" name="appid" /> | ||
68 | 18 | </signal> | ||
69 | 19 | </interface> | ||
70 | 20 | </node> | ||
71 | 0 | 21 | ||
72 | === modified file 'debian/control' | |||
73 | --- debian/control 2013-12-06 10:38:35 +0000 | |||
74 | +++ debian/control 2013-12-06 12:27:28 +0000 | |||
75 | @@ -49,7 +49,7 @@ | |||
76 | 49 | . | 49 | . |
77 | 50 | This package provides tools for working with the Upstart App Launch. | 50 | This package provides tools for working with the Upstart App Launch. |
78 | 51 | 51 | ||
80 | 52 | Package: libupstart-app-launch1 | 52 | Package: libupstart-app-launch2 |
81 | 53 | Section: libs | 53 | Section: libs |
82 | 54 | Architecture: any | 54 | Architecture: any |
83 | 55 | Depends: ${misc:Depends}, | 55 | Depends: ${misc:Depends}, |
84 | @@ -62,15 +62,17 @@ | |||
85 | 62 | . | 62 | . |
86 | 63 | This package contains shared libraries to be used by applications. | 63 | This package contains shared libraries to be used by applications. |
87 | 64 | 64 | ||
89 | 65 | Package: libupstart-app-launch1-dev | 65 | Package: libupstart-app-launch2-dev |
90 | 66 | Section: libdevel | 66 | Section: libdevel |
91 | 67 | Architecture: any | 67 | Architecture: any |
92 | 68 | Depends: ${misc:Depends}, | 68 | Depends: ${misc:Depends}, |
93 | 69 | ${shlibs:Depends}, | 69 | ${shlibs:Depends}, |
94 | 70 | libglib2.0-dev, | 70 | libglib2.0-dev, |
96 | 71 | libupstart-app-launch1 (= ${binary:Version}), | 71 | libupstart-app-launch2 (= ${binary:Version}), |
97 | 72 | Pre-Depends: ${misc:Pre-Depends}, | 72 | Pre-Depends: ${misc:Pre-Depends}, |
98 | 73 | Multi-Arch: same | 73 | Multi-Arch: same |
99 | 74 | Replaces: libupstart-app-launch1-dev | ||
100 | 75 | Conflicts: libupstart-app-launch1-dev | ||
101 | 74 | Description: library for sending requests to the upstart app launch | 76 | Description: library for sending requests to the upstart app launch |
102 | 75 | Upstart Job file and associated utilities that is used to launch | 77 | Upstart Job file and associated utilities that is used to launch |
103 | 76 | applications in a standard and confined way. | 78 | applications in a standard and confined way. |
104 | 77 | 79 | ||
105 | === renamed file 'debian/libupstart-app-launch1-dev.install' => 'debian/libupstart-app-launch2-dev.install' | |||
106 | === renamed file 'debian/libupstart-app-launch1.install' => 'debian/libupstart-app-launch2.install' | |||
107 | --- debian/libupstart-app-launch1.install 2013-08-02 13:24:59 +0000 | |||
108 | +++ debian/libupstart-app-launch2.install 2013-12-06 12:27:28 +0000 | |||
109 | @@ -1,1 +1,1 @@ | |||
111 | 1 | usr/lib/*/libupstart-app-launch.so.1* | 1 | usr/lib/*/libupstart-app-launch.so.2* |
112 | 2 | 2 | ||
113 | === renamed file 'debian/libupstart-app-launch1.symbols' => 'debian/libupstart-app-launch2.symbols' | |||
114 | --- debian/libupstart-app-launch1.symbols 2013-10-08 19:38:15 +0000 | |||
115 | +++ debian/libupstart-app-launch2.symbols 2013-12-06 12:27:28 +0000 | |||
116 | @@ -1,15 +1,17 @@ | |||
118 | 1 | libupstart-app-launch.so.1 libupstart-app-launch1 #MINVER# | 1 | libupstart-app-launch.so.2 libupstart-app-launch2 #MINVER# |
119 | 2 | upstart_app_launch_get_primary_pid@Base 0.2 | 2 | upstart_app_launch_get_primary_pid@Base 0.2 |
120 | 3 | upstart_app_launch_list_running_apps@Base 0.2 | 3 | upstart_app_launch_list_running_apps@Base 0.2 |
121 | 4 | upstart_app_launch_observer_add_app_failed@Base 0.2 | 4 | upstart_app_launch_observer_add_app_failed@Base 0.2 |
122 | 5 | upstart_app_launch_observer_add_app_focus@Base 0.2 | 5 | upstart_app_launch_observer_add_app_focus@Base 0.2 |
123 | 6 | upstart_app_launch_observer_add_app_resume@Base 0.2 | 6 | upstart_app_launch_observer_add_app_resume@Base 0.2 |
125 | 7 | upstart_app_launch_observer_add_app_start@Base 0.2 | 7 | upstart_app_launch_observer_add_app_started@Base 0replaceme |
126 | 8 | upstart_app_launch_observer_add_app_starting@Base 0replaceme | ||
127 | 8 | upstart_app_launch_observer_add_app_stop@Base 0.2 | 9 | upstart_app_launch_observer_add_app_stop@Base 0.2 |
128 | 9 | upstart_app_launch_observer_delete_app_failed@Base 0.2 | 10 | upstart_app_launch_observer_delete_app_failed@Base 0.2 |
129 | 10 | upstart_app_launch_observer_delete_app_focus@Base 0.2 | 11 | upstart_app_launch_observer_delete_app_focus@Base 0.2 |
130 | 11 | upstart_app_launch_observer_delete_app_resume@Base 0.2 | 12 | upstart_app_launch_observer_delete_app_resume@Base 0.2 |
132 | 12 | upstart_app_launch_observer_delete_app_start@Base 0.2 | 13 | upstart_app_launch_observer_delete_app_started@Base 0replaceme |
133 | 14 | upstart_app_launch_observer_delete_app_starting@Base 0replaceme | ||
134 | 13 | upstart_app_launch_observer_delete_app_stop@Base 0.2 | 15 | upstart_app_launch_observer_delete_app_stop@Base 0.2 |
135 | 14 | upstart_app_launch_pid_in_app_id@Base 0.2 | 16 | upstart_app_launch_pid_in_app_id@Base 0.2 |
136 | 15 | upstart_app_launch_start_application@Base 0.2 | 17 | upstart_app_launch_start_application@Base 0.2 |
137 | 16 | 18 | ||
138 | === modified file 'desktop-exec-trace.tp' | |||
139 | --- desktop-exec-trace.tp 2013-12-04 17:07:09 +0000 | |||
140 | +++ desktop-exec-trace.tp 2013-12-06 12:27:28 +0000 | |||
141 | @@ -1,5 +1,7 @@ | |||
142 | 1 | 1 | ||
143 | 2 | TRACEPOINT_EVENT(upstart_app_launch, desktop_start, TP_ARGS(0), TP_FIELDS()) | 2 | TRACEPOINT_EVENT(upstart_app_launch, desktop_start, TP_ARGS(0), TP_FIELDS()) |
144 | 3 | TRACEPOINT_EVENT(upstart_app_launch, desktop_starting_sent, TP_ARGS(0), TP_FIELDS()) | ||
145 | 3 | TRACEPOINT_EVENT(upstart_app_launch, desktop_found, TP_ARGS(0), TP_FIELDS()) | 4 | TRACEPOINT_EVENT(upstart_app_launch, desktop_found, TP_ARGS(0), TP_FIELDS()) |
147 | 4 | TRACEPOINT_EVENT(upstart_app_launch, desktop_finished, TP_ARGS(0), TP_FIELDS()) | 5 | TRACEPOINT_EVENT(upstart_app_launch, desktop_handshake_wait, TP_ARGS(0), TP_FIELDS()) |
148 | 6 | TRACEPOINT_EVENT(upstart_app_launch, desktop_handshake_complete, TP_ARGS(0), TP_FIELDS()) | ||
149 | 5 | 7 | ||
150 | 6 | 8 | ||
151 | === modified file 'desktop-exec.c' | |||
152 | --- desktop-exec.c 2013-12-05 17:08:13 +0000 | |||
153 | +++ desktop-exec.c 2013-12-06 12:27:28 +0000 | |||
154 | @@ -44,6 +44,13 @@ | |||
155 | 44 | g_setenv("LTTNG_UST_REGISTER_TIMEOUT", "0", FALSE); /* Set to zero if not set */ | 44 | g_setenv("LTTNG_UST_REGISTER_TIMEOUT", "0", FALSE); /* Set to zero if not set */ |
156 | 45 | tracepoint(upstart_app_launch, desktop_start); | 45 | tracepoint(upstart_app_launch, desktop_start); |
157 | 46 | 46 | ||
158 | 47 | handshake_t * handshake = starting_handshake_start(app_id); | ||
159 | 48 | if (handshake == NULL) { | ||
160 | 49 | g_warning("Unable to setup starting handshake"); | ||
161 | 50 | } | ||
162 | 51 | |||
163 | 52 | tracepoint(upstart_app_launch, desktop_starting_sent); | ||
164 | 53 | |||
165 | 47 | gchar * desktopfilename = NULL; | 54 | gchar * desktopfilename = NULL; |
166 | 48 | GKeyFile * keyfile = keyfile_for_appid(app_id, &desktopfilename); | 55 | GKeyFile * keyfile = keyfile_for_appid(app_id, &desktopfilename); |
167 | 49 | 56 | ||
168 | @@ -84,7 +91,11 @@ | |||
169 | 84 | g_free(desktopfilename); | 91 | g_free(desktopfilename); |
170 | 85 | } | 92 | } |
171 | 86 | 93 | ||
173 | 87 | tracepoint(upstart_app_launch, desktop_finished); | 94 | tracepoint(upstart_app_launch, desktop_handshake_wait); |
174 | 95 | |||
175 | 96 | starting_handshake_wait(handshake); | ||
176 | 97 | |||
177 | 98 | tracepoint(upstart_app_launch, desktop_handshake_complete); | ||
178 | 88 | 99 | ||
179 | 89 | return 0; | 100 | return 0; |
180 | 90 | } | 101 | } |
181 | 91 | 102 | ||
182 | === modified file 'helpers.c' | |||
183 | --- helpers.c 2013-11-22 16:35:27 +0000 | |||
184 | +++ helpers.c 2013-12-06 12:27:28 +0000 | |||
185 | @@ -582,3 +582,85 @@ | |||
186 | 582 | 582 | ||
187 | 583 | return; | 583 | return; |
188 | 584 | } | 584 | } |
189 | 585 | |||
190 | 586 | static void | ||
191 | 587 | unity_signal_cb (GDBusConnection * con, const gchar * sender, const gchar * path, const gchar * interface, const gchar * signal, GVariant * params, gpointer user_data) | ||
192 | 588 | { | ||
193 | 589 | GMainLoop * mainloop = (GMainLoop *)user_data; | ||
194 | 590 | g_main_loop_quit(mainloop); | ||
195 | 591 | } | ||
196 | 592 | |||
197 | 593 | struct _handshake_t { | ||
198 | 594 | GDBusConnection * con; | ||
199 | 595 | GMainLoop * mainloop; | ||
200 | 596 | guint signal_subscribe; | ||
201 | 597 | guint timeout; | ||
202 | 598 | }; | ||
203 | 599 | |||
204 | 600 | static gboolean | ||
205 | 601 | unity_too_slow_cb (gpointer user_data) | ||
206 | 602 | { | ||
207 | 603 | handshake_t * handshake = (handshake_t *)user_data; | ||
208 | 604 | g_main_loop_quit(handshake->mainloop); | ||
209 | 605 | handshake->timeout = 0; | ||
210 | 606 | return G_SOURCE_REMOVE; | ||
211 | 607 | } | ||
212 | 608 | |||
213 | 609 | handshake_t * | ||
214 | 610 | starting_handshake_start (const gchar * app_id) | ||
215 | 611 | { | ||
216 | 612 | GError * error = NULL; | ||
217 | 613 | handshake_t * handshake = g_new0(handshake_t, 1); | ||
218 | 614 | |||
219 | 615 | handshake->mainloop = g_main_loop_new(NULL, FALSE); | ||
220 | 616 | handshake->con = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error); | ||
221 | 617 | |||
222 | 618 | if (error != NULL) { | ||
223 | 619 | g_critical("Unable to connect to session bus: %s", error->message); | ||
224 | 620 | g_error_free(error); | ||
225 | 621 | g_free(handshake); | ||
226 | 622 | return NULL; | ||
227 | 623 | } | ||
228 | 624 | |||
229 | 625 | /* Set up listening for the unfrozen signal from Unity */ | ||
230 | 626 | handshake->signal_subscribe = g_dbus_connection_signal_subscribe(handshake->con, | ||
231 | 627 | NULL, /* sender */ | ||
232 | 628 | "com.canonical.UpstartAppLaunch", /* interface */ | ||
233 | 629 | "UnityStartingSignal", /* signal */ | ||
234 | 630 | "/", /* path */ | ||
235 | 631 | app_id, /* arg0 */ | ||
236 | 632 | G_DBUS_SIGNAL_FLAGS_NONE, | ||
237 | 633 | unity_signal_cb, handshake->mainloop, | ||
238 | 634 | NULL); /* user data destroy */ | ||
239 | 635 | |||
240 | 636 | /* Send unfreeze to to Unity */ | ||
241 | 637 | g_dbus_connection_emit_signal(handshake->con, | ||
242 | 638 | NULL, /* destination */ | ||
243 | 639 | "/", /* path */ | ||
244 | 640 | "com.canonical.UpstartAppLaunch", /* interface */ | ||
245 | 641 | "UnityStartingBroadcast", /* signal */ | ||
246 | 642 | g_variant_new("(s)", app_id), | ||
247 | 643 | &error); | ||
248 | 644 | |||
249 | 645 | /* Really, Unity? */ | ||
250 | 646 | handshake->timeout = g_timeout_add_seconds(1, unity_too_slow_cb, handshake); | ||
251 | 647 | |||
252 | 648 | return handshake; | ||
253 | 649 | } | ||
254 | 650 | |||
255 | 651 | void | ||
256 | 652 | starting_handshake_wait (handshake_t * handshake) | ||
257 | 653 | { | ||
258 | 654 | if (handshake == NULL) | ||
259 | 655 | return; | ||
260 | 656 | |||
261 | 657 | g_main_loop_run(handshake->mainloop); | ||
262 | 658 | |||
263 | 659 | if (handshake->timeout != 0) | ||
264 | 660 | g_source_remove(handshake->timeout); | ||
265 | 661 | g_main_loop_unref(handshake->mainloop); | ||
266 | 662 | g_dbus_connection_signal_unsubscribe(handshake->con, handshake->signal_subscribe); | ||
267 | 663 | g_object_unref(handshake->con); | ||
268 | 664 | |||
269 | 665 | g_free(handshake); | ||
270 | 666 | } | ||
271 | 585 | 667 | ||
272 | === modified file 'helpers.h' | |||
273 | --- helpers.h 2013-11-12 21:06:02 +0000 | |||
274 | +++ helpers.h 2013-12-06 12:27:28 +0000 | |||
275 | @@ -36,3 +36,7 @@ | |||
276 | 36 | void set_confined_envvars (const gchar * package, | 36 | void set_confined_envvars (const gchar * package, |
277 | 37 | const gchar * app_dir); | 37 | const gchar * app_dir); |
278 | 38 | 38 | ||
279 | 39 | typedef struct _handshake_t handshake_t; | ||
280 | 40 | handshake_t * starting_handshake_start (const gchar * app_id); | ||
281 | 41 | void starting_handshake_wait (handshake_t * handshake); | ||
282 | 42 | |||
283 | 39 | 43 | ||
284 | === modified file 'libupstart-app-launch/CMakeLists.txt' | |||
285 | --- libupstart-app-launch/CMakeLists.txt 2013-08-08 03:54:36 +0000 | |||
286 | +++ libupstart-app-launch/CMakeLists.txt 2013-12-06 12:27:28 +0000 | |||
287 | @@ -3,8 +3,8 @@ | |||
288 | 3 | # Version Info | 3 | # Version Info |
289 | 4 | ########################## | 4 | ########################## |
290 | 5 | 5 | ||
293 | 6 | set(API_VERSION 1) | 6 | set(API_VERSION 2) |
294 | 7 | set(ABI_VERSION 1) | 7 | set(ABI_VERSION 2) |
295 | 8 | 8 | ||
296 | 9 | 9 | ||
297 | 10 | ########################## | 10 | ########################## |
298 | 11 | 11 | ||
299 | === modified file 'libupstart-app-launch/upstart-app-launch.c' | |||
300 | --- libupstart-app-launch/upstart-app-launch.c 2013-11-25 14:44:42 +0000 | |||
301 | +++ libupstart-app-launch/upstart-app-launch.c 2013-12-06 12:27:28 +0000 | |||
302 | @@ -163,8 +163,6 @@ | |||
303 | 163 | g_free(app); | 163 | g_free(app); |
304 | 164 | g_free(inst); | 164 | g_free(inst); |
305 | 165 | nih_unref(job_proxy, NULL); | 165 | nih_unref(job_proxy, NULL); |
306 | 166 | |||
307 | 167 | return; | ||
308 | 168 | } | 166 | } |
309 | 169 | 167 | ||
310 | 170 | static void | 168 | static void |
311 | @@ -257,7 +255,8 @@ | |||
312 | 257 | }; | 255 | }; |
313 | 258 | 256 | ||
314 | 259 | /* The lists of Observers */ | 257 | /* The lists of Observers */ |
316 | 260 | static GList * start_array = NULL; | 258 | static GList * starting_array = NULL; |
317 | 259 | static GList * started_array = NULL; | ||
318 | 261 | static GList * stop_array = NULL; | 260 | static GList * stop_array = NULL; |
319 | 262 | static GList * focus_array = NULL; | 261 | static GList * focus_array = NULL; |
320 | 263 | static GList * resume_array = NULL; | 262 | static GList * resume_array = NULL; |
321 | @@ -301,8 +300,6 @@ | |||
322 | 301 | } | 300 | } |
323 | 302 | 301 | ||
324 | 303 | g_free(instance); | 302 | g_free(instance); |
325 | 304 | |||
326 | 305 | return; | ||
327 | 306 | } | 303 | } |
328 | 307 | 304 | ||
329 | 308 | /* Creates the observer structure and registers for the signal with | 305 | /* Creates the observer structure and registers for the signal with |
330 | @@ -339,9 +336,9 @@ | |||
331 | 339 | } | 336 | } |
332 | 340 | 337 | ||
333 | 341 | gboolean | 338 | gboolean |
335 | 342 | upstart_app_launch_observer_add_app_start (upstart_app_launch_app_observer_t observer, gpointer user_data) | 339 | upstart_app_launch_observer_add_app_started (upstart_app_launch_app_observer_t observer, gpointer user_data) |
336 | 343 | { | 340 | { |
338 | 344 | return add_app_generic(observer, user_data, "started", &start_array); | 341 | return add_app_generic(observer, user_data, "started", &started_array); |
339 | 345 | } | 342 | } |
340 | 346 | 343 | ||
341 | 347 | gboolean | 344 | gboolean |
342 | @@ -394,8 +391,6 @@ | |||
343 | 394 | g_variant_get(params, "(&s)", &appid); | 391 | g_variant_get(params, "(&s)", &appid); |
344 | 395 | observer->func(appid, observer->user_data); | 392 | observer->func(appid, observer->user_data); |
345 | 396 | } | 393 | } |
346 | 397 | |||
347 | 398 | return; | ||
348 | 399 | } | 394 | } |
349 | 400 | 395 | ||
350 | 401 | gboolean | 396 | gboolean |
351 | @@ -423,8 +418,6 @@ | |||
352 | 423 | g_warning("Unable to emit response signal: %s", error->message); | 418 | g_warning("Unable to emit response signal: %s", error->message); |
353 | 424 | g_error_free(error); | 419 | g_error_free(error); |
354 | 425 | } | 420 | } |
355 | 426 | |||
356 | 427 | return; | ||
357 | 428 | } | 421 | } |
358 | 429 | 422 | ||
359 | 430 | gboolean | 423 | gboolean |
360 | @@ -433,6 +426,33 @@ | |||
361 | 433 | return add_session_generic(observer, user_data, "UnityResumeRequest", &resume_array, resume_signal_cb); | 426 | return add_session_generic(observer, user_data, "UnityResumeRequest", &resume_array, resume_signal_cb); |
362 | 434 | } | 427 | } |
363 | 435 | 428 | ||
364 | 429 | /* Handle the starting signal when it occurs, call the observer, then send a signal back when we're done */ | ||
365 | 430 | static void | ||
366 | 431 | starting_signal_cb (GDBusConnection * conn, const gchar * sender, const gchar * object, const gchar * interface, const gchar * signal, GVariant * params, gpointer user_data) | ||
367 | 432 | { | ||
368 | 433 | focus_signal_cb(conn, sender, object, interface, signal, params, user_data); | ||
369 | 434 | |||
370 | 435 | GError * error = NULL; | ||
371 | 436 | g_dbus_connection_emit_signal(conn, | ||
372 | 437 | sender, /* destination */ | ||
373 | 438 | "/", /* path */ | ||
374 | 439 | "com.canonical.UpstartAppLaunch", /* interface */ | ||
375 | 440 | "UnityStartingSignal", /* signal */ | ||
376 | 441 | params, /* params, the same */ | ||
377 | 442 | &error); | ||
378 | 443 | |||
379 | 444 | if (error != NULL) { | ||
380 | 445 | g_warning("Unable to emit response signal: %s", error->message); | ||
381 | 446 | g_error_free(error); | ||
382 | 447 | } | ||
383 | 448 | } | ||
384 | 449 | |||
385 | 450 | gboolean | ||
386 | 451 | upstart_app_launch_observer_add_app_starting (upstart_app_launch_app_observer_t observer, gpointer user_data) | ||
387 | 452 | { | ||
388 | 453 | return add_session_generic(observer, user_data, "UnityStartingBroadcast", &starting_array, starting_signal_cb); | ||
389 | 454 | } | ||
390 | 455 | |||
391 | 436 | gboolean | 456 | gboolean |
392 | 437 | upstart_app_launch_observer_add_app_failed (upstart_app_launch_app_failed_observer_t observer, gpointer user_data) | 457 | upstart_app_launch_observer_add_app_failed (upstart_app_launch_app_failed_observer_t observer, gpointer user_data) |
393 | 438 | { | 458 | { |
394 | @@ -467,9 +487,9 @@ | |||
395 | 467 | } | 487 | } |
396 | 468 | 488 | ||
397 | 469 | gboolean | 489 | gboolean |
399 | 470 | upstart_app_launch_observer_delete_app_start (upstart_app_launch_app_observer_t observer, gpointer user_data) | 490 | upstart_app_launch_observer_delete_app_started (upstart_app_launch_app_observer_t observer, gpointer user_data) |
400 | 471 | { | 491 | { |
402 | 472 | return delete_app_generic(observer, user_data, &start_array); | 492 | return delete_app_generic(observer, user_data, &started_array); |
403 | 473 | } | 493 | } |
404 | 474 | 494 | ||
405 | 475 | gboolean | 495 | gboolean |
406 | @@ -491,6 +511,12 @@ | |||
407 | 491 | } | 511 | } |
408 | 492 | 512 | ||
409 | 493 | gboolean | 513 | gboolean |
410 | 514 | upstart_app_launch_observer_delete_app_starting (upstart_app_launch_app_observer_t observer, gpointer user_data) | ||
411 | 515 | { | ||
412 | 516 | return delete_app_generic(observer, user_data, &starting_array); | ||
413 | 517 | } | ||
414 | 518 | |||
415 | 519 | gboolean | ||
416 | 494 | upstart_app_launch_observer_delete_app_failed (upstart_app_launch_app_failed_observer_t observer, gpointer user_data) | 520 | upstart_app_launch_observer_delete_app_failed (upstart_app_launch_app_failed_observer_t observer, gpointer user_data) |
417 | 495 | { | 521 | { |
418 | 496 | return FALSE; | 522 | return FALSE; |
419 | @@ -549,8 +575,6 @@ | |||
420 | 549 | 575 | ||
421 | 550 | nih_unref(instance_proxy, NULL); | 576 | nih_unref(instance_proxy, NULL); |
422 | 551 | } | 577 | } |
423 | 552 | |||
424 | 553 | return; | ||
425 | 554 | } | 578 | } |
426 | 555 | 579 | ||
427 | 556 | gchar ** | 580 | gchar ** |
428 | 557 | 581 | ||
429 | === modified file 'libupstart-app-launch/upstart-app-launch.h' | |||
430 | --- libupstart-app-launch/upstart-app-launch.h 2013-09-26 15:19:22 +0000 | |||
431 | +++ libupstart-app-launch/upstart-app-launch.h 2013-12-06 12:27:28 +0000 | |||
432 | @@ -80,16 +80,29 @@ | |||
433 | 80 | gboolean upstart_app_launch_stop_application (const gchar * appid); | 80 | gboolean upstart_app_launch_stop_application (const gchar * appid); |
434 | 81 | 81 | ||
435 | 82 | /** | 82 | /** |
446 | 83 | * upstart_app_launch_observer_add_app_start: | 83 | * upstart_app_launch_observer_add_app_starting: |
447 | 84 | * @observer: Callback when an application starts | 84 | * @observer: Callback when an application is about to start |
448 | 85 | * @user_data: (allow none): Data to pass to the observer | 85 | * @user_data: (allow none): Data to pass to the observer |
449 | 86 | * | 86 | * |
450 | 87 | * Sets up a callback to get called each time an application | 87 | * Sets up a callback to get called each time an application |
451 | 88 | * starts. | 88 | * is about to start. The application will not start until the |
452 | 89 | * | 89 | * function returns. |
453 | 90 | * Return value: Whether adding the observer was successful. | 90 | * |
454 | 91 | */ | 91 | * Return value: Whether adding the observer was successful. |
455 | 92 | gboolean upstart_app_launch_observer_add_app_start (upstart_app_launch_app_observer_t observer, | 92 | */ |
456 | 93 | gboolean upstart_app_launch_observer_add_app_starting (upstart_app_launch_app_observer_t observer, | ||
457 | 94 | gpointer user_data); | ||
458 | 95 | /** | ||
459 | 96 | * upstart_app_launch_observer_add_app_started: | ||
460 | 97 | * @observer: Callback when an application started | ||
461 | 98 | * @user_data: (allow none): Data to pass to the observer | ||
462 | 99 | * | ||
463 | 100 | * Sets up a callback to get called each time an application | ||
464 | 101 | * has been started. | ||
465 | 102 | * | ||
466 | 103 | * Return value: Whether adding the observer was successful. | ||
467 | 104 | */ | ||
468 | 105 | gboolean upstart_app_launch_observer_add_app_started (upstart_app_launch_app_observer_t observer, | ||
469 | 93 | gpointer user_data); | 106 | gpointer user_data); |
470 | 94 | /** | 107 | /** |
471 | 95 | * upstart_app_launch_observer_add_app_stop: | 108 | * upstart_app_launch_observer_add_app_stop: |
472 | @@ -145,16 +158,28 @@ | |||
473 | 145 | gpointer user_data); | 158 | gpointer user_data); |
474 | 146 | 159 | ||
475 | 147 | /** | 160 | /** |
486 | 148 | * upstart_app_launch_observer_delete_app_start: | 161 | * upstart_app_launch_observer_delete_app_starting: |
487 | 149 | * @observer: Callback to remove | 162 | * @observer: Callback to remove |
488 | 150 | * @user_data: (allow none): Data that was passed to the observer | 163 | * @user_data: (allow none): Data that was passed to the observer |
489 | 151 | * | 164 | * |
490 | 152 | * Removes a previously registered callback to ensure it no longer | 165 | * Removes a previously registered callback to ensure it no longer |
491 | 153 | * gets signaled. | 166 | * gets signaled. |
492 | 154 | * | 167 | * |
493 | 155 | * Return value: Whether deleting the observer was successful. | 168 | * Return value: Whether deleting the observer was successful. |
494 | 156 | */ | 169 | */ |
495 | 157 | gboolean upstart_app_launch_observer_delete_app_start (upstart_app_launch_app_observer_t observer, | 170 | gboolean upstart_app_launch_observer_delete_app_starting (upstart_app_launch_app_observer_t observer, |
496 | 171 | gpointer user_data); | ||
497 | 172 | /** | ||
498 | 173 | * upstart_app_launch_observer_delete_app_started: | ||
499 | 174 | * @observer: Callback to remove | ||
500 | 175 | * @user_data: (allow none): Data that was passed to the observer | ||
501 | 176 | * | ||
502 | 177 | * Removes a previously registered callback to ensure it no longer | ||
503 | 178 | * gets signaled. | ||
504 | 179 | * | ||
505 | 180 | * Return value: Whether deleting the observer was successful. | ||
506 | 181 | */ | ||
507 | 182 | gboolean upstart_app_launch_observer_delete_app_started (upstart_app_launch_app_observer_t observer, | ||
508 | 158 | gpointer user_data); | 183 | gpointer user_data); |
509 | 159 | /** | 184 | /** |
510 | 160 | * upstart_app_launch_observer_delete_app_stop: | 185 | * upstart_app_launch_observer_delete_app_stop: |
511 | 161 | 186 | ||
512 | === modified file 'tests/CMakeLists.txt' | |||
513 | --- tests/CMakeLists.txt 2013-12-04 17:48:47 +0000 | |||
514 | +++ tests/CMakeLists.txt 2013-12-06 12:27:28 +0000 | |||
515 | @@ -18,6 +18,13 @@ | |||
516 | 18 | 18 | ||
517 | 19 | add_test (helper-test helper-test) | 19 | add_test (helper-test helper-test) |
518 | 20 | 20 | ||
519 | 21 | # Helper test | ||
520 | 22 | |||
521 | 23 | add_executable (helper-handshake-test helper-handshake-test.cc) | ||
522 | 24 | target_link_libraries (helper-handshake-test helpers gtest ${GTEST_LIBS}) | ||
523 | 25 | |||
524 | 26 | add_test (helper-handshake-test helper-handshake-test) | ||
525 | 27 | |||
526 | 21 | # Second Exec Test | 28 | # Second Exec Test |
527 | 22 | 29 | ||
528 | 23 | include_directories("${CMAKE_SOURCE_DIR}/libupstart-app-launch") | 30 | include_directories("${CMAKE_SOURCE_DIR}/libupstart-app-launch") |
529 | @@ -42,6 +49,7 @@ | |||
530 | 42 | add_test (NAME libual-test-pid COMMAND libual-test --gtest_filter=*ApplicationPid) | 49 | add_test (NAME libual-test-pid COMMAND libual-test --gtest_filter=*ApplicationPid) |
531 | 43 | add_test (NAME libual-test-list COMMAND libual-test --gtest_filter=*ApplicationList) | 50 | add_test (NAME libual-test-list COMMAND libual-test --gtest_filter=*ApplicationList) |
532 | 44 | add_test (NAME libual-test-observer COMMAND libual-test --gtest_filter=*StartStopObserver) | 51 | add_test (NAME libual-test-observer COMMAND libual-test --gtest_filter=*StartStopObserver) |
533 | 52 | add_test (NAME libual-test-starting COMMAND libual-test --gtest_filter=*StartingResponses) | ||
534 | 45 | 53 | ||
535 | 46 | # ZG Test | 54 | # ZG Test |
536 | 47 | 55 | ||
537 | 48 | 56 | ||
538 | === added file 'tests/helper-handshake-test.cc' | |||
539 | --- tests/helper-handshake-test.cc 1970-01-01 00:00:00 +0000 | |||
540 | +++ tests/helper-handshake-test.cc 2013-12-06 12:27:28 +0000 | |||
541 | @@ -0,0 +1,120 @@ | |||
542 | 1 | /* | ||
543 | 2 | * Copyright 2013 Canonical Ltd. | ||
544 | 3 | * | ||
545 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
546 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
547 | 6 | * by the Free Software Foundation. | ||
548 | 7 | * | ||
549 | 8 | * This program is distributed in the hope that it will be useful, but | ||
550 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
551 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
552 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
553 | 12 | * | ||
554 | 13 | * You should have received a copy of the GNU General Public License along | ||
555 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
556 | 15 | * | ||
557 | 16 | * Authors: | ||
558 | 17 | * Ted Gould <ted.gould@canonical.com> | ||
559 | 18 | */ | ||
560 | 19 | |||
561 | 20 | #include <gtest/gtest.h> | ||
562 | 21 | #include <glib/gstdio.h> | ||
563 | 22 | #include <gio/gio.h> | ||
564 | 23 | |||
565 | 24 | extern "C" { | ||
566 | 25 | #include "../helpers.h" | ||
567 | 26 | } | ||
568 | 27 | |||
569 | 28 | class HelperHandshakeTest : public ::testing::Test | ||
570 | 29 | { | ||
571 | 30 | private: | ||
572 | 31 | GTestDBus * testbus = NULL; | ||
573 | 32 | |||
574 | 33 | protected: | ||
575 | 34 | GMainLoop * mainloop = NULL; | ||
576 | 35 | |||
577 | 36 | virtual void SetUp() { | ||
578 | 37 | mainloop = g_main_loop_new(NULL, FALSE); | ||
579 | 38 | testbus = g_test_dbus_new(G_TEST_DBUS_NONE); | ||
580 | 39 | g_test_dbus_up(testbus); | ||
581 | 40 | } | ||
582 | 41 | |||
583 | 42 | virtual void TearDown() { | ||
584 | 43 | g_test_dbus_down(testbus); | ||
585 | 44 | g_clear_object(&testbus); | ||
586 | 45 | g_main_loop_unref(mainloop); | ||
587 | 46 | mainloop = NULL; | ||
588 | 47 | return; | ||
589 | 48 | } | ||
590 | 49 | |||
591 | 50 | public: | ||
592 | 51 | GDBusMessage * FilterFunc (GDBusConnection * conn, GDBusMessage * message, gboolean incomming) { | ||
593 | 52 | if (g_strcmp0(g_dbus_message_get_member(message), "UnityStartingBroadcast") == 0) { | ||
594 | 53 | GVariant * body = g_dbus_message_get_body(message); | ||
595 | 54 | GVariant * correct_body = g_variant_new("(s)", "fooapp"); | ||
596 | 55 | g_variant_ref_sink(correct_body); | ||
597 | 56 | |||
598 | 57 | [body, correct_body]() { | ||
599 | 58 | ASSERT_TRUE(g_variant_equal(body, correct_body)); | ||
600 | 59 | }(); | ||
601 | 60 | |||
602 | 61 | g_variant_unref(correct_body); | ||
603 | 62 | g_main_loop_quit(mainloop); | ||
604 | 63 | } | ||
605 | 64 | |||
606 | 65 | return message; | ||
607 | 66 | } | ||
608 | 67 | |||
609 | 68 | }; | ||
610 | 69 | |||
611 | 70 | static GDBusMessage * | ||
612 | 71 | filter_func (GDBusConnection * conn, GDBusMessage * message, gboolean incomming, gpointer user_data) { | ||
613 | 72 | return static_cast<HelperHandshakeTest *>(user_data)->FilterFunc(conn, message, incomming); | ||
614 | 73 | } | ||
615 | 74 | |||
616 | 75 | TEST_F(HelperHandshakeTest, BaseHandshake) | ||
617 | 76 | { | ||
618 | 77 | GDBusConnection * con = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL); | ||
619 | 78 | guint filter = g_dbus_connection_add_filter(con, filter_func, this, NULL); | ||
620 | 79 | |||
621 | 80 | handshake_t * handshake = starting_handshake_start("fooapp"); | ||
622 | 81 | |||
623 | 82 | g_main_loop_run(mainloop); | ||
624 | 83 | |||
625 | 84 | g_dbus_connection_remove_filter(con, filter); | ||
626 | 85 | |||
627 | 86 | g_dbus_connection_emit_signal(con, | ||
628 | 87 | g_dbus_connection_get_unique_name(con), /* destination */ | ||
629 | 88 | "/", /* path */ | ||
630 | 89 | "com.canonical.UpstartAppLaunch", /* interface */ | ||
631 | 90 | "UnityStartingSignal", /* signal */ | ||
632 | 91 | g_variant_new("(s)", "fooapp"), /* params, the same */ | ||
633 | 92 | NULL); | ||
634 | 93 | |||
635 | 94 | starting_handshake_wait(handshake); | ||
636 | 95 | |||
637 | 96 | g_object_unref(con); | ||
638 | 97 | |||
639 | 98 | return; | ||
640 | 99 | } | ||
641 | 100 | |||
642 | 101 | static gboolean | ||
643 | 102 | two_second_reached (gpointer user_data) | ||
644 | 103 | { | ||
645 | 104 | bool * reached = static_cast<bool *>(user_data); | ||
646 | 105 | *reached = true; | ||
647 | 106 | } | ||
648 | 107 | |||
649 | 108 | TEST_F(HelperHandshakeTest, HandshakeTimeout) | ||
650 | 109 | { | ||
651 | 110 | bool timeout_reached = false; | ||
652 | 111 | handshake_t * handshake = starting_handshake_start("fooapp"); | ||
653 | 112 | |||
654 | 113 | guint outertimeout = g_timeout_add_seconds(2, two_second_reached, &timeout_reached); | ||
655 | 114 | |||
656 | 115 | starting_handshake_wait(handshake); | ||
657 | 116 | |||
658 | 117 | ASSERT_FALSE(timeout_reached); | ||
659 | 118 | |||
660 | 119 | return; | ||
661 | 120 | } | ||
662 | 0 | 121 | ||
663 | === modified file 'tests/libual-test.cc' | |||
664 | --- tests/libual-test.cc 2013-11-25 14:49:12 +0000 | |||
665 | +++ tests/libual-test.cc 2013-12-06 12:27:28 +0000 | |||
666 | @@ -182,6 +182,27 @@ | |||
667 | 182 | 182 | ||
668 | 183 | return found; | 183 | return found; |
669 | 184 | } | 184 | } |
670 | 185 | |||
671 | 186 | static gboolean pause_helper (gpointer pmainloop) { | ||
672 | 187 | g_main_loop_quit((GMainLoop *)pmainloop); | ||
673 | 188 | return G_SOURCE_REMOVE; | ||
674 | 189 | } | ||
675 | 190 | |||
676 | 191 | void pause (guint time) { | ||
677 | 192 | if (time > 0) { | ||
678 | 193 | GMainLoop * mainloop = g_main_loop_new(NULL, FALSE); | ||
679 | 194 | guint timer = g_timeout_add(time, pause_helper, mainloop); | ||
680 | 195 | |||
681 | 196 | g_main_loop_run(mainloop); | ||
682 | 197 | |||
683 | 198 | g_source_remove(timer); | ||
684 | 199 | g_main_loop_unref(mainloop); | ||
685 | 200 | } | ||
686 | 201 | |||
687 | 202 | while (g_main_pending()) { | ||
688 | 203 | g_main_iteration(TRUE); | ||
689 | 204 | } | ||
690 | 205 | } | ||
691 | 185 | }; | 206 | }; |
692 | 186 | 207 | ||
693 | 187 | TEST_F(LibUAL, StartApplication) | 208 | TEST_F(LibUAL, StartApplication) |
694 | @@ -307,7 +328,7 @@ | |||
695 | 307 | .name = nullptr | 328 | .name = nullptr |
696 | 308 | }; | 329 | }; |
697 | 309 | 330 | ||
699 | 310 | ASSERT_TRUE(upstart_app_launch_observer_add_app_start(observer_cb, &start_data)); | 331 | ASSERT_TRUE(upstart_app_launch_observer_add_app_started(observer_cb, &start_data)); |
700 | 311 | ASSERT_TRUE(upstart_app_launch_observer_add_app_stop(observer_cb, &stop_data)); | 332 | ASSERT_TRUE(upstart_app_launch_observer_add_app_stop(observer_cb, &stop_data)); |
701 | 312 | ASSERT_FALSE(upstart_app_launch_observer_add_app_failed(NULL, NULL)); /* Not yet implemented */ | 333 | ASSERT_FALSE(upstart_app_launch_observer_add_app_failed(NULL, NULL)); /* Not yet implemented */ |
702 | 313 | 334 | ||
703 | @@ -417,7 +438,59 @@ | |||
704 | 417 | 438 | ||
705 | 418 | 439 | ||
706 | 419 | /* Remove */ | 440 | /* Remove */ |
708 | 420 | ASSERT_TRUE(upstart_app_launch_observer_delete_app_start(observer_cb, &start_data)); | 441 | ASSERT_TRUE(upstart_app_launch_observer_delete_app_started(observer_cb, &start_data)); |
709 | 421 | ASSERT_TRUE(upstart_app_launch_observer_delete_app_stop(observer_cb, &stop_data)); | 442 | ASSERT_TRUE(upstart_app_launch_observer_delete_app_stop(observer_cb, &stop_data)); |
710 | 422 | ASSERT_FALSE(upstart_app_launch_observer_delete_app_failed(NULL, NULL)); /* Not yet implemented */ | 443 | ASSERT_FALSE(upstart_app_launch_observer_delete_app_failed(NULL, NULL)); /* Not yet implemented */ |
711 | 423 | } | 444 | } |
712 | 445 | |||
713 | 446 | static GDBusMessage * | ||
714 | 447 | filter_starting (GDBusConnection * conn, GDBusMessage * message, gboolean incomming, gpointer user_data) | ||
715 | 448 | { | ||
716 | 449 | if (g_strcmp0(g_dbus_message_get_member(message), "UnityStartingSignal") == 0) { | ||
717 | 450 | unsigned int * count = static_cast<unsigned int *>(user_data); | ||
718 | 451 | (*count)++; | ||
719 | 452 | g_object_unref(message); | ||
720 | 453 | return NULL; | ||
721 | 454 | } | ||
722 | 455 | |||
723 | 456 | return message; | ||
724 | 457 | } | ||
725 | 458 | |||
726 | 459 | static void | ||
727 | 460 | starting_observer (const gchar * appid, gpointer user_data) | ||
728 | 461 | { | ||
729 | 462 | std::string * last = static_cast<std::string *>(user_data); | ||
730 | 463 | *last = appid; | ||
731 | 464 | return; | ||
732 | 465 | } | ||
733 | 466 | |||
734 | 467 | TEST_F(LibUAL, StartingResponses) | ||
735 | 468 | { | ||
736 | 469 | std::string last_observer; | ||
737 | 470 | unsigned int starting_count = 0; | ||
738 | 471 | GDBusConnection * session = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, NULL); | ||
739 | 472 | guint filter = g_dbus_connection_add_filter(session, | ||
740 | 473 | filter_starting, | ||
741 | 474 | &starting_count, | ||
742 | 475 | NULL); | ||
743 | 476 | |||
744 | 477 | EXPECT_TRUE(upstart_app_launch_observer_add_app_starting(starting_observer, &last_observer)); | ||
745 | 478 | |||
746 | 479 | g_dbus_connection_emit_signal(session, | ||
747 | 480 | NULL, /* destination */ | ||
748 | 481 | "/", /* path */ | ||
749 | 482 | "com.canonical.UpstartAppLaunch", /* interface */ | ||
750 | 483 | "UnityStartingBroadcast", /* signal */ | ||
751 | 484 | g_variant_new("(s)", "foo"), /* params, the same */ | ||
752 | 485 | NULL); | ||
753 | 486 | |||
754 | 487 | pause(100); | ||
755 | 488 | |||
756 | 489 | EXPECT_EQ("foo", last_observer); | ||
757 | 490 | EXPECT_EQ(1, starting_count); | ||
758 | 491 | |||
759 | 492 | EXPECT_TRUE(upstart_app_launch_observer_delete_app_starting(starting_observer, &last_observer)); | ||
760 | 493 | |||
761 | 494 | g_dbus_connection_remove_filter(session, filter); | ||
762 | 495 | g_object_unref(session); | ||
763 | 496 | } | ||
764 | 424 | 497 | ||
765 | === modified file 'tests/second-exec-test.cc' | |||
766 | --- tests/second-exec-test.cc 2013-10-04 19:22:41 +0000 | |||
767 | +++ tests/second-exec-test.cc 2013-12-06 12:27:28 +0000 | |||
768 | @@ -58,8 +58,6 @@ | |||
769 | 58 | 58 | ||
770 | 59 | upstart_app_launch_observer_add_app_focus(focus_cb, this); | 59 | upstart_app_launch_observer_add_app_focus(focus_cb, this); |
771 | 60 | upstart_app_launch_observer_add_app_resume(resume_cb, this); | 60 | upstart_app_launch_observer_add_app_resume(resume_cb, this); |
772 | 61 | |||
773 | 62 | return; | ||
774 | 63 | } | 61 | } |
775 | 64 | virtual void TearDown() { | 62 | virtual void TearDown() { |
776 | 65 | upstart_app_launch_observer_delete_app_focus(focus_cb, this); | 63 | upstart_app_launch_observer_delete_app_focus(focus_cb, this); |
777 | @@ -67,8 +65,6 @@ | |||
778 | 67 | 65 | ||
779 | 68 | g_test_dbus_down(testbus); | 66 | g_test_dbus_down(testbus); |
780 | 69 | g_object_unref(testbus); | 67 | g_object_unref(testbus); |
781 | 70 | |||
782 | 71 | return; | ||
783 | 72 | } | 68 | } |
784 | 73 | 69 | ||
785 | 74 | static gboolean pause_helper (gpointer pmainloop) { | 70 | static gboolean pause_helper (gpointer pmainloop) { |
786 | @@ -90,8 +86,6 @@ | |||
787 | 90 | while (g_main_pending()) { | 86 | while (g_main_pending()) { |
788 | 91 | g_main_iteration(TRUE); | 87 | g_main_iteration(TRUE); |
789 | 92 | } | 88 | } |
790 | 93 | |||
791 | 94 | return; | ||
792 | 95 | } | 89 | } |
793 | 96 | }; | 90 | }; |
794 | 97 | 91 | ||
795 | 98 | 92 | ||
796 | === modified file 'upstart-app-watch.c' | |||
797 | --- upstart-app-watch.c 2013-09-24 22:18:11 +0000 | |||
798 | +++ upstart-app-watch.c 2013-12-06 12:27:28 +0000 | |||
799 | @@ -20,30 +20,37 @@ | |||
800 | 20 | #include "libupstart-app-launch/upstart-app-launch.h" | 20 | #include "libupstart-app-launch/upstart-app-launch.h" |
801 | 21 | 21 | ||
802 | 22 | void | 22 | void |
803 | 23 | starting (const gchar * appid, gpointer user_data) | ||
804 | 24 | { | ||
805 | 25 | g_print("Starting %s\n", appid); | ||
806 | 26 | return; | ||
807 | 27 | } | ||
808 | 28 | |||
809 | 29 | void | ||
810 | 23 | started (const gchar * appid, gpointer user_data) | 30 | started (const gchar * appid, gpointer user_data) |
811 | 24 | { | 31 | { |
813 | 25 | g_print("Start %s\n", appid); | 32 | g_print("Started %s\n", appid); |
814 | 26 | return; | 33 | return; |
815 | 27 | } | 34 | } |
816 | 28 | 35 | ||
817 | 29 | void | 36 | void |
818 | 30 | stopped (const gchar * appid, gpointer user_data) | 37 | stopped (const gchar * appid, gpointer user_data) |
819 | 31 | { | 38 | { |
821 | 32 | g_print("Stop %s\n", appid); | 39 | g_print("Stop %s\n", appid); |
822 | 33 | return; | 40 | return; |
823 | 34 | } | 41 | } |
824 | 35 | 42 | ||
825 | 36 | void | 43 | void |
826 | 37 | resume (const gchar * appid, gpointer user_data) | 44 | resume (const gchar * appid, gpointer user_data) |
827 | 38 | { | 45 | { |
829 | 39 | g_print("Resume %s\n", appid); | 46 | g_print("Resume %s\n", appid); |
830 | 40 | return; | 47 | return; |
831 | 41 | } | 48 | } |
832 | 42 | 49 | ||
833 | 43 | void | 50 | void |
834 | 44 | focus (const gchar * appid, gpointer user_data) | 51 | focus (const gchar * appid, gpointer user_data) |
835 | 45 | { | 52 | { |
837 | 46 | g_print("Focus %s\n", appid); | 53 | g_print("Focus %s\n", appid); |
838 | 47 | return; | 54 | return; |
839 | 48 | } | 55 | } |
840 | 49 | 56 | ||
841 | @@ -60,7 +67,7 @@ | |||
842 | 60 | break; | 67 | break; |
843 | 61 | } | 68 | } |
844 | 62 | 69 | ||
846 | 63 | g_print("Focus %s (%s)\n", appid, failstr); | 70 | g_print("Fail %s (%s)\n", appid, failstr); |
847 | 64 | return; | 71 | return; |
848 | 65 | } | 72 | } |
849 | 66 | 73 | ||
850 | @@ -68,7 +75,8 @@ | |||
851 | 68 | int | 75 | int |
852 | 69 | main (int argc, gchar * argv[]) | 76 | main (int argc, gchar * argv[]) |
853 | 70 | { | 77 | { |
855 | 71 | upstart_app_launch_observer_add_app_start(started, NULL); | 78 | upstart_app_launch_observer_add_app_starting(starting, NULL); |
856 | 79 | upstart_app_launch_observer_add_app_started(started, NULL); | ||
857 | 72 | upstart_app_launch_observer_add_app_stop(stopped, NULL); | 80 | upstart_app_launch_observer_add_app_stop(stopped, NULL); |
858 | 73 | upstart_app_launch_observer_add_app_focus(focus, NULL); | 81 | upstart_app_launch_observer_add_app_focus(focus, NULL); |
859 | 74 | upstart_app_launch_observer_add_app_resume(resume, NULL); | 82 | upstart_app_launch_observer_add_app_resume(resume, NULL); |
860 | @@ -77,7 +85,8 @@ | |||
861 | 77 | GMainLoop * mainloop = g_main_loop_new(NULL, FALSE); | 85 | GMainLoop * mainloop = g_main_loop_new(NULL, FALSE); |
862 | 78 | g_main_loop_run(mainloop); | 86 | g_main_loop_run(mainloop); |
863 | 79 | 87 | ||
865 | 80 | upstart_app_launch_observer_delete_app_start(started, NULL); | 88 | upstart_app_launch_observer_delete_app_starting(starting, NULL); |
866 | 89 | upstart_app_launch_observer_delete_app_started(started, NULL); | ||
867 | 81 | upstart_app_launch_observer_delete_app_stop(stopped, NULL); | 90 | upstart_app_launch_observer_delete_app_stop(stopped, NULL); |
868 | 82 | upstart_app_launch_observer_delete_app_focus(focus, NULL); | 91 | upstart_app_launch_observer_delete_app_focus(focus, NULL); |
869 | 83 | upstart_app_launch_observer_delete_app_resume(resume, NULL); | 92 | upstart_app_launch_observer_delete_app_resume(resume, NULL); |
FAILED: Continuous integration, rev:107 jenkins. qa.ubuntu. com/job/ upstart- app-launch- ci/168/ jenkins. qa.ubuntu. com/job/ upstart- app-launch- trusty- amd64-ci/ 27 jenkins. qa.ubuntu. com/job/ upstart- app-launch- trusty- armhf-ci/ 27/console jenkins. qa.ubuntu. com/job/ upstart- app-launch- trusty- i386-ci/ 27/console
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/upstart- app-launch- ci/168/ rebuild
http://