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

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Brandon Schaefer
Approved revision: 506
Merged at revision: 498
Proposed branch: lp:~3v1n0/bamf/javaws-ignore-desktop-0.3
Merge into: lp:bamf/0.3
Diff against target: 477 lines (+243/-22)
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 (+50/-19)
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.3
Reviewer Review Type Date Requested Status
Brandon Schaefer (community) Approve
Review via email: mp+145294@code.launchpad.net

Commit message

BamfMatcher: ignore the javaws windows when setting the window hint

Description of the change

Backport to Bamf-0.3 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.
500. By Marco Trevisan (Treviño)

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

501. By Marco Trevisan (Treviño)

TestMatcher: fix javawm class names

502. By Marco Trevisan (Treviño)

BamfLegacyWindow: add a function to fetch the process name

503. By Marco Trevisan (Treviño)

BamfLegacyWindowTest: implement the get_process_name function

504. By Marco Trevisan (Treviño)

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.

505. By Marco Trevisan (Treviño)

TestMatcher: added one more test to ensure javaws matching

506. By Marco Trevisan (Treviño)

BamfMatcher: fix compilation issues

Revision history for this message
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:18:56 +0000
+++ src/bamf-legacy-window-test.c 2013-01-29 17:52:22 +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:18:56 +0000
+++ src/bamf-legacy-window-test.h 2013-01-29 17:52:22 +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-10 00:23:28 +0000
+++ src/bamf-legacy-window.c 2013-01-29 17:52:22 +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-09 09:13:30 +0000
+++ src/bamf-legacy-window.h 2013-01-29 17:52:22 +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-10 00:23:28 +0000
+++ src/bamf-matcher-private.h 2013-01-29 17:52:22 +0000
@@ -50,5 +50,6 @@
50BamfApplication * bamf_matcher_get_application_by_desktop_file (BamfMatcher *self, const char *desktop_file);50BamfApplication * bamf_matcher_get_application_by_desktop_file (BamfMatcher *self, const char *desktop_file);
51BamfApplication * bamf_matcher_get_application_by_xid (BamfMatcher *self, guint xid);51BamfApplication * bamf_matcher_get_application_by_xid (BamfMatcher *self, guint xid);
52char * bamf_matcher_get_trimmed_exec (BamfMatcher *self, const char *exec);52char * bamf_matcher_get_trimmed_exec (BamfMatcher *self, const char *exec);
53gboolean bamf_matcher_is_valid_process_prefix (BamfMatcher *self, const char *exec);
5354
54#endif55#endif
5556
=== modified file 'src/bamf-matcher.c'
--- src/bamf-matcher.c 2013-01-10 00:23:28 +0000
+++ src/bamf-matcher.c 2013-01-29 17:52:22 +0000
@@ -58,7 +58,8 @@
58 "^gksu(do)?$", "^sudo$", "^su-to-root$", "^amdxdg-su$", "^java(ws)?$",58 "^gksu(do)?$", "^sudo$", "^su-to-root$", "^amdxdg-su$", "^java(ws)?$",
59 "^mono$", "^ruby$", "^padsp$", "^aoss$", "^python(\\d.\\d)?$", "^(ba)?sh$",59 "^mono$", "^ruby$", "^padsp$", "^aoss$", "^python(\\d.\\d)?$", "^(ba)?sh$",
60 "^perl$", "^env$", "^xdg-open$",60 "^perl$", "^env$", "^xdg-open$",
61 /* javaws strings: */ "^net\\.sourceforge\\.jnlp\\.runtime\\.Boot$", "^rt.jar$"61 /* javaws strings: */ "^net\\.sourceforge\\.jnlp\\.runtime\\.Boot$", "^rt\\.jar$",
62 "^com\\.sun\\.javaws\\.Main$", "^deploy\\.jar$"
62};63};
6364
64// Prefixes that must be considered starting point of exec strings65// Prefixes that must be considered starting point of exec strings
@@ -511,6 +512,30 @@
511 return (l ? (char *) l->data : NULL);512 return (l ? (char *) l->data : NULL);
512}513}
513514
515gboolean
516bamf_matcher_is_valid_process_prefix (BamfMatcher *self, const char *process_name)
517{
518 GRegex *regex;
519 gint i;
520
521 g_return_val_if_fail (BAMF_IS_MATCHER (self), TRUE);
522
523 if (!process_name || *process_name == '\0')
524 return FALSE;
525
526 for (i = 0; i < self->priv->bad_prefixes->len; ++i)
527 {
528 regex = g_array_index (self->priv->bad_prefixes, GRegex *, i);
529
530 if (g_regex_match (regex, process_name, 0, NULL))
531 {
532 return FALSE;
533 }
534 }
535
536 return TRUE;
537}
538
514/* Attempts to return the binary name for a particular execution string */539/* Attempts to return the binary name for a particular execution string */
515char *540char *
516bamf_matcher_get_trimmed_exec (BamfMatcher * self, const char * exec_string)541bamf_matcher_get_trimmed_exec (BamfMatcher * self, const char * exec_string)
@@ -566,16 +591,7 @@
566 if (good_prefix)591 if (good_prefix)
567 continue;592 continue;
568593
569 bad_prefix = FALSE;594 bad_prefix = !bamf_matcher_is_valid_process_prefix (self, part);
570 for (j = 0; j < self->priv->bad_prefixes->len; j++)
571 {
572 regex = g_array_index (self->priv->bad_prefixes, GRegex *, j);
573 if (g_regex_match (regex, part, 0, NULL))
574 {
575 bad_prefix = TRUE;
576 break;
577 }
578 }
579595
580 if (!bad_prefix)596 if (!bad_prefix)
581 {597 {
@@ -1504,9 +1520,10 @@
1504 result = g_list_reverse (result);1520 result = g_list_reverse (result);
1505 return result;1521 return result;
1506 }1522 }
1507 1523
1508 proc_name = process_name (pid);1524 proc_name = process_name (pid);
1509 if (proc_name)1525
1526 if (bamf_matcher_is_valid_process_prefix (self, proc_name))
1510 {1527 {
1511 table_list = g_hash_table_lookup (priv->desktop_file_table, proc_name);1528 table_list = g_hash_table_lookup (priv->desktop_file_table, proc_name);
1512 1529
@@ -1514,15 +1531,15 @@
1514 {1531 {
1515 result = g_list_prepend (result, g_strdup (l->data)); 1532 result = g_list_prepend (result, g_strdup (l->data));
1516 }1533 }
1517 g_free (proc_name);
1518 }1534 }
1519 1535 g_free (proc_name);
1536
1520 result = g_list_reverse (result);1537 result = g_list_reverse (result);
1521 return result;1538 return result;
1522}1539}
15231540
1524static gboolean1541static gboolean
1525is_web_app_window (BamfMatcher *self, BamfLegacyWindow *window)1542is_web_app_window (BamfLegacyWindow *window)
1526{1543{
1527 const char *window_class = bamf_legacy_window_get_class_name (window);1544 const char *window_class = bamf_legacy_window_get_class_name (window);
1528 const char *instance_name = bamf_legacy_window_get_class_instance_name (window);1545 const char *instance_name = bamf_legacy_window_get_class_instance_name (window);
@@ -1557,12 +1574,26 @@
1557}1574}
15581575
1559static gboolean1576static gboolean
1577is_javaws_window (BamfLegacyWindow *window)
1578{
1579 const char *window_class = bamf_legacy_window_get_class_name (window);
1580
1581 if (g_strcmp0 (window_class, "net-sourceforge-jnlp-runtime-Boot") == 0 ||
1582 g_strcmp0 (window_class, "com-sun-javaws-Main") == 0)
1583 {
1584 return TRUE;
1585 }
1586
1587 return FALSE;
1588}
1589
1590static gboolean
1560bamf_matcher_window_skips_hint_set (BamfMatcher *self, BamfLegacyWindow *window)1591bamf_matcher_window_skips_hint_set (BamfMatcher *self, BamfLegacyWindow *window)
1561{1592{
1562 gboolean skip_hint_set = FALSE;1593 gboolean skip_hint_set;
1563 g_return_val_if_fail (BAMF_IS_MATCHER (self), TRUE);1594 g_return_val_if_fail (BAMF_IS_MATCHER (self), TRUE);
15641595
1565 skip_hint_set = is_web_app_window (self, window);1596 skip_hint_set = is_web_app_window (window) || is_javaws_window (window);
15661597
1567 return skip_hint_set;1598 return skip_hint_set;
1568}1599}
@@ -1644,7 +1675,7 @@
16441675
1645 if (!filter_by_wmclass)1676 if (!filter_by_wmclass)
1646 {1677 {
1647 if (is_web_app_window (self, window))1678 if (is_web_app_window (window))
1648 {1679 {
1649 // This ensures that a new application is created even for unknown webapps1680 // This ensures that a new application is created even for unknown webapps
1650 filter_by_wmclass = TRUE;1681 filter_by_wmclass = TRUE;
16511682
=== 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 17:52:22 +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-10 00:23:28 +0000
+++ tests/bamfdaemon/test-matcher.c 2013-01-29 17:52:22 +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