Merge lp:~3v1n0/bamf/app-icon-fallback-improved into lp:bamf
- app-icon-fallback-improved
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Brandon Schaefer |
Approved revision: | 589 |
Merged at revision: | 559 |
Proposed branch: | lp:~3v1n0/bamf/app-icon-fallback-improved |
Merge into: | lp:bamf |
Diff against target: |
616 lines (+314/-69) 10 files modified
src/bamf-application.c (+63/-25) src/bamf-legacy-window-test.c (+19/-0) src/bamf-legacy-window-test.h (+4/-0) src/bamf-legacy-window.c (+3/-0) src/bamf-legacy-window.h (+1/-0) src/bamf-matcher.h (+6/-0) tests/bamfdaemon/test-application.c (+206/-44) tests/bamfdaemon/test-bamf.c (+4/-0) tests/data/icon.desktop (+7/-0) tests/libbamf/Makefile.am (+1/-0) |
To merge this branch: | bzr merge lp:~3v1n0/bamf/app-icon-fallback-improved |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Brandon Schaefer (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+170871@code.launchpad.net |
Commit message
BamfApplication: try to use a window icon if the computed icon belongs to a "generic" app
Added a bunch of new BamfApplication tests for icon.
Description of the change
Improve the code to get a fallback icon for .desktop-less applications, now if the application icon is "generic" (i.e. the one of a known loader such as python), we try instead to fetch the window icon if available and giving it higher priority.
Added a bunch of new tests.
PS Jenkins bot (ps-jenkins) wrote : | # |
- 588. By Marco Trevisan (Treviño)
-
TestLibBamf, Makefile.am: fix make distcheck
- 589. By Marco Trevisan (Treviño)
-
TestBamf: add local icon directory and prepend it to theme to allow testing
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:589
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:587
http://
Executed test runs:
SUCCESS: http://
None: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:587
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:587
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Brandon Schaefer (brandontschaefer) wrote : | # |
Sweet, tests pass, code looks good, and tested manually :)
Preview Diff
1 | === modified file 'src/bamf-application.c' |
2 | --- src/bamf-application.c 2013-06-19 19:08:39 +0000 |
3 | +++ src/bamf-application.c 2013-06-21 21:00:38 +0000 |
4 | @@ -178,17 +178,25 @@ |
5 | } |
6 | |
7 | static gboolean |
8 | -icon_name_is_valid (char *name) |
9 | +icon_name_is_valid (const char *name) |
10 | { |
11 | GtkIconTheme *icon_theme; |
12 | |
13 | - if (name == NULL) |
14 | + if (!name || name[0] == '\0') |
15 | return FALSE; |
16 | |
17 | icon_theme = gtk_icon_theme_get_default (); |
18 | return gtk_icon_theme_has_icon (icon_theme, name); |
19 | } |
20 | |
21 | +static gboolean |
22 | +icon_name_is_generic (const char *name) |
23 | +{ |
24 | + BamfMatcher *matcher = bamf_matcher_get_default (); |
25 | + |
26 | + return !bamf_matcher_is_valid_process_prefix (matcher, name); |
27 | +} |
28 | + |
29 | static void |
30 | bamf_application_setup_icon_and_name (BamfApplication *self) |
31 | { |
32 | @@ -199,7 +207,7 @@ |
33 | GIcon *gicon; |
34 | GList *children, *l; |
35 | const char *class; |
36 | - char *icon = NULL, *name = NULL; |
37 | + char *icon = NULL, *generic_icon = NULL, *name = NULL; |
38 | GError *error; |
39 | |
40 | g_return_if_fail (BAMF_IS_APPLICATION (self)); |
41 | @@ -221,7 +229,7 @@ |
42 | |
43 | if (!G_IS_APP_INFO (desktop)) |
44 | { |
45 | - g_key_file_free(keyfile); |
46 | + g_key_file_free (keyfile); |
47 | return; |
48 | } |
49 | |
50 | @@ -231,13 +239,20 @@ |
51 | if (gicon) |
52 | { |
53 | icon = g_icon_to_string (gicon); |
54 | + |
55 | + if (!icon_name_is_valid (icon)) |
56 | + { |
57 | + g_free (icon); |
58 | + icon = NULL; |
59 | + } |
60 | } |
61 | - else |
62 | + |
63 | + if (!icon) |
64 | { |
65 | icon = g_strdup (BAMF_APPLICATION_DEFAULT_ICON); |
66 | } |
67 | |
68 | - if (g_key_file_has_key(keyfile, G_KEY_FILE_DESKTOP_GROUP, STUB_KEY, NULL)) |
69 | + if (g_key_file_has_key (keyfile, G_KEY_FILE_DESKTOP_GROUP, STUB_KEY, NULL)) |
70 | { |
71 | /* This will error to return false, which is okay as it seems |
72 | unlikely anyone will want to set this flag except to turn |
73 | @@ -269,7 +284,7 @@ |
74 | } |
75 | |
76 | g_object_unref (desktop); |
77 | - g_key_file_free(keyfile); |
78 | + g_key_file_free (keyfile); |
79 | } |
80 | else if ((children = bamf_view_get_children (BAMF_VIEW (self))) != NULL) |
81 | { |
82 | @@ -290,14 +305,34 @@ |
83 | icon = g_utf8_strdown (class, -1); |
84 | |
85 | if (icon_name_is_valid (icon)) |
86 | - break; |
87 | + { |
88 | + if (icon_name_is_generic (icon)) |
89 | + { |
90 | + generic_icon = g_strdup (icon); |
91 | + } |
92 | + else |
93 | + { |
94 | + break; |
95 | + } |
96 | + } |
97 | } |
98 | |
99 | g_free (icon); |
100 | - icon = bamf_legacy_window_get_exec_string (bamf_window_get_window (window)); |
101 | + char *exec = bamf_legacy_window_get_exec_string (bamf_window_get_window (window)); |
102 | + icon = bamf_matcher_get_trimmed_exec (bamf_matcher_get_default (), exec); |
103 | + g_free (exec); |
104 | |
105 | if (icon_name_is_valid (icon)) |
106 | - break; |
107 | + { |
108 | + if (icon_name_is_generic (icon)) |
109 | + { |
110 | + generic_icon = g_strdup (icon); |
111 | + } |
112 | + else |
113 | + { |
114 | + break; |
115 | + } |
116 | + } |
117 | |
118 | g_free (icon); |
119 | icon = NULL; |
120 | @@ -310,28 +345,31 @@ |
121 | if (!icon) |
122 | { |
123 | if (window) |
124 | - { |
125 | - icon = g_strdup (bamf_legacy_window_save_mini_icon (bamf_window_get_window (window))); |
126 | - } |
127 | + icon = g_strdup (bamf_legacy_window_save_mini_icon (bamf_window_get_window (window))); |
128 | |
129 | if (!icon) |
130 | { |
131 | - icon = g_strdup (BAMF_APPLICATION_DEFAULT_ICON); |
132 | + if (generic_icon) |
133 | + { |
134 | + icon = generic_icon; |
135 | + generic_icon = NULL; |
136 | + } |
137 | + else |
138 | + { |
139 | + icon = g_strdup (BAMF_APPLICATION_DEFAULT_ICON); |
140 | + } |
141 | } |
142 | } |
143 | - } |
144 | - else |
145 | - { |
146 | - /* we do nothing as we have nothing to go on */ |
147 | - } |
148 | - |
149 | - if (icon) |
150 | - bamf_view_set_icon (BAMF_VIEW (self), icon); |
151 | - |
152 | - if (name) |
153 | - bamf_view_set_name (BAMF_VIEW (self), name); |
154 | + |
155 | + g_free (generic_icon); |
156 | + generic_icon = NULL; |
157 | + } |
158 | + |
159 | + bamf_view_set_icon (BAMF_VIEW (self), icon); |
160 | + bamf_view_set_name (BAMF_VIEW (self), name); |
161 | |
162 | g_free (name); |
163 | + g_free (icon); |
164 | } |
165 | |
166 | void |
167 | |
168 | === modified file 'src/bamf-legacy-window-test.c' |
169 | --- src/bamf-legacy-window-test.c 2013-04-18 13:57:15 +0000 |
170 | +++ src/bamf-legacy-window-test.c 2013-06-21 21:00:38 +0000 |
171 | @@ -139,6 +139,16 @@ |
172 | } |
173 | |
174 | void |
175 | +bamf_legacy_window_test_set_icon (BamfLegacyWindowTest *self, const char *val) |
176 | +{ |
177 | + if (g_strcmp0 (self->icon, val) == 0) |
178 | + return; |
179 | + |
180 | + g_free (self->icon); |
181 | + self->icon = g_strdup (val); |
182 | +} |
183 | + |
184 | +void |
185 | bamf_legacy_window_test_set_role (BamfLegacyWindowTest *self, const char *val) |
186 | { |
187 | if (g_strcmp0 (self->role, val) == 0) |
188 | @@ -410,12 +420,19 @@ |
189 | return g_hash_table_insert (self->hints, g_strdup (name), g_strdup (value)); |
190 | } |
191 | |
192 | +static const char * |
193 | +bamf_legacy_window_test_save_mini_icon (BamfLegacyWindow *window) |
194 | +{ |
195 | + return BAMF_LEGACY_WINDOW_TEST (window)->icon; |
196 | +} |
197 | + |
198 | static void |
199 | bamf_legacy_window_test_finalize (GObject *object) |
200 | { |
201 | BamfLegacyWindowTest *self = BAMF_LEGACY_WINDOW_TEST (object); |
202 | |
203 | g_free (self->name); |
204 | + g_free (self->icon); |
205 | g_free (self->role); |
206 | g_free (self->wm_class_name); |
207 | g_free (self->wm_class_instance); |
208 | @@ -438,6 +455,7 @@ |
209 | obj_class->finalize = bamf_legacy_window_test_finalize; |
210 | win_class->get_transient = bamf_legacy_window_test_get_transient; |
211 | win_class->get_name = bamf_legacy_window_test_get_name; |
212 | + win_class->save_mini_icon = bamf_legacy_window_test_save_mini_icon; |
213 | win_class->get_role = bamf_legacy_window_test_get_role; |
214 | win_class->get_class_name = bamf_legacy_window_test_get_class_name; |
215 | win_class->get_class_instance_name = bamf_legacy_window_test_get_class_instance_name; |
216 | @@ -481,6 +499,7 @@ |
217 | copy->xid = self->xid; |
218 | copy->pid = self->pid; |
219 | copy->name = g_strdup (self->name); |
220 | + copy->icon = g_strdup (self->icon); |
221 | copy->role = g_strdup (self->role); |
222 | copy->wm_class_name = g_strdup (self->wm_class_name); |
223 | copy->wm_class_instance = g_strdup (self->wm_class_instance); |
224 | |
225 | === modified file 'src/bamf-legacy-window-test.h' |
226 | --- src/bamf-legacy-window-test.h 2013-04-17 00:56:22 +0000 |
227 | +++ src/bamf-legacy-window-test.h 2013-06-21 21:00:38 +0000 |
228 | @@ -54,6 +54,7 @@ |
229 | guint32 xid; |
230 | guint pid; |
231 | char * name; |
232 | + char * icon; |
233 | char * role; |
234 | char * wm_class_name; |
235 | char * wm_class_instance; |
236 | @@ -123,6 +124,9 @@ |
237 | bamf_legacy_window_test_set_name (BamfLegacyWindowTest *self, const char *val); |
238 | |
239 | void |
240 | +bamf_legacy_window_test_set_icon (BamfLegacyWindowTest *self, const char *val); |
241 | + |
242 | +void |
243 | bamf_legacy_window_test_set_role (BamfLegacyWindowTest *self, const char *val); |
244 | |
245 | void |
246 | |
247 | === modified file 'src/bamf-legacy-window.c' |
248 | --- src/bamf-legacy-window.c 2013-06-18 13:44:04 +0000 |
249 | +++ src/bamf-legacy-window.c 2013-06-21 21:00:38 +0000 |
250 | @@ -267,6 +267,9 @@ |
251 | |
252 | g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), NULL); |
253 | |
254 | + if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->save_mini_icon) |
255 | + return BAMF_LEGACY_WINDOW_GET_CLASS (self)->save_mini_icon (self); |
256 | + |
257 | if (self->priv->mini_icon_path) |
258 | { |
259 | if (g_file_test (self->priv->mini_icon_path, G_FILE_TEST_EXISTS)) |
260 | |
261 | === modified file 'src/bamf-legacy-window.h' |
262 | --- src/bamf-legacy-window.h 2013-06-08 13:54:06 +0000 |
263 | +++ src/bamf-legacy-window.h 2013-06-21 21:00:38 +0000 |
264 | @@ -76,6 +76,7 @@ |
265 | const char * (*get_role) (BamfLegacyWindow *legacy_window); |
266 | const char * (*get_class_name) (BamfLegacyWindow *legacy_window); |
267 | const char * (*get_class_instance_name) (BamfLegacyWindow *legacy_window); |
268 | + const char * (*save_mini_icon) (BamfLegacyWindow *legacy_window); |
269 | char * (*get_exec_string) (BamfLegacyWindow *legacy_window); |
270 | char * (*get_process_name) (BamfLegacyWindow *legacy_window); |
271 | char * (*get_app_id) (BamfLegacyWindow *legacy_window); |
272 | |
273 | === modified file 'src/bamf-matcher.h' |
274 | --- src/bamf-matcher.h 2013-06-08 13:54:06 +0000 |
275 | +++ src/bamf-matcher.h 2013-06-21 21:00:38 +0000 |
276 | @@ -108,6 +108,12 @@ |
277 | GVariant * bamf_matcher_get_window_stack_for_monitor (BamfMatcher *matcher, |
278 | gint monitor); |
279 | |
280 | +gboolean bamf_matcher_is_valid_process_prefix (BamfMatcher *matcher, |
281 | + const char *process_name); |
282 | + |
283 | +char * bamf_matcher_get_trimmed_exec (BamfMatcher *matcher, |
284 | + const char *exec_string); |
285 | + |
286 | |
287 | BamfMatcher * bamf_matcher_get_default (void); |
288 | |
289 | |
290 | === modified file 'tests/bamfdaemon/test-application.c' |
291 | --- tests/bamfdaemon/test-application.c 2013-06-18 17:55:15 +0000 |
292 | +++ tests/bamfdaemon/test-application.c 2013-06-21 21:00:38 +0000 |
293 | @@ -28,48 +28,11 @@ |
294 | |
295 | #define DESKTOP_FILE "/usr/share/applications/gnome-terminal.desktop" |
296 | |
297 | -static void test_allocation (void); |
298 | -static void test_desktop_file (void); |
299 | -static void test_desktop_no_icon (void); |
300 | -static void test_get_mime_types (void); |
301 | -static void test_get_mime_types_none (void); |
302 | -static void test_urgent (void); |
303 | -static void test_active (void); |
304 | -static void test_get_xids (void); |
305 | -static void test_manages_xid (void); |
306 | -static void test_get_window (void); |
307 | -static void test_user_visible (void); |
308 | -static void test_urgent (void); |
309 | -static void test_window_added (void); |
310 | -static void test_window_removed (void); |
311 | - |
312 | static gboolean signal_seen = FALSE; |
313 | static gboolean signal_result = FALSE; |
314 | static char * signal_window = NULL; |
315 | static GDBusConnection * gdbus_connection = NULL; |
316 | |
317 | -void |
318 | -test_application_create_suite (GDBusConnection *connection) |
319 | -{ |
320 | -#define DOMAIN "/Application" |
321 | - |
322 | - gdbus_connection = connection; |
323 | - |
324 | - g_test_add_func (DOMAIN"/Allocation", test_allocation); |
325 | - g_test_add_func (DOMAIN"/DesktopFile", test_desktop_file); |
326 | - g_test_add_func (DOMAIN"/DesktopFile/NoIcon", test_desktop_no_icon); |
327 | - g_test_add_func (DOMAIN"/DesktopFile/MimeTypes/Valid", test_get_mime_types); |
328 | - g_test_add_func (DOMAIN"/DesktopFile/MimeTypes/None", test_get_mime_types_none); |
329 | - g_test_add_func (DOMAIN"/ManagesXid", test_manages_xid); |
330 | - g_test_add_func (DOMAIN"/GetWindow", test_get_window); |
331 | - g_test_add_func (DOMAIN"/Xids", test_get_xids); |
332 | - g_test_add_func (DOMAIN"/Events/Active", test_active); |
333 | - g_test_add_func (DOMAIN"/Events/Urgent", test_urgent); |
334 | - g_test_add_func (DOMAIN"/Events/UserVisible", test_user_visible); |
335 | - g_test_add_func (DOMAIN"/Events/WindowAdded", test_window_added); |
336 | - g_test_add_func (DOMAIN"/Events/WindowRemoved", test_window_removed); |
337 | -} |
338 | - |
339 | static void |
340 | test_allocation (void) |
341 | { |
342 | @@ -108,16 +71,183 @@ |
343 | } |
344 | |
345 | static void |
346 | -test_desktop_no_icon (void) |
347 | -{ |
348 | - BamfApplication *application; |
349 | +test_desktop_icon (void) |
350 | +{ |
351 | + BamfApplication *application; |
352 | + const char *icon_desktop = TESTDIR"/data/icon.desktop"; |
353 | + |
354 | + application = bamf_application_new_from_desktop_file (icon_desktop); |
355 | + g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "test-bamf-icon"); |
356 | + g_object_unref (application); |
357 | +} |
358 | + |
359 | +static void |
360 | +test_desktop_icon_empty (void) |
361 | +{ |
362 | + BamfApplication *application; |
363 | const char no_icon_desktop[] = TESTDIR"/data/no-icon.desktop"; |
364 | |
365 | application = bamf_application_new_from_desktop_file (no_icon_desktop); |
366 | - g_assert (g_strcmp0 (bamf_application_get_desktop_file (application), no_icon_desktop) == 0); |
367 | - |
368 | - g_assert (g_strcmp0(bamf_view_get_icon(BAMF_VIEW(application)), "application-default-icon") == 0); |
369 | - g_object_unref (application); |
370 | + g_assert_cmpstr (bamf_application_get_desktop_file (application), ==, no_icon_desktop); |
371 | + |
372 | + g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "application-default-icon"); |
373 | + g_object_unref (application); |
374 | +} |
375 | + |
376 | +static void |
377 | +test_desktop_icon_invalid (void) |
378 | +{ |
379 | + BamfApplication *application; |
380 | + const char *invalid_icon_desktop = TESTDIR"/data/test-bamf-app.desktop"; |
381 | + |
382 | + application = bamf_application_new_from_desktop_file (invalid_icon_desktop); |
383 | + |
384 | + g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "application-default-icon"); |
385 | + g_object_unref (application); |
386 | +} |
387 | + |
388 | +static void |
389 | +test_icon_class_name (void) |
390 | +{ |
391 | + BamfApplication *application; |
392 | + BamfLegacyWindowTest *lwin; |
393 | + BamfWindow *test; |
394 | + |
395 | + application = bamf_application_new (); |
396 | + lwin = bamf_legacy_window_test_new (20, "window", "test-bamf-icon", "execution-binary"); |
397 | + test = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); |
398 | + |
399 | + bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (test)); |
400 | + |
401 | + g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "test-bamf-icon"); |
402 | + |
403 | + g_object_unref (lwin); |
404 | + g_object_unref (test); |
405 | + g_object_unref (application); |
406 | +} |
407 | + |
408 | +static void |
409 | +test_icon_exec_string (void) |
410 | +{ |
411 | + BamfApplication *application; |
412 | + BamfLegacyWindowTest *lwin; |
413 | + BamfWindow *test; |
414 | + |
415 | + application = bamf_application_new (); |
416 | + lwin = bamf_legacy_window_test_new (20, "window", "class", "test-bamf-icon"); |
417 | + test = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); |
418 | + |
419 | + bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (test)); |
420 | + |
421 | + g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "test-bamf-icon"); |
422 | + |
423 | + g_object_unref (lwin); |
424 | + g_object_unref (test); |
425 | + g_object_unref (application); |
426 | +} |
427 | + |
428 | +static void |
429 | +test_icon_embedded (void) |
430 | +{ |
431 | + BamfApplication *application; |
432 | + BamfLegacyWindowTest *lwin; |
433 | + BamfWindow *test; |
434 | + |
435 | + application = bamf_application_new (); |
436 | + lwin = bamf_legacy_window_test_new (20, "window", "class", "python execution-script.py"); |
437 | + bamf_legacy_window_test_set_icon (lwin, "test-bamf-icon"); |
438 | + test = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); |
439 | + |
440 | + bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (test)); |
441 | + |
442 | + g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "test-bamf-icon"); |
443 | + |
444 | + g_object_unref (lwin); |
445 | + g_object_unref (test); |
446 | + g_object_unref (application); |
447 | +} |
448 | + |
449 | +static void |
450 | +test_icon_priority (void) |
451 | +{ |
452 | + BamfApplication *application; |
453 | + BamfLegacyWindowTest *lwin; |
454 | + BamfWindow *test; |
455 | + |
456 | + lwin = bamf_legacy_window_test_new (20, "window", "test-bamf-icon", "test-bamf-pixmap"); |
457 | + bamf_legacy_window_test_set_icon (lwin, "bamf-custom-icon"); |
458 | + test = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); |
459 | + |
460 | + application = bamf_application_new (); |
461 | + bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (test)); |
462 | + g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "test-bamf-icon"); |
463 | + g_object_unref (application); |
464 | + |
465 | + application = bamf_application_new (); |
466 | + bamf_legacy_window_test_set_wmclass (lwin, NULL, NULL); |
467 | + bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (test)); |
468 | + g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "test-bamf-pixmap"); |
469 | + g_object_unref (application); |
470 | + |
471 | + application = bamf_application_new (); |
472 | + g_free (lwin->exec); |
473 | + lwin->exec = NULL; |
474 | + bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (test)); |
475 | + g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "bamf-custom-icon"); |
476 | + g_object_unref (application); |
477 | + |
478 | + g_object_unref (lwin); |
479 | + g_object_unref (test); |
480 | +} |
481 | + |
482 | +static void |
483 | +test_icon_generic_class (void) |
484 | +{ |
485 | + BamfApplication *application; |
486 | + BamfLegacyWindowTest *lwin; |
487 | + BamfWindow *test; |
488 | + |
489 | + lwin = bamf_legacy_window_test_new (20, "window", "python", "execution-script"); |
490 | + test = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); |
491 | + |
492 | + application = bamf_application_new (); |
493 | + bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (test)); |
494 | + g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "python"); |
495 | + g_object_unref (application); |
496 | + |
497 | + application = bamf_application_new (); |
498 | + bamf_legacy_window_test_set_icon (lwin, "bamf-custom-icon"); |
499 | + bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (test)); |
500 | + g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "bamf-custom-icon"); |
501 | + g_object_unref (application); |
502 | + |
503 | + g_object_unref (lwin); |
504 | + g_object_unref (test); |
505 | +} |
506 | + |
507 | +static void |
508 | +test_icon_generic_exec (void) |
509 | +{ |
510 | + BamfApplication *application; |
511 | + BamfLegacyWindowTest *lwin; |
512 | + BamfWindow *test; |
513 | + |
514 | + lwin = bamf_legacy_window_test_new (20, "window", "class", "python2.7"); |
515 | + test = bamf_window_new (BAMF_LEGACY_WINDOW (lwin)); |
516 | + |
517 | + application = bamf_application_new (); |
518 | + bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (test)); |
519 | + g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "python2.7"); |
520 | + g_object_unref (application); |
521 | + |
522 | + application = bamf_application_new (); |
523 | + bamf_legacy_window_test_set_icon (lwin, "bamf-custom-icon"); |
524 | + bamf_view_add_child (BAMF_VIEW (application), BAMF_VIEW (test)); |
525 | + g_assert_cmpstr (bamf_view_get_icon (BAMF_VIEW (application)), ==, "bamf-custom-icon"); |
526 | + g_object_unref (application); |
527 | + |
528 | + g_object_unref (lwin); |
529 | + g_object_unref (test); |
530 | } |
531 | |
532 | static void |
533 | @@ -558,3 +688,35 @@ |
534 | g_object_unref (window); |
535 | g_object_unref (test); |
536 | } |
537 | + |
538 | +/* Initialize test suite */ |
539 | + |
540 | +void |
541 | +test_application_create_suite (GDBusConnection *connection) |
542 | +{ |
543 | +#define DOMAIN "/Application" |
544 | + |
545 | + gdbus_connection = connection; |
546 | + |
547 | + g_test_add_func (DOMAIN"/Allocation", test_allocation); |
548 | + g_test_add_func (DOMAIN"/DesktopFile", test_desktop_file); |
549 | + g_test_add_func (DOMAIN"/DesktopFile/Icon", test_desktop_icon); |
550 | + g_test_add_func (DOMAIN"/DesktopFile/Icon/Empty", test_desktop_icon_empty); |
551 | + g_test_add_func (DOMAIN"/DesktopFile/Icon/Invalid", test_desktop_icon_invalid); |
552 | + g_test_add_func (DOMAIN"/DesktopFile/MimeTypes/Valid", test_get_mime_types); |
553 | + g_test_add_func (DOMAIN"/DesktopFile/MimeTypes/None", test_get_mime_types_none); |
554 | + g_test_add_func (DOMAIN"/DesktopLess/Icon/ClassName", test_icon_class_name); |
555 | + g_test_add_func (DOMAIN"/DesktopLess/Icon/Exec", test_icon_exec_string); |
556 | + g_test_add_func (DOMAIN"/DesktopLess/Icon/Embedded", test_icon_embedded); |
557 | + g_test_add_func (DOMAIN"/DesktopLess/Icon/Priority", test_icon_priority); |
558 | + g_test_add_func (DOMAIN"/DesktopLess/Icon/Generic/Class", test_icon_generic_class); |
559 | + g_test_add_func (DOMAIN"/DesktopLess/Icon/Generic/Exec", test_icon_generic_exec); |
560 | + g_test_add_func (DOMAIN"/ManagesXid", test_manages_xid); |
561 | + g_test_add_func (DOMAIN"/GetWindow", test_get_window); |
562 | + g_test_add_func (DOMAIN"/Xids", test_get_xids); |
563 | + g_test_add_func (DOMAIN"/Events/Active", test_active); |
564 | + g_test_add_func (DOMAIN"/Events/Urgent", test_urgent); |
565 | + g_test_add_func (DOMAIN"/Events/UserVisible", test_user_visible); |
566 | + g_test_add_func (DOMAIN"/Events/WindowAdded", test_window_added); |
567 | + g_test_add_func (DOMAIN"/Events/WindowRemoved", test_window_removed); |
568 | +} |
569 | |
570 | === modified file 'tests/bamfdaemon/test-bamf.c' |
571 | --- tests/bamfdaemon/test-bamf.c 2013-06-13 17:08:07 +0000 |
572 | +++ tests/bamfdaemon/test-bamf.c 2013-06-21 21:00:38 +0000 |
573 | @@ -38,10 +38,14 @@ |
574 | on_bus_acquired (GDBusConnection *connection, const gchar *name, gpointer data) |
575 | { |
576 | GMainLoop *loop = data; |
577 | + GtkIconTheme *icon_theme; |
578 | |
579 | g_setenv ("BAMF_TEST_MODE", "TRUE", TRUE); |
580 | g_setenv ("PATH", TESTDIR"/data/bin", TRUE); |
581 | |
582 | + icon_theme = gtk_icon_theme_get_default (); |
583 | + gtk_icon_theme_prepend_search_path (icon_theme, TESTDIR"/data/icons"); |
584 | + |
585 | test_matcher_create_suite (connection); |
586 | test_view_create_suite (connection); |
587 | test_window_create_suite (); |
588 | |
589 | === added file 'tests/data/icon.desktop' |
590 | --- tests/data/icon.desktop 1970-01-01 00:00:00 +0000 |
591 | +++ tests/data/icon.desktop 2013-06-21 21:00:38 +0000 |
592 | @@ -0,0 +1,7 @@ |
593 | +[Desktop Entry] |
594 | +Name=Test Bamf App with Icon |
595 | +Exec=test-bamf-app |
596 | +Icon=test-bamf-icon |
597 | +Terminal=false |
598 | +Type=Application |
599 | +Categories=Graphics; |
600 | |
601 | === added directory 'tests/data/icons' |
602 | === added file 'tests/data/icons/python.png' |
603 | === added file 'tests/data/icons/python2.7.png' |
604 | === added file 'tests/data/icons/test-bamf-icon.png' |
605 | === added file 'tests/data/icons/test-bamf-pixmap.png' |
606 | === modified file 'tests/libbamf/Makefile.am' |
607 | --- tests/libbamf/Makefile.am 2013-06-08 13:54:06 +0000 |
608 | +++ tests/libbamf/Makefile.am 2013-06-21 21:00:38 +0000 |
609 | @@ -9,6 +9,7 @@ |
610 | |
611 | test_libbamf_CFLAGS = \ |
612 | -I$(top_srcdir)/lib \ |
613 | + -I$(top_builddir)/lib \ |
614 | -I$(top_srcdir)/lib/libbamf \ |
615 | -I$(top_builddir)/lib/libbamf \ |
616 | -DTESTDIR=\""$(abs_top_srcdir)/tests"\" \ |
FAILED: Continuous integration, rev:587 jenkins. qa.ubuntu. com/job/ bamf-ci/ 61/ jenkins. qa.ubuntu. com/job/ bamf-saucy- amd64-ci/ 42 jenkins. qa.ubuntu. com/job/ bamf-saucy- armhf-ci/ 42
http://
Executed test runs:
UNSTABLE: http://
UNSTABLE: http://
Click here to trigger a rebuild: s-jenkins: 8080/job/ bamf-ci/ 61/rebuild
http://