Merge lp:~3v1n0/bamf/javaws-ignore-desktop-0.2 into lp:bamf/0.2

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Brandon Schaefer
Approved revision: 498
Merged at revision: 491
Proposed branch: lp:~3v1n0/bamf/javaws-ignore-desktop-0.2
Merge into: lp:bamf/0.2
Diff against target: 473 lines (+241/-21)
8 files modified
src/bamf-legacy-window-test.c (+21/-0)
src/bamf-legacy-window-test.h (+1/-0)
src/bamf-legacy-window.c (+47/-0)
src/bamf-legacy-window.h (+4/-0)
src/bamf-matcher-private.h (+1/-0)
src/bamf-matcher.c (+48/-18)
tests/bamfdaemon/data/icedtea-netx-javaws.desktop (+12/-0)
tests/bamfdaemon/test-matcher.c (+107/-3)
To merge this branch: bzr merge lp:~3v1n0/bamf/javaws-ignore-desktop-0.2
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
Review via email: mp+145291@code.launchpad.net

Commit message

BamfMatcher: ignore the javaws windows when setting the window hint

Description of the change

Backport to Bamf-0.2 of lp:~3v1n0/bamf/javaws-ignore-desktop/+merge/145289

We need to avoid that a Java Web Application is associated with the default "Java Web Start" .desktop file provided by java as the default opener for jnlp files, or the bug #1098186 will show again.

Test added.

To post a comment you must log in.
493. By Marco Trevisan (Treviño) on 2013-01-29

Tests: add the missing icedtea-netx-javaws.desktop file

494. By Marco Trevisan (Treviño) on 2013-01-29

TestMatcher: fix javawm class names

495. By Marco Trevisan (Treviño) on 2013-01-29

BamfLegacyWindow: add a function to fetch the process name

496. By Marco Trevisan (Treviño) on 2013-01-29

BamfLegacyWindowTest: implement the get_process_name function

497. By Marco Trevisan (Treviño) on 2013-01-29

BamfMatcher: add bamf_matcher_is_valid_process_prefix to check for bad prefix process

Now we ignore the bad process prefixes also when using the
fallback process-name comparison. In this way the .desktop files
that they may provide to load files are ignored.

498. By Marco Trevisan (Treviño) on 2013-01-29

TestMatcher: added one more test to ensure javaws matching

Brandon Schaefer (brandontschaefer) wrote :

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/bamf-legacy-window-test.c'
--- src/bamf-legacy-window-test.c 2012-10-10 17:36:21 +0000
+++ src/bamf-legacy-window-test.c 2013-01-29 18:22:23 +0000
@@ -194,6 +194,16 @@
194}194}
195195
196char *196char *
197bamf_legacy_window_test_get_process_name (BamfLegacyWindow *legacy_window)
198{
199 BamfLegacyWindowTest *self;
200
201 self = BAMF_LEGACY_WINDOW_TEST (legacy_window);
202
203 return g_strdup (self->process_name);
204}
205
206char *
197bamf_legacy_window_test_get_app_id (BamfLegacyWindow *legacy_window)207bamf_legacy_window_test_get_app_id (BamfLegacyWindow *legacy_window)
198{208{
199 BamfLegacyWindowTest *self;209 BamfLegacyWindowTest *self;
@@ -371,6 +381,7 @@
371 g_free (self->wm_class_name);381 g_free (self->wm_class_name);
372 g_free (self->wm_class_instance);382 g_free (self->wm_class_instance);
373 g_free (self->exec);383 g_free (self->exec);
384 g_free (self->process_name);
374 g_free (self->application_id);385 g_free (self->application_id);
375 g_free (self->unique_bus_name);386 g_free (self->unique_bus_name);
376 g_free (self->dbus_menu_object_path);387 g_free (self->dbus_menu_object_path);
@@ -390,6 +401,7 @@
390 win_class->get_class_name = bamf_legacy_window_test_get_class_name;401 win_class->get_class_name = bamf_legacy_window_test_get_class_name;
391 win_class->get_class_instance_name = bamf_legacy_window_test_get_class_instance_name;402 win_class->get_class_instance_name = bamf_legacy_window_test_get_class_instance_name;
392 win_class->get_exec_string = bamf_legacy_window_test_get_exec_string;403 win_class->get_exec_string = bamf_legacy_window_test_get_exec_string;
404 win_class->get_process_name = bamf_legacy_window_test_get_process_name;
393 win_class->get_xid = bamf_legacy_window_test_get_xid;405 win_class->get_xid = bamf_legacy_window_test_get_xid;
394 win_class->get_pid = bamf_legacy_window_test_get_pid;406 win_class->get_pid = bamf_legacy_window_test_get_pid;
395 win_class->needs_attention = bamf_legacy_window_test_needs_attention;407 win_class->needs_attention = bamf_legacy_window_test_needs_attention;
@@ -431,6 +443,7 @@
431 copy->wm_class_name = g_strdup (self->wm_class_name);443 copy->wm_class_name = g_strdup (self->wm_class_name);
432 copy->wm_class_instance = g_strdup (self->wm_class_instance);444 copy->wm_class_instance = g_strdup (self->wm_class_instance);
433 copy->exec = g_strdup (self->exec);445 copy->exec = g_strdup (self->exec);
446 copy->process_name = g_strdup (self->process_name);
434 copy->application_id = g_strdup (self->application_id);447 copy->application_id = g_strdup (self->application_id);
435 copy->unique_bus_name = g_strdup (self->unique_bus_name);448 copy->unique_bus_name = g_strdup (self->unique_bus_name);
436 copy->dbus_menu_object_path = g_strdup (self->dbus_menu_object_path);449 copy->dbus_menu_object_path = g_strdup (self->dbus_menu_object_path);
@@ -459,5 +472,13 @@
459 self->wm_class_name = g_strdup (wmclass_name);472 self->wm_class_name = g_strdup (wmclass_name);
460 self->exec = g_strdup (exec);473 self->exec = g_strdup (exec);
461474
475 if (self->exec)
476 {
477 gchar **splitted_exec = g_strsplit (exec, " ", 2);
478 gchar *tmp = g_utf8_strrchr (splitted_exec[0], -1, G_DIR_SEPARATOR);
479 self->process_name = g_strdup (tmp ? tmp + 1 : splitted_exec[0]);
480 g_strfreev (splitted_exec);
481 }
482
462 return self;483 return self;
463}484}
464485
=== modified file 'src/bamf-legacy-window-test.h'
--- src/bamf-legacy-window-test.h 2012-10-10 17:36:21 +0000
+++ src/bamf-legacy-window-test.h 2013-01-29 18:22:23 +0000
@@ -57,6 +57,7 @@
57 char * wm_class_name;57 char * wm_class_name;
58 char * wm_class_instance;58 char * wm_class_instance;
59 char * exec;59 char * exec;
60 char * process_name;
60 char * application_id;61 char * application_id;
61 char * unique_bus_name;62 char * unique_bus_name;
62 char * dbus_menu_object_path;63 char * dbus_menu_object_path;
6364
=== modified file 'src/bamf-legacy-window.c'
--- src/bamf-legacy-window.c 2013-01-09 19:49:06 +0000
+++ src/bamf-legacy-window.c 2013-01-29 18:22:23 +0000
@@ -186,6 +186,51 @@
186}186}
187187
188char *188char *
189bamf_legacy_window_get_process_name (BamfLegacyWindow *self)
190{
191 gchar *stat_path;
192 gchar *contents;
193 gchar **lines;
194 gchar **sections;
195 gchar *result = NULL;
196 guint pid;
197
198 g_return_val_if_fail (BAMF_IS_LEGACY_WINDOW (self), NULL);
199
200 if (BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_process_name)
201 return BAMF_LEGACY_WINDOW_GET_CLASS (self)->get_process_name (self);
202
203 pid = bamf_legacy_window_get_pid (self);
204
205 if (pid <= 0)
206 return NULL;
207
208 stat_path = g_strdup_printf ("/proc/%i/status", pid);
209
210 if (g_file_get_contents (stat_path, &contents, NULL, NULL))
211 {
212 lines = g_strsplit (contents, "\n", 2);
213
214 if (lines && g_strv_length (lines) > 0)
215 {
216 sections = g_strsplit (lines[0], "\t", 0);
217 if (sections)
218 {
219 if (g_strv_length (sections) > 1)
220 result = g_strdup (sections[1]);
221
222 g_strfreev (sections);
223 }
224 g_strfreev (lines);
225 }
226 g_free (contents);
227 }
228 g_free (stat_path);
229
230 return result;
231}
232
233char *
189bamf_legacy_window_get_exec_string (BamfLegacyWindow *self)234bamf_legacy_window_get_exec_string (BamfLegacyWindow *self)
190{235{
191 gchar *result = NULL;236 gchar *result = NULL;
@@ -223,6 +268,8 @@
223 return result;268 return result;
224}269}
225270
271
272
226const char *273const char *
227bamf_legacy_window_save_mini_icon (BamfLegacyWindow *self)274bamf_legacy_window_save_mini_icon (BamfLegacyWindow *self)
228{275{
229276
=== modified file 'src/bamf-legacy-window.h'
--- src/bamf-legacy-window.h 2012-10-10 17:36:21 +0000
+++ src/bamf-legacy-window.h 2013-01-29 18:22:23 +0000
@@ -74,6 +74,7 @@
74 const char * (*get_class_name) (BamfLegacyWindow *legacy_window);74 const char * (*get_class_name) (BamfLegacyWindow *legacy_window);
75 const char * (*get_class_instance_name) (BamfLegacyWindow *legacy_window);75 const char * (*get_class_instance_name) (BamfLegacyWindow *legacy_window);
76 char * (*get_exec_string) (BamfLegacyWindow *legacy_window);76 char * (*get_exec_string) (BamfLegacyWindow *legacy_window);
77 char * (*get_process_name) (BamfLegacyWindow *legacy_window);
77 char * (*get_app_id) (BamfLegacyWindow *legacy_window);78 char * (*get_app_id) (BamfLegacyWindow *legacy_window);
78 char * (*get_unique_bus_name) (BamfLegacyWindow *legacy_window);79 char * (*get_unique_bus_name) (BamfLegacyWindow *legacy_window);
79 char * (*get_menu_object_path) (BamfLegacyWindow *legacy_window);80 char * (*get_menu_object_path) (BamfLegacyWindow *legacy_window);
@@ -142,6 +143,8 @@
142143
143char * bamf_legacy_window_get_exec_string (BamfLegacyWindow *self);144char * bamf_legacy_window_get_exec_string (BamfLegacyWindow *self);
144145
146char * bamf_legacy_window_get_process_name (BamfLegacyWindow *self);
147
145BamfLegacyWindow * bamf_legacy_window_get_transient (BamfLegacyWindow *self);148BamfLegacyWindow * bamf_legacy_window_get_transient (BamfLegacyWindow *self);
146149
147char * bamf_legacy_window_get_hint (BamfLegacyWindow *self,150char * bamf_legacy_window_get_hint (BamfLegacyWindow *self,
@@ -158,3 +161,4 @@
158BamfLegacyWindow * bamf_legacy_window_new (WnckWindow *legacy_window);161BamfLegacyWindow * bamf_legacy_window_new (WnckWindow *legacy_window);
159162
160#endif163#endif
164
161165
=== modified file 'src/bamf-matcher-private.h'
--- src/bamf-matcher-private.h 2013-01-09 19:48:18 +0000
+++ src/bamf-matcher-private.h 2013-01-29 18:22:23 +0000
@@ -47,5 +47,6 @@
47BamfApplication * bamf_matcher_get_application_by_desktop_file (BamfMatcher *self, const char *desktop_file);47BamfApplication * bamf_matcher_get_application_by_desktop_file (BamfMatcher *self, const char *desktop_file);
48BamfApplication * bamf_matcher_get_application_by_xid (BamfMatcher *self, guint xid);48BamfApplication * bamf_matcher_get_application_by_xid (BamfMatcher *self, guint xid);
49char * bamf_matcher_get_trimmed_exec (BamfMatcher *self, const char *exec);49char * bamf_matcher_get_trimmed_exec (BamfMatcher *self, const char *exec);
50gboolean bamf_matcher_is_valid_process_prefix (BamfMatcher *self, const char *exec);
5051
51#endif52#endif
5253
=== modified file 'src/bamf-matcher.c'
--- src/bamf-matcher.c 2013-01-09 22:37:21 +0000
+++ src/bamf-matcher.c 2013-01-29 18:22:23 +0000
@@ -54,7 +54,8 @@
54 "^gksu(do)?$", "^sudo$", "^su-to-root$", "^amdxdg-su$", "^java(ws)?$",54 "^gksu(do)?$", "^sudo$", "^su-to-root$", "^amdxdg-su$", "^java(ws)?$",
55 "^mono$", "^ruby$", "^padsp$", "^aoss$", "^python(\\d.\\d)?$", "^(ba)?sh$",55 "^mono$", "^ruby$", "^padsp$", "^aoss$", "^python(\\d.\\d)?$", "^(ba)?sh$",
56 "^perl$", "^env$", "^xdg-open$",56 "^perl$", "^env$", "^xdg-open$",
57 /* javaws strings: */ "^net\\.sourceforge\\.jnlp\\.runtime\\.Boot$", "^rt.jar$"57 /* javaws strings: */ "^net\\.sourceforge\\.jnlp\\.runtime\\.Boot$", "^rt\\.jar$",
58 "^com\\.sun\\.javaws\\.Main$", "^deploy\\.jar$"
58};59};
5960
60// Prefixes that must be considered starting point of exec strings61// Prefixes that must be considered starting point of exec strings
@@ -507,6 +508,30 @@
507 return (l ? (char *) l->data : NULL);508 return (l ? (char *) l->data : NULL);
508}509}
509510
511gboolean
512bamf_matcher_is_valid_process_prefix (BamfMatcher *self, const char *process_name)
513{
514 GRegex *regex;
515 gint i;
516
517 g_return_val_if_fail (BAMF_IS_MATCHER (self), TRUE);
518
519 if (!process_name || *process_name == '\0')
520 return FALSE;
521
522 for (i = 0; i < self->priv->bad_prefixes->len; ++i)
523 {
524 regex = g_array_index (self->priv->bad_prefixes, GRegex *, i);
525
526 if (g_regex_match (regex, process_name, 0, NULL))
527 {
528 return FALSE;
529 }
530 }
531
532 return TRUE;
533}
534
510/* Attempts to return the binary name for a particular execution string */535/* Attempts to return the binary name for a particular execution string */
511char *536char *
512bamf_matcher_get_trimmed_exec (BamfMatcher * self, const char * exec_string)537bamf_matcher_get_trimmed_exec (BamfMatcher * self, const char * exec_string)
@@ -562,16 +587,7 @@
562 if (good_prefix)587 if (good_prefix)
563 continue;588 continue;
564589
565 bad_prefix = FALSE;590 bad_prefix = !bamf_matcher_is_valid_process_prefix (self, part);
566 for (j = 0; j < self->priv->bad_prefixes->len; j++)
567 {
568 regex = g_array_index (self->priv->bad_prefixes, GRegex *, j);
569 if (g_regex_match (regex, part, 0, NULL))
570 {
571 bad_prefix = TRUE;
572 break;
573 }
574 }
575591
576 if (!bad_prefix)592 if (!bad_prefix)
577 {593 {
@@ -1502,7 +1518,7 @@
1502 }1518 }
1503 1519
1504 proc_name = process_name (pid);1520 proc_name = process_name (pid);
1505 if (proc_name)1521 if (bamf_matcher_is_valid_process_prefix (self, proc_name))
1506 {1522 {
1507 table_list = g_hash_table_lookup (priv->desktop_file_table, proc_name);1523 table_list = g_hash_table_lookup (priv->desktop_file_table, proc_name);
1508 1524
@@ -1510,15 +1526,15 @@
1510 {1526 {
1511 result = g_list_prepend (result, g_strdup (l->data)); 1527 result = g_list_prepend (result, g_strdup (l->data));
1512 }1528 }
1513 g_free (proc_name);
1514 }1529 }
1515 1530 g_free (proc_name);
1531
1516 result = g_list_reverse (result);1532 result = g_list_reverse (result);
1517 return result;1533 return result;
1518}1534}
15191535
1520static gboolean1536static gboolean
1521is_web_app_window (BamfMatcher *self, BamfLegacyWindow *window)1537is_web_app_window (BamfLegacyWindow *window)
1522{1538{
1523 const char *window_class = bamf_legacy_window_get_class_name (window);1539 const char *window_class = bamf_legacy_window_get_class_name (window);
1524 const char *instance_name = bamf_legacy_window_get_class_instance_name (window);1540 const char *instance_name = bamf_legacy_window_get_class_instance_name (window);
@@ -1553,12 +1569,26 @@
1553}1569}
15541570
1555static gboolean1571static gboolean
1572is_javaws_window (BamfLegacyWindow *window)
1573{
1574 const char *window_class = bamf_legacy_window_get_class_name (window);
1575
1576 if (g_strcmp0 (window_class, "net-sourceforge-jnlp-runtime-Boot") == 0 ||
1577 g_strcmp0 (window_class, "com-sun-javaws-Main") == 0)
1578 {
1579 return TRUE;
1580 }
1581
1582 return FALSE;
1583}
1584
1585static gboolean
1556bamf_matcher_window_skips_hint_set (BamfMatcher *self, BamfLegacyWindow *window)1586bamf_matcher_window_skips_hint_set (BamfMatcher *self, BamfLegacyWindow *window)
1557{1587{
1558 gboolean skip_hint_set = FALSE;1588 gboolean skip_hint_set;
1559 g_return_val_if_fail (BAMF_IS_MATCHER (self), TRUE);1589 g_return_val_if_fail (BAMF_IS_MATCHER (self), TRUE);
15601590
1561 skip_hint_set = is_web_app_window (self, window);1591 skip_hint_set = is_web_app_window (window) || is_javaws_window (window);
15621592
1563 return skip_hint_set;1593 return skip_hint_set;
1564}1594}
@@ -1640,7 +1670,7 @@
16401670
1641 if (!filter_by_wmclass)1671 if (!filter_by_wmclass)
1642 {1672 {
1643 if (is_web_app_window (self, window))1673 if (is_web_app_window (window))
1644 {1674 {
1645 // This ensures that a new application is created even for unknown webapps1675 // This ensures that a new application is created even for unknown webapps
1646 filter_by_wmclass = TRUE;1676 filter_by_wmclass = TRUE;
16471677
=== added file 'tests/bamfdaemon/data/icedtea-netx-javaws.desktop'
--- tests/bamfdaemon/data/icedtea-netx-javaws.desktop 1970-01-01 00:00:00 +0000
+++ tests/bamfdaemon/data/icedtea-netx-javaws.desktop 2013-01-29 18:22:23 +0000
@@ -0,0 +1,12 @@
1[Desktop Entry]
2Name=IcedTea Java Web Start
3Name[fi]=IcedTea Java - Web Start
4Comment=IcedTea Java Web Start
5Comment[fi]=IcedTea Java - Web Start
6Exec=/usr/bin/javaws %u
7Terminal=false
8Type=Application
9Icon=javaws
10Categories=Application;Network;
11MimeType=application/x-java-jnlp-file;
12NoDisplay=true
013
=== modified file 'tests/bamfdaemon/test-matcher.c'
--- tests/bamfdaemon/test-matcher.c 2013-01-09 22:37:58 +0000
+++ tests/bamfdaemon/test-matcher.c 2013-01-29 18:22:23 +0000
@@ -34,6 +34,8 @@
34static void test_match_libreoffice_windows (void);34static void test_match_libreoffice_windows (void);
35static void test_match_gnome_control_center_panels (void);35static void test_match_gnome_control_center_panels (void);
36static void test_match_javaws_windows (void);36static void test_match_javaws_windows (void);
37static void test_match_javaws_windows_hint_ignored (void);
38static void test_match_javaws_windows_no_desktop_match (void);
37static void test_new_desktop_matches_unmatched_windows (void);39static void test_new_desktop_matches_unmatched_windows (void);
38static void test_trim_exec_string (void);40static void test_trim_exec_string (void);
3941
@@ -56,6 +58,8 @@
56 g_test_add_func (DOMAIN"/Matching/Application/LibreOffice", test_match_libreoffice_windows);58 g_test_add_func (DOMAIN"/Matching/Application/LibreOffice", test_match_libreoffice_windows);
57 g_test_add_func (DOMAIN"/Matching/Application/GnomeControlCenter", test_match_gnome_control_center_panels);59 g_test_add_func (DOMAIN"/Matching/Application/GnomeControlCenter", test_match_gnome_control_center_panels);
58 g_test_add_func (DOMAIN"/Matching/Application/JavaWebStart", test_match_javaws_windows);60 g_test_add_func (DOMAIN"/Matching/Application/JavaWebStart", test_match_javaws_windows);
61 g_test_add_func (DOMAIN"/Matching/Application/JavaWebStart/HintIngored", test_match_javaws_windows_hint_ignored);
62 g_test_add_func (DOMAIN"/Matching/Application/JavaWebStart/NoDesktopMatch", test_match_javaws_windows_no_desktop_match);
59 g_test_add_func (DOMAIN"/Matching/Windows/UnmatchedOnNewDesktop", test_new_desktop_matches_unmatched_windows);63 g_test_add_func (DOMAIN"/Matching/Windows/UnmatchedOnNewDesktop", test_new_desktop_matches_unmatched_windows);
60 g_test_add_func (DOMAIN"/ExecStringTrimming", test_trim_exec_string);64 g_test_add_func (DOMAIN"/ExecStringTrimming", test_trim_exec_string);
61}65}
@@ -569,7 +573,7 @@
569573
570 screen = bamf_legacy_screen_get_default ();574 screen = bamf_legacy_screen_get_default ();
571 matcher = bamf_matcher_get_default ();575 matcher = bamf_matcher_get_default ();
572 const char *exec_prefix = "/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/java " \576 const char *exec_prefix = "/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/javaws " \
573 "-Xbootclasspath/a:/usr/share/icedtea-web/netx.jar " \577 "-Xbootclasspath/a:/usr/share/icedtea-web/netx.jar " \
574 "-Xms8m -Djava.security.manager " \578 "-Xms8m -Djava.security.manager " \
575 "-Djava.security.policy=/etc/icedtea-web/javaws.policy " \579 "-Djava.security.policy=/etc/icedtea-web/javaws.policy " \
@@ -577,8 +581,8 @@
577 "-Dicedtea-web.bin.name=javaws " \581 "-Dicedtea-web.bin.name=javaws " \
578 "-Dicedtea-web.bin.location=/usr/bin/javaws "\582 "-Dicedtea-web.bin.location=/usr/bin/javaws "\
579 "net.sourceforge.jnlp.runtime.Boot";583 "net.sourceforge.jnlp.runtime.Boot";
580 const char *class_name = "sun-awt-X11-XFramePeer";584 const char *class_name = "net-sourceforge-jnlp-runtime-Boot";
581 const char *class_instance = "net-sourceforge-jnlp-runtime-Boot";585 const char *class_instance = "sun-awt-X11-XFramePeer";
582586
583 cleanup_matcher_tables (matcher);587 cleanup_matcher_tables (matcher);
584 export_matcher_on_bus (matcher);588 export_matcher_on_bus (matcher);
@@ -626,6 +630,93 @@
626}630}
627631
628static void632static void
633test_match_javaws_windows_hint_ignored (void)
634{
635 BamfMatcher *matcher;
636 BamfLegacyScreen *screen;
637 BamfLegacyWindowTest *test_win;
638 BamfApplication *app;
639
640 screen = bamf_legacy_screen_get_default ();
641 matcher = bamf_matcher_get_default ();
642 const char *exec_prefix = "/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/javaws " \
643 "-Xbootclasspath/a:/usr/share/icedtea-web/netx.jar " \
644 "-Xms8m -Djava.security.manager " \
645 "-Djava.security.policy=/etc/icedtea-web/javaws.policy " \
646 "-classpath /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/rt.jar " \
647 "-Dicedtea-web.bin.name=javaws " \
648 "-Dicedtea-web.bin.location=/usr/bin/javaws "\
649 "net.sourceforge.jnlp.runtime.Boot ";
650 const char *class_name = "net-sourceforge-jnlp-runtime-Boot";
651 const char *class_instance = "sun-awt-X11-XFramePeer";
652
653 cleanup_matcher_tables (matcher);
654 export_matcher_on_bus (matcher);
655
656 guint xid = g_random_int ();
657 guint pid = g_random_int ();
658 char *exec = g_strconcat (exec_prefix, "Notepad.jnlp", NULL);
659 test_win = bamf_legacy_window_test_new (xid, "Notepad", NULL, exec);
660 bamf_legacy_window_test_set_wmclass (test_win, class_name, class_instance);
661 test_win->pid = pid;
662 _bamf_legacy_screen_open_test_window (screen, test_win);
663 g_free (exec);
664
665 bamf_matcher_register_desktop_file_for_pid (matcher, DATA_DIR"/icedtea-netx-javaws.desktop", pid);
666
667 char *hint = bamf_legacy_window_get_hint (BAMF_LEGACY_WINDOW (test_win), _NET_WM_DESKTOP_FILE);
668 g_assert (hint == NULL);
669
670 app = bamf_matcher_get_application_by_xid (matcher, xid);
671 g_assert (BAMF_IS_APPLICATION (app));
672 g_assert (bamf_application_get_desktop_file (app) == NULL);
673
674 g_object_unref (matcher);
675 g_object_unref (screen);
676}
677
678static void
679test_match_javaws_windows_no_desktop_match (void)
680{
681 BamfMatcher *matcher;
682 BamfLegacyScreen *screen;
683 BamfLegacyWindowTest *test_win;
684 BamfApplication *app;
685
686 screen = bamf_legacy_screen_get_default ();
687 matcher = bamf_matcher_get_default ();
688 const char *exec_prefix = "/usr/lib/jvm/java-6-openjdk-amd64/jre/bin/javaws " \
689 "-Xbootclasspath/a:/usr/share/icedtea-web/netx.jar " \
690 "-Xms8m -Djava.security.manager " \
691 "-Djava.security.policy=/etc/icedtea-web/javaws.policy " \
692 "-classpath /usr/lib/jvm/java-6-openjdk-amd64/jre/lib/rt.jar " \
693 "-Dicedtea-web.bin.name=javaws " \
694 "-Dicedtea-web.bin.location=/usr/bin/javaws "\
695 "net.sourceforge.jnlp.runtime.Boot ";
696 const char *class_name = "net-sourceforge-jnlp-runtime-Boot";
697 const char *class_instance = "sun-awt-X11-XFramePeer";
698
699 cleanup_matcher_tables (matcher);
700 export_matcher_on_bus (matcher);
701
702 bamf_matcher_load_desktop_file (matcher, DATA_DIR"/icedtea-netx-javaws.desktop");
703
704 guint xid = g_random_int ();
705 char *exec = g_strconcat (exec_prefix, "Notepad.jnlp", NULL);
706 test_win = bamf_legacy_window_test_new (xid, "Notepad", NULL, exec);
707 bamf_legacy_window_test_set_wmclass (test_win, class_name, class_instance);
708 _bamf_legacy_screen_open_test_window (screen, test_win);
709 g_free (exec);
710
711 app = bamf_matcher_get_application_by_xid (matcher, xid);
712 g_assert (BAMF_IS_APPLICATION (app));
713 g_assert (bamf_application_get_desktop_file (app) == NULL);
714
715 g_object_unref (matcher);
716 g_object_unref (screen);
717}
718
719static void
629test_trim_exec_string (void)720test_trim_exec_string (void)
630{721{
631 BamfMatcher *matcher;722 BamfMatcher *matcher;
@@ -692,5 +783,18 @@
692 g_assert_cmpstr (trimmed, ==, "notepad.jnlp");783 g_assert_cmpstr (trimmed, ==, "notepad.jnlp");
693 g_free (trimmed);784 g_free (trimmed);
694785
786 exec = "/usr/lib/jvm/java-7-oracle/jre/bin/java " \
787 "-classpath /usr/lib/jvm/java-7-oracle/jre/lib/deploy.jar " \
788 "-Djava.security.policy=file:/usr/lib/jvm/java-7-oracle/jre/lib/security/javaws.policy " \
789 "-DtrustProxy=true -Xverify:remote " \
790 "-Djnlpx.home=/usr/lib/jvm/java-7-oracle/jre/bin " \
791 "-Djnlpx.remove=true -Dsun.awt.warmup=true " \
792 "-Xbootclasspath/a:/usr/lib/jvm/java-7-oracle/jre/lib/javaws.jar:/usr/lib/jvm/java-7-oracle/jre/lib/deploy.jar:/usr/lib/jvm/java-7-oracle/jre/lib/plugin.jar " \
793 "-Xms12m -Xmx384m -Djnlpx.jvm=/usr/lib/jvm/java-7-oracle/jre/bin/java " \
794 "com.sun.javaws.Main Notepad.jnlp";
795 trimmed = bamf_matcher_get_trimmed_exec (matcher, exec);
796 g_assert_cmpstr (trimmed, ==, "notepad.jnlp");
797 g_free (trimmed);
798
695 g_object_unref (matcher);799 g_object_unref (matcher);
696}800}

Subscribers

People subscribed via source and target branches