~ubuntuone-control-tower/software-center/trunk

« back to all changes in this revision

Viewing changes to test/gtk3/test_unity_launcher_integration.py

  • Committer: Michael Vogt
  • Date: 2012-02-02 08:37:01 UTC
  • mfrom: (2566.1.35 software-center)
  • Revision ID: michael.vogt@ubuntu.com-20120202083701-d5h3uww1fkznvtgt
merged lp:~gary-lasker/software-center/launcher-integration-lp761851, many thanks!

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
import time
5
5
import unittest
6
6
 
7
 
from mock import Mock
8
 
 
9
7
from testutils import setup_test_env
10
8
setup_test_env()
11
9
 
16
14
from softwarecenter.utils import convert_desktop_file_to_installed_location
17
15
from softwarecenter.db.application import Application
18
16
from softwarecenter.ui.gtk3.panes.availablepane import get_test_window
 
17
from softwarecenter.backend.unitylauncher import UnityLauncherInfo
19
18
 
20
19
# we can only have one instance of availablepane, so create it here
21
20
win = get_test_window()
51
50
                                    TransactionTypes.INSTALL)
52
51
        # wait a wee bit
53
52
        self._zzz()
54
 
 
55
 
    def test_unity_launcher_integration(self):
56
 
        # test the automatic add to launcher enabled functionality
57
 
        available_pane.add_to_launcher_enabled = True
58
 
        test_pkgname = "lincity-ng"
59
 
        mock_result = Mock()
60
 
        mock_result.pkgname = test_pkgname
61
 
        mock_result.success = True
62
 
        # now pretend
63
 
        self._navigate_to_appdetails_and_install(test_pkgname)
64
53
        
65
 
        # check that a correct UnityLauncherInfo object has been created and
66
 
        # added to the queue
67
 
        self.assertTrue(test_pkgname in available_pane.unity_launcher.launcher_queue)
68
 
        launcher_info = available_pane.unity_launcher.remove_from_launcher_queue(test_pkgname)
69
 
        # check the UnityLauncherInfo values themselves
70
 
        self.assertEqual(launcher_info.name, "lincity-ng")
71
 
        self.assertEqual(launcher_info.icon_name, "lincity-ng")
 
54
    def _fake_send_application_to_launcher_and_check(self,
 
55
                                                     pkgname, launcher_info):
 
56
        self.assertEqual(pkgname, self.expected_pkgname)
 
57
        self.assertEqual(launcher_info.name, self.expected_launcher_info.name)
 
58
        self.assertEqual(launcher_info.icon_name,
 
59
                         self.expected_launcher_info.icon_name)
72
60
        self.assertTrue(launcher_info.icon_x > 5)
73
61
        self.assertTrue(launcher_info.icon_y > 5)
74
62
        self.assertEqual(launcher_info.icon_size, 96)
75
63
        self.assertEqual(launcher_info.app_install_desktop_file_path,
76
 
            "/usr/share/app-install/desktop/lincity-ng:lincity-ng.desktop")
77
 
        self.assertEqual(launcher_info.trans_id, "testid101")
78
 
        # finally, make sure the the app has been removed from the launcher
79
 
        # queue        
80
 
        self.assertFalse(test_pkgname in available_pane.unity_launcher.launcher_queue)
 
64
                self.expected_launcher_info.app_install_desktop_file_path)
 
65
        self.assertEqual(launcher_info.trans_id,
 
66
                self.expected_launcher_info.trans_id)
 
67
 
 
68
    def test_unity_launcher_integration(self):
 
69
        # test the automatic add to launcher enabled functionality
 
70
        available_pane.add_to_launcher_enabled = True
 
71
        test_pkgname = "lincity-ng"
 
72
        # now pretend
 
73
        # for testing, we substitute a fake version of UnityLauncher's
 
74
        # send_application_to_launcher method that lets us check for the
 
75
        # correct values and also avoids firing the actual dbus signal
 
76
        # to the unity launcher service
 
77
        self.expected_pkgname = test_pkgname
 
78
        self.expected_launcher_info = UnityLauncherInfo("lincity-ng",
 
79
                 "lincity-ng",
 
80
                 0, 0, 0, 0, # these values are set in availablepane
 
81
                 "/usr/share/app-install/desktop/lincity-ng:lincity-ng.desktop",
 
82
                 "testid101")
 
83
        available_pane.unity_launcher.send_application_to_launcher = (
 
84
                self._fake_send_application_to_launcher_and_check)
 
85
        self._navigate_to_appdetails_and_install(test_pkgname)
81
86
        
82
87
    def test_unity_launcher_integration_disabled(self):
83
88
        # test the case where automatic add to launcher is disabled
84
89
        available_pane.add_to_launcher_enabled = False
85
90
        test_pkgname = "lincity-ng"
86
 
        mock_result = Mock()
87
 
        mock_result.pkgname = test_pkgname
88
 
        mock_result.success = True
89
91
        # now pretend
 
92
        # for testing, we substitute a fake version of UnityLauncher's
 
93
        # send_application_to_launcher method that lets us check for the
 
94
        # correct values and also avoids firing the actual dbus signal
 
95
        # to the unity launcher service
 
96
        # in the disabled add to launcher case, we just want to insure
 
97
        # that we never call send_application_to_launcher, so we can just
 
98
        # plug in bogus values and we will catch a call if it occurs
 
99
        self.expected_pkgname = ""
 
100
        self.expected_launcher_info = UnityLauncherInfo("", "",
 
101
                 0, 0, 0, 0, "", "")
 
102
        available_pane.unity_launcher.send_application_to_launcher = (
 
103
                self._fake_send_application_to_launcher_and_check)
90
104
        self._navigate_to_appdetails_and_install(test_pkgname)
91
 
        
92
 
        # check that no corresponding unity_launcher info object has been added
93
 
        # to the queue
94
 
        self.assertFalse(test_pkgname in available_pane.unity_launcher.launcher_queue)
95
105
 
96
106
    def test_desktop_file_path_conversion(self):
97
107
        # test 'normal' case