File: tests-Exercise-all-methods-defined-by-GDesktopAppInfo.patch

package info (click to toggle)
pygobject 3.50.0-8
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 4,592 kB
  • sloc: python: 22,999; ansic: 22,948; sh: 468; makefile: 74; xml: 35
file content (123 lines) | stat: -rw-r--r-- 4,778 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
From: Simon McVittie <smcv@debian.org>
Date: Wed, 8 Oct 2025 11:03:17 +0100
Subject: tests: Exercise all methods defined by GDesktopAppInfo

This is the most commonly-used object in GioUnix so it seems worthwhile
to test it more fully, especially if we need to add overrides for it.

Helps: https://gitlab.gnome.org/GNOME/pygobject/-/issues/719
Signed-off-by: Simon McVittie <smcv@debian.org>
Forwarded: https://gitlab.gnome.org/GNOME/pygobject/-/merge_requests/456
---
 tests/test_gio.py | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 84 insertions(+), 1 deletion(-)

diff --git a/tests/test_gio.py b/tests/test_gio.py
index 463fa4c..005d188 100644
--- a/tests/test_gio.py
+++ b/tests/test_gio.py
@@ -64,7 +64,20 @@ class TestGioPlatform(unittest.TestCase):
 Version=1.0
 Type=Application
 Name=Some Application
-Exec={GLib.find_program_in_path("sh")}
+Exec={GLib.find_program_in_path("true")} %u
+Actions=act;
+Categories=Development;Profiling;
+GenericName=Test
+Hidden=true
+Keywords=test;example;
+NoDisplay=true
+OnlyShowIn=GNOME;
+StartupWMClass=testTest
+X-Bool=true
+
+[Desktop Action act]
+Name=Take action!
+Exec={GLib.find_program_in_path("true")} action
 """
 
     def setUp(self):
@@ -89,12 +102,82 @@ Exec={GLib.find_program_in_path("sh")}
                 GLib.KeyFileFlags.NONE,
             )
 
+    def assert_expected_desktop_app_info(self, app_info):
+        # All functionality is available as ordinary methods, without
+        # needing extraneous arguments
+        # https://gitlab.gnome.org/GNOME/pygobject/-/issues/719
+        self.assertEqual(app_info.get_action_name("act"), "Take action!")
+        self.assertEqual(app_info.get_boolean("X-Bool"), True)
+        self.assertEqual(app_info.get_categories(), "Development;Profiling;")
+        self.assertIsNone(app_info.get_filename())
+        self.assertEqual(app_info.get_generic_name(), "Test")
+        self.assertEqual(app_info.get_is_hidden(), True)
+        self.assertEqual(app_info.get_keywords(), ["test", "example"])
+        self.assertEqual(app_info.get_locale_string("Keywords"), "test;example;")
+        self.assertEqual(app_info.get_nodisplay(), True)
+        self.assertEqual(app_info.get_show_in("GNOME"), True)
+        self.assertEqual(app_info.get_show_in("KDE"), False)
+        # get_show_in() can be called without an argument, which means NULL
+        self.assertIn(app_info.get_show_in(), [True, False])
+        self.assertIn(app_info.get_show_in(None), [True, False])
+        self.assertEqual(app_info.get_startup_wm_class(), "testTest")
+        self.assertEqual(app_info.get_string("StartupWMClass"), "testTest")
+        self.assertEqual(app_info.get_string_list("Keywords"), ["test", "example"])
+        self.assertEqual(app_info.has_key("Keywords"), True)
+        self.assertEqual(app_info.list_actions(), ["act"])
+
+        # All functionality is also available via unbound methods:
+        # for example Cinnamon relies on this as of October 2025
+        self.assertEqual(
+            GioUnix.DesktopAppInfo.get_action_name(app_info, "act"), "Take action!"
+        )
+        self.assertEqual(
+            Gio.DesktopAppInfo.get_action_name(app_info, "act"), "Take action!"
+        )
+
+        # Exercise methods that actually launch something
+        app_info.launch_action("act")
+        app_info.launch_action("act", None)
+        self.assertTrue(
+            app_info.launch_uris_as_manager(
+                ["about:blank"],
+                None,
+                GLib.SpawnFlags.DEFAULT,
+                None,
+                None,
+                None,
+                None,
+            ),
+        )
+        self.assertTrue(
+            app_info.launch_uris_as_manager(
+                ["about:blank"],
+                None,
+                GLib.SpawnFlags.DEFAULT,
+            ),
+        )
+        self.assertTrue(
+            app_info.launch_uris_as_manager_with_fds(
+                ["about:blank"],
+                None,
+                GLib.SpawnFlags.DEFAULT,
+                None,
+                None,
+                None,
+                None,
+                -1,
+                -1,
+                -1,
+            ),
+        )
+
     @unittest.skipIf(GioUnix is None, "Not supported")
     def test_desktop_app_info_can_be_created_from_gio_unix(self):
         app_info = GioUnix.DesktopAppInfo.new_from_keyfile(self.key_file)
         self.assertIsNotNone(app_info)
         self.assertIsInstance(app_info, GioUnix.DesktopAppInfo)
         self.assertIsInstance(app_info, Gio.AppInfo)
+        self.assert_expected_desktop_app_info(app_info)
 
     @unittest.skipIf(GioUnix is None, "Not supported")
     def test_desktop_app_info_can_be_created_from_gio(self):