Merge lp:~nataliabidart/ubuntuone-windows-installer/start-right into lp:ubuntuone-windows-installer

Proposed by Natalia Bidart
Status: Merged
Approved by: Natalia Bidart
Approved revision: 69
Merged at revision: 68
Proposed branch: lp:~nataliabidart/ubuntuone-windows-installer/start-right
Merge into: lp:ubuntuone-windows-installer
Diff against target: 231 lines (+66/-48)
5 files modified
ubuntuone_installer/gui/qt/tests/test_gui.py (+7/-37)
ubuntuone_installer/gui/qt/utils/linux.py (+1/-1)
ubuntuone_installer/gui/qt/utils/tests/test_linux.py (+15/-0)
ubuntuone_installer/gui/qt/utils/tests/test_windows.py (+40/-6)
ubuntuone_installer/gui/qt/utils/windows.py (+3/-4)
To merge this branch: bzr merge lp:~nataliabidart/ubuntuone-windows-installer/start-right
Reviewer Review Type Date Requested Status
Roberto Alsina (community) Approve
Review via email: mp+75618@code.launchpad.net

Commit message

- Start the control panel using the --with-icon switch (LP: #851221).

To post a comment you must log in.
69. By Natalia Bidart

Removing commented out lines.

Revision history for this message
Roberto Alsina (ralsina) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone_installer/gui/qt/tests/test_gui.py'
2--- ubuntuone_installer/gui/qt/tests/test_gui.py 2011-09-15 19:10:23 +0000
3+++ ubuntuone_installer/gui/qt/tests/test_gui.py 2011-09-15 19:59:23 +0000
4@@ -19,14 +19,9 @@
5
6 """Tests for the Qt UI."""
7
8-import os
9-import subprocess
10-import sys
11-
12 from PyQt4 import QtGui, QtCore
13-from ubuntuone.devtools.testcase import skipIfOS
14+from ubuntuone.controlpanel.gui import qt
15 from ubuntuone.platform.credentials import APP_NAME
16-from ubuntuone.controlpanel.gui import qt
17
18 from ubuntuone_installer.gui import NEXT
19 from ubuntuone_installer.gui.qt import gui, forgotten, utils
20@@ -485,38 +480,15 @@
21 """Check if the main properties of the windows are set."""
22 self.assertEqual(self.ui.windowTitle(), APP_NAME)
23
24- def test_start_control_panel_on_finishing(self):
25- """Calling done with result=1, the control panel should be called."""
26- gui.AreYouSure.result = 1
27- self.patch(subprocess, "Popen", self._set_called)
28- self.ui.done(result=1)
29- self.assertEqual(self._called,
30- ((['ubuntuone-control-panel-qt'],), {}))
31-
32- @skipIfOS('linux2', 'Windows-specific tests.')
33- def test_start_control_panel_frozen(self):
34- """When frozen, the control-panel has a path."""
35- self.ui.restart()
36- self.ui.show()
37- self.addCleanup(self.ui.hide)
38- gui.AreYouSure.result = 1
39- # I can't patch sys because frozen is not there by default
40- sys.frozen = True
41-
42- def clean_frozen():
43- """Remove sys.frozen."""
44- del sys.frozen
45-
46- self.addCleanup(clean_frozen)
47- self.patch(subprocess, "Popen", self._set_called)
48- self.ui.done(result=1)
49- self.assertIn(os.sep, self._called[0][0][0])
50- self.assertIn('ubuntuone-control-panel-qt', self._called[0][0][0])
51+ def test_start_control_panel(self):
52+ """The control panel starter is called."""
53+ self.patch(utils, 'start_control_panel', self._set_called)
54+ self.ui.done(result=1)
55+ self.assertEqual(self._called, ((), {}))
56
57 def test_not_start_control_panel_on_cancel(self):
58 """Called done with result=0, control panel should NOT be called."""
59- gui.AreYouSure.result = 1
60- self.patch(subprocess, "Popen", self._set_called)
61+ self.patch(utils, 'start_control_panel', self._set_called)
62 self.ui.done(result=0)
63 self.assertEqual(self._called, False)
64
65@@ -526,7 +498,6 @@
66 self.patch(self.ui, 'currentId', lambda: self.ui.SIGNIN_PAGE)
67 # Make AreYouSure say the user is "not sure"
68 gui.AreYouSure.result = 0
69- self.patch(subprocess, "Popen", self._set_called)
70 self.ui.show()
71 self.addCleanup(self.ui.hide)
72 self.ui.done(result=0)
73@@ -537,7 +508,6 @@
74 self.ui.show()
75 self.addCleanup(self.ui.hide)
76 self.patch(self.ui, 'currentId', lambda: self.ui.CONGRATULATIONS_PAGE)
77- self.patch(subprocess, "Popen", self._set_called)
78 self.ui.done(result=0)
79 self.assertEqual(self._called, False)
80 self.assertEqual(FakeAreYouSure.shown, False)
81
82=== modified file 'ubuntuone_installer/gui/qt/utils/linux.py'
83--- ubuntuone_installer/gui/qt/utils/linux.py 2011-09-07 20:34:19 +0000
84+++ ubuntuone_installer/gui/qt/utils/linux.py 2011-09-15 19:59:23 +0000
85@@ -29,7 +29,7 @@
86
87 def start_control_panel():
88 """Start the control panel."""
89- subprocess.Popen(["ubuntuone-control-panel-qt", ])
90+ subprocess.Popen(["ubuntuone-control-panel-qt"])
91
92
93 def remove_syncdaemon_from_autostart():
94
95=== modified file 'ubuntuone_installer/gui/qt/utils/tests/test_linux.py'
96--- ubuntuone_installer/gui/qt/utils/tests/test_linux.py 2011-08-30 14:11:48 +0000
97+++ ubuntuone_installer/gui/qt/utils/tests/test_linux.py 2011-09-15 19:59:23 +0000
98@@ -19,11 +19,26 @@
99 """Tests for the platform specific functions."""
100
101 import os
102+import subprocess
103
104 from ubuntuone_installer.gui.qt import utils
105 from ubuntuone_installer.gui.qt.tests import BaseTestCase
106
107
108+class StartControlPanelTestCase(BaseTestCase):
109+
110+ """Test the start of the control panel."""
111+
112+ def test_start_control_panel(self):
113+ """The proper process is started."""
114+ self.patch(subprocess, "Popen", self._set_called)
115+
116+ utils.start_control_panel()
117+
118+ expected = ((['ubuntuone-control-panel-qt'],), {})
119+ self.assertEqual(self._called, expected)
120+
121+
122 class DefaultFoldersTestCase(BaseTestCase):
123
124 """Test the default suggested UDFs."""
125
126=== modified file 'ubuntuone_installer/gui/qt/utils/tests/test_windows.py'
127--- ubuntuone_installer/gui/qt/utils/tests/test_windows.py 2011-09-13 14:43:39 +0000
128+++ ubuntuone_installer/gui/qt/utils/tests/test_windows.py 2011-09-15 19:59:23 +0000
129@@ -20,6 +20,7 @@
130
131 import sys
132 import os
133+import subprocess
134
135 # Avoid pylint error on Linux
136 # pylint: disable=F0401
137@@ -31,6 +32,7 @@
138
139
140 class UninstallerTestCase(BaseTestCase):
141+
142 """Test the uninstaller."""
143
144 def test_execute_uninstall_on_licence_cancel_file_not_exists(self):
145@@ -86,8 +88,44 @@
146 self.assertEqual(0, self._called[0][5])
147
148
149+class StartControlPanelTestCase(BaseTestCase):
150+
151+ """Test the start of the control panel."""
152+
153+ def test_start_control_panel(self):
154+ """The proper process is started."""
155+ self.patch(subprocess, "Popen", self._set_called)
156+
157+ utils.start_control_panel()
158+
159+ expected = ((['ubuntuone-control-panel-qt', '--with-icon'],), {})
160+ self.assertEqual(self._called, expected)
161+
162+ def test_start_control_panel_frozen(self):
163+ """When frozen, the control-panel has a path."""
164+ # I can't patch sys because frozen is not there by default
165+ sys.frozen = True
166+ self.addCleanup(delattr, sys, 'frozen')
167+
168+ root = 'Z:\\Yadda\\Yoo'
169+ self.patch(os.path, 'abspath', lambda p: os.path.join(root, p))
170+ self.patch(os.path, 'dirname', lambda p: p)
171+ exe = 'foo\\bar\\baz\\'
172+ self.patch(sys, 'executable', exe)
173+
174+ self.patch(subprocess, "Popen", self._set_called)
175+
176+ utils.start_control_panel()
177+
178+ path = os.path.join(root, exe, 'ubuntuone-control-panel-qt.exe')
179+ expected = (([path, '--with-icon'],), {})
180+ self.assertEqual(self._called, expected)
181+
182+
183 class FakeRegistry(object):
184+
185 """A fake registry."""
186+
187 # pylint: disable=C0103
188 HKEY_CURRENT_USER = 2
189 KEY_ALL_ACCESS = 4
190@@ -126,6 +164,7 @@
191
192
193 class AutostartTestCase(BaseTestCase):
194+
195 """Test add_syncdaemon_to_autostart."""
196
197 def setUp(self):
198@@ -138,12 +177,7 @@
199 """Check that the registry is updated correctly."""
200 # I can't patch sys because frozen is not there by default
201 sys.frozen = True
202-
203- def clean_frozen():
204- """Remove sys.frozen."""
205- del sys.frozen
206-
207- self.addCleanup(clean_frozen)
208+ self.addCleanup(delattr, sys, 'frozen')
209 utils.windows.add_syncdaemon_to_autostart()
210 self.assertEqual(self.registry.connect_args,
211 ((None, self.registry.HKEY_CURRENT_USER), {}))
212
213=== modified file 'ubuntuone_installer/gui/qt/utils/windows.py'
214--- ubuntuone_installer/gui/qt/utils/windows.py 2011-09-13 01:33:57 +0000
215+++ ubuntuone_installer/gui/qt/utils/windows.py 2011-09-15 19:59:23 +0000
216@@ -52,12 +52,11 @@
217 # If we are in windows and "frozen", assume it's in
218 # the same folder as this .exe
219 if hasattr(sys, "frozen"):
220- cp_path = os.path.join(os.path.dirname(
221- os.path.abspath(sys.executable)),
222- "ubuntuone-control-panel-qt.exe")
223+ cp_dir = os.path.dirname(os.path.abspath(sys.executable))
224+ cp_path = os.path.join(cp_dir, "ubuntuone-control-panel-qt.exe")
225 else:
226 cp_path = "ubuntuone-control-panel-qt"
227- subprocess.Popen([cp_path, ])
228+ subprocess.Popen([cp_path, "--with-icon"])
229
230
231 def add_syncdaemon_to_autostart():

Subscribers

People subscribed via source and target branches