16
16
from softwarecenter.ui.gtk3.panes.availablepane import get_test_window
17
17
from softwarecenter.backend.unitylauncher import UnityLauncherInfo
19
# Tests for Ubuntu Software Center's integration with the Unity launcher,
20
# see https://wiki.ubuntu.com/SoftwareCenter#Learning%20how%20to%20launch%20an%20application
19
22
# we can only have one instance of availablepane, so create it here
20
23
win = get_test_window()
21
24
available_pane = win.get_data("pane")
23
# see https://wiki.ubuntu.com/SoftwareCenter#Learning%20how%20to%20launch%20an%20application
25
26
class TestUnityLauncherIntegration(unittest.TestCase):
29
# monkey patch is_unity_running
30
softwarecenter.utils.is_unity_running = lambda: True
28
33
for i in range(10):
33
38
while Gtk.events_pending():
34
39
Gtk.main_iteration()
37
# monkey patch is_unity_running
38
softwarecenter.utils.is_unity_running = lambda: True
41
def _install_from_list_view(self, pkgname):
42
from softwarecenter.ui.gtk3.panes.availablepane import AvailablePane
43
available_pane.notebook.set_current_page(AvailablePane.Pages.LIST)
46
available_pane.on_search_terms_changed(None, "ark,artha,software-center")
49
# select the first item in the list
50
available_pane.app_view.tree_view.set_cursor(Gtk.TreePath(0),
52
# ok to just use the test app here
53
app = Application("", pkgname)
56
# pretend we started an install
57
available_pane.backend.emit("transaction-started",
58
app.pkgname, app.appname,
60
TransactionTypes.INSTALL)
40
64
def _navigate_to_appdetails_and_install(self, pkgname):
41
65
app = Application("", pkgname)
59
83
self.expected_launcher_info.icon_name)
60
84
self.assertTrue(launcher_info.icon_x > 5)
61
85
self.assertTrue(launcher_info.icon_y > 5)
62
self.assertEqual(launcher_info.icon_size, 96)
86
# check that the icon size is one of either 32 pixels (for the
87
# list view case) or 96 pixels (for the details view case)
88
self.assertTrue(launcher_info.icon_size == 32 or
89
launcher_info.icon_size == 96)
63
90
self.assertEqual(launcher_info.app_install_desktop_file_path,
64
91
self.expected_launcher_info.app_install_desktop_file_path)
65
92
self.assertEqual(launcher_info.trans_id,
66
93
self.expected_launcher_info.trans_id)
95
def test_unity_launcher_integration_list_view(self):
96
# test the automatic add to launcher enabled functionality when
97
# installing an app form the list view
98
available_pane.add_to_launcher_enabled = True
99
test_pkgname = "lincity-ng"
101
# for testing, we substitute a fake version of UnityLauncher's
102
# send_application_to_launcher method that lets us check for the
103
# correct values and also avoids firing the actual dbus signal
104
# to the unity launcher service
105
self.expected_pkgname = test_pkgname
106
self.expected_launcher_info = UnityLauncherInfo("lincity-ng",
108
0, 0, 0, 0, # these values are set in availablepane
109
"/usr/share/app-install/desktop/lincity-ng:lincity-ng.desktop",
111
available_pane.unity_launcher.send_application_to_launcher = (
112
self._fake_send_application_to_launcher_and_check)
113
self._install_from_list_view(test_pkgname)
68
def test_unity_launcher_integration(self):
69
# test the automatic add to launcher enabled functionality
115
def test_unity_launcher_integration_details_view(self):
116
# test the automatic add to launcher enabled functionality when
117
# installing an app from the details view
70
118
available_pane.add_to_launcher_enabled = True
71
119
test_pkgname = "lincity-ng"