~ralsina/ubuntuone-windows-installer/no-icon-without-arguments

« back to all changes in this revision

Viewing changes to ubuntuone_installer/gui/qt/utils/tests/test_windows.py

  • Committer: Tarmac
  • Author(s): Natalia B. Bidart, ralsina
  • Date: 2011-09-15 22:02:03 UTC
  • mfrom: (64.2.5 start-right)
  • Revision ID: tarmac-20110915220203-8m90rveaj4dylhcz
- Start the control panel using the --with-icon switch (LP: #851221).

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
import sys
22
22
import os
 
23
import subprocess
23
24
 
24
25
# Avoid pylint error on Linux
25
26
# pylint: disable=F0401
31
32
 
32
33
 
33
34
class UninstallerTestCase(BaseTestCase):
 
35
 
34
36
    """Test the uninstaller."""
35
37
 
36
38
    def test_execute_uninstall_on_licence_cancel_file_not_exists(self):
86
88
        self.assertEqual(0, self._called[0][5])
87
89
 
88
90
 
 
91
class StartControlPanelTestCase(BaseTestCase):
 
92
 
 
93
    """Test the start of the control panel."""
 
94
 
 
95
    def test_start_control_panel(self):
 
96
        """The proper process is started."""
 
97
        self.patch(subprocess, "Popen", self._set_called)
 
98
 
 
99
        utils.start_control_panel()
 
100
 
 
101
        expected = ((['ubuntuone-control-panel-qt', '--with-icon'],), {})
 
102
        self.assertEqual(self._called, expected)
 
103
 
 
104
    def test_start_control_panel_frozen(self):
 
105
        """When frozen, the control-panel has a path."""
 
106
        # I can't patch sys because frozen is not there by default
 
107
        sys.frozen = True
 
108
        self.addCleanup(delattr, sys, 'frozen')
 
109
 
 
110
        root = 'Z:\\Yadda\\Yoo'
 
111
        self.patch(os.path, 'abspath', lambda p: os.path.join(root, p))
 
112
        self.patch(os.path, 'dirname', lambda p: p)
 
113
        exe = 'foo\\bar\\baz\\'
 
114
        self.patch(sys, 'executable', exe)
 
115
 
 
116
        self.patch(subprocess, "Popen", self._set_called)
 
117
 
 
118
        utils.start_control_panel()
 
119
 
 
120
        path = os.path.join(root, exe, 'ubuntuone-control-panel-qt.exe')
 
121
        expected = (([path, '--with-icon'],), {})
 
122
        self.assertEqual(self._called, expected)
 
123
 
 
124
 
89
125
class FakeRegistry(object):
 
126
 
90
127
    """A fake registry."""
 
128
 
91
129
    # pylint: disable=C0103
92
130
    HKEY_CURRENT_USER = 2
93
131
    KEY_ALL_ACCESS = 4
126
164
 
127
165
 
128
166
class AutostartTestCase(BaseTestCase):
 
167
 
129
168
    """Test add_syncdaemon_to_autostart."""
130
169
 
131
170
    def setUp(self):
138
177
        """Check that the registry is updated correctly."""
139
178
        # I can't patch sys because frozen is not there by default
140
179
        sys.frozen = True
141
 
 
142
 
        def clean_frozen():
143
 
            """Remove sys.frozen."""
144
 
            del sys.frozen
145
 
 
146
 
        self.addCleanup(clean_frozen)
 
180
        self.addCleanup(delattr, sys, 'frozen')
147
181
        utils.windows.add_syncdaemon_to_autostart()
148
182
        self.assertEqual(self.registry.connect_args,
149
183
            ((None, self.registry.HKEY_CURRENT_USER), {}))