Merge lp:~ralsina/ubuntuone-control-panel/unique_in_ubuntu into lp:ubuntuone-control-panel
- unique_in_ubuntu
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Roberto Alsina | ||||
Approved revision: | 319 | ||||
Merged at revision: | 317 | ||||
Proposed branch: | lp:~ralsina/ubuntuone-control-panel/unique_in_ubuntu | ||||
Merge into: | lp:ubuntuone-control-panel | ||||
Diff against target: |
284 lines (+67/-113) 8 files modified
run-tests (+1/-1) ubuntuone/controlpanel/gui/qt/main/__init__.py (+1/-0) ubuntuone/controlpanel/gui/qt/main/tests/test_main.py (+13/-0) ubuntuone/controlpanel/gui/qt/uniqueapp/__init__.py (+28/-8) ubuntuone/controlpanel/gui/qt/uniqueapp/linux.py (+0/-29) ubuntuone/controlpanel/gui/qt/uniqueapp/tests/test_unique_app.py (+2/-23) ubuntuone/controlpanel/gui/qt/uniqueapp/windows.py (+0/-52) ubuntuone/controlpanel/gui/tests/__init__.py (+22/-0) |
||||
To merge this branch: | bzr merge lp:~ralsina/ubuntuone-control-panel/unique_in_ubuntu | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
dobey (community) | Approve | ||
Diego Sarmentero (community) | Approve | ||
Review via email: mp+103336@code.launchpad.net |
Commit message
- Implemented UniqueApplication for Linux (Fixes LP:987909).
Description of the change
Implemented UniqueApplication for linux, by just using the same thing as in Windows.
To test IRL:
start the control panel.
start it again.
See a single window? Nice!
dobey (dobey) : | # |
Ubuntu One Auto Pilot (otto-pilot) wrote : | # |
The attempt to merge lp:~ralsina/ubuntuone-control-panel/unique_in_ubuntu into lp:ubuntuone-control-panel failed. Below is the output from the failed tests.
*** Running test suite for ubuntuone/
ubuntuone.
ReplicationsT
test_exclude ... [OK]
test_
test_
test_
test_
test_
test_replicate ... [OK]
test_
test_
ubuntuone.
TestCase
runTest ... [OK]
ubuntuone.
AutoconnectTe
test_disable ... [OK]
test_
test_enable ... [OK]
test_
test_get_value ... [OK]
test_
BaseTestCase
runTest ... [OK]
BasicTestCase
test_
test_
test_
test_
test_
FileSyncTestCase
test_
test_
test_
test_
test_
test_
test_
test_
FoldersTestCase
test_
test_
test_
test_
test_
Ubuntu One Auto Pilot (otto-pilot) wrote : | # |
The attempt to merge lp:~ralsina/ubuntuone-control-panel/unique_in_ubuntu into lp:ubuntuone-control-panel failed. Below is the output from the failed tests.
*** Running test suite for ubuntuone/
ubuntuone.
ReplicationsT
test_exclude ... [OK]
test_
test_
test_
test_
test_
test_replicate ... [OK]
test_
test_
ubuntuone.
TestCase
runTest ... [OK]
ubuntuone.
AutoconnectTe
test_disable ... [OK]
test_
test_enable ... [OK]
test_
test_get_value ... [OK]
test_
BaseTestCase
runTest ... [OK]
BasicTestCase
test_
test_
test_
test_
test_
FileSyncTestCase
test_
test_
test_
test_
test_
test_
test_
test_
FoldersTestCase
test_
test_
test_
test_
test_
- 319. By Roberto Alsina
-
put the tests in the right variable so they work on tarmac
Preview Diff
1 | === modified file 'run-tests' | |||
2 | --- run-tests 2012-02-29 19:49:44 +0000 | |||
3 | +++ run-tests 2012-04-25 13:38:20 +0000 | |||
4 | @@ -16,7 +16,7 @@ | |||
5 | 16 | # You should have received a copy of the GNU General Public License along | 16 | # You should have received a copy of the GNU General Public License along |
6 | 17 | # with this program. If not, see <http://www.gnu.org/licenses/>. | 17 | # with this program. If not, see <http://www.gnu.org/licenses/>. |
7 | 18 | 18 | ||
9 | 19 | QT_TESTS_PATH="ubuntuone/controlpanel/gui/qt/tests, ubuntuone/controlpanel/gui/qt/main/tests" | 19 | QT_TESTS_PATH="ubuntuone/controlpanel/gui/qt/tests, ubuntuone/controlpanel/gui/qt/main/tests, ubuntuone/controlpanel/gui/qt/uniqueapp/tests" |
10 | 20 | DBUS_TESTS_PATH=ubuntuone/controlpanel/dbustests | 20 | DBUS_TESTS_PATH=ubuntuone/controlpanel/dbustests |
11 | 21 | WINDOWS_TESTS=test_windows.py | 21 | WINDOWS_TESTS=test_windows.py |
12 | 22 | 22 | ||
13 | 23 | 23 | ||
14 | === modified file 'ubuntuone/controlpanel/gui/qt/main/__init__.py' | |||
15 | --- ubuntuone/controlpanel/gui/qt/main/__init__.py 2012-03-29 17:20:14 +0000 | |||
16 | +++ ubuntuone/controlpanel/gui/qt/main/__init__.py 2012-04-25 13:38:20 +0000 | |||
17 | @@ -100,6 +100,7 @@ | |||
18 | 100 | installer=installer) | 100 | installer=installer) |
19 | 101 | if window: | 101 | if window: |
20 | 102 | window.switch_to(switch_to) | 102 | window.switch_to(switch_to) |
21 | 103 | app.new_instance.connect(window.raise_) | ||
22 | 103 | # pylint: enable=W0612 | 104 | # pylint: enable=W0612 |
23 | 104 | if icon: | 105 | if icon: |
24 | 105 | app.new_instance.connect(icon.restore_window) | 106 | app.new_instance.connect(icon.restore_window) |
25 | 106 | 107 | ||
26 | === modified file 'ubuntuone/controlpanel/gui/qt/main/tests/test_main.py' | |||
27 | --- ubuntuone/controlpanel/gui/qt/main/tests/test_main.py 2012-03-29 17:08:33 +0000 | |||
28 | +++ ubuntuone/controlpanel/gui/qt/main/tests/test_main.py 2012-04-25 13:38:20 +0000 | |||
29 | @@ -23,6 +23,7 @@ | |||
30 | 23 | 23 | ||
31 | 24 | from ubuntuone.controlpanel.gui.qt import main | 24 | from ubuntuone.controlpanel.gui.qt import main |
32 | 25 | from ubuntuone.controlpanel.tests import TestCase | 25 | from ubuntuone.controlpanel.tests import TestCase |
33 | 26 | from ubuntuone.controlpanel.gui.tests import FakeSignal | ||
34 | 26 | 27 | ||
35 | 27 | 28 | ||
36 | 28 | class FakeTranslator(object): | 29 | class FakeTranslator(object): |
37 | @@ -44,6 +45,7 @@ | |||
38 | 44 | self.args = None | 45 | self.args = None |
39 | 45 | self.style = None | 46 | self.style = None |
40 | 46 | self.translator = None | 47 | self.translator = None |
41 | 48 | self.new_instance = FakeSignal() | ||
42 | 47 | 49 | ||
43 | 48 | def __call__(self, argv, *args, **kwargs): | 50 | def __call__(self, argv, *args, **kwargs): |
44 | 49 | """Fake arg filtering function.""" | 51 | """Fake arg filtering function.""" |
45 | @@ -77,6 +79,7 @@ | |||
46 | 77 | 79 | ||
47 | 78 | tabname = None | 80 | tabname = None |
48 | 79 | urgent = None | 81 | urgent = None |
49 | 82 | raised = None | ||
50 | 80 | 83 | ||
51 | 81 | def switch_to(self, tabname): | 84 | def switch_to(self, tabname): |
52 | 82 | """Fake switch_to.""" | 85 | """Fake switch_to.""" |
53 | @@ -86,6 +89,10 @@ | |||
54 | 86 | """Fake set_urgent.""" | 89 | """Fake set_urgent.""" |
55 | 87 | self.urgent = value | 90 | self.urgent = value |
56 | 88 | 91 | ||
57 | 92 | def raise_(self): | ||
58 | 93 | """Fake raise.""" | ||
59 | 94 | self.raised = True | ||
60 | 95 | |||
61 | 89 | 96 | ||
62 | 90 | class FakeStart(object): | 97 | class FakeStart(object): |
63 | 91 | 98 | ||
64 | @@ -183,3 +190,9 @@ | |||
65 | 183 | self.assertEqual(self.translator.args, (("qt_" + locale, | 190 | self.assertEqual(self.translator.args, (("qt_" + locale, |
66 | 184 | QtCore.QLibraryInfo.location( | 191 | QtCore.QLibraryInfo.location( |
67 | 185 | QtCore.QLibraryInfo.TranslationsPath)), {})) | 192 | QtCore.QLibraryInfo.TranslationsPath)), {})) |
68 | 193 | |||
69 | 194 | def test_new_instance(self): | ||
70 | 195 | """Ensure the new_instance signal is connected.""" | ||
71 | 196 | main.main([sys.argv[0]]) | ||
72 | 197 | self.assertEqual(self.app.new_instance.target, | ||
73 | 198 | self.start.window.raise_) | ||
74 | 186 | 199 | ||
75 | === modified file 'ubuntuone/controlpanel/gui/qt/uniqueapp/__init__.py' | |||
76 | --- ubuntuone/controlpanel/gui/qt/uniqueapp/__init__.py 2012-01-23 20:15:09 +0000 | |||
77 | +++ ubuntuone/controlpanel/gui/qt/uniqueapp/__init__.py 2012-04-25 13:38:20 +0000 | |||
78 | @@ -16,13 +16,33 @@ | |||
79 | 16 | 16 | ||
80 | 17 | """A QApplication that starts a single instance.""" | 17 | """A QApplication that starts a single instance.""" |
81 | 18 | 18 | ||
82 | 19 | #pylint: disable=W0404 | ||
83 | 20 | import sys | 19 | import sys |
84 | 21 | 20 | ||
92 | 22 | if sys.platform == "win32": | 21 | from PyQt4 import QtNetwork, QtGui, QtCore |
93 | 23 | from ubuntuone.controlpanel.gui.qt.uniqueapp import windows as platform | 22 | |
94 | 24 | else: | 23 | |
95 | 25 | from ubuntuone.controlpanel.gui.qt.uniqueapp import linux as platform | 24 | class UniqueApplication(QtGui.QApplication): |
96 | 26 | 25 | ||
97 | 27 | #pylint: disable=C0103 | 26 | """A dummy UniqueApplication class.""" |
98 | 28 | UniqueApplication = platform.UniqueApplication | 27 | |
99 | 28 | new_instance = QtCore.pyqtSignal() | ||
100 | 29 | |||
101 | 30 | def __init__(self, argv, key): | ||
102 | 31 | super(UniqueApplication, self).__init__(argv) | ||
103 | 32 | self.key = key | ||
104 | 33 | self.server = QtNetwork.QLocalServer(self) | ||
105 | 34 | self.server.newConnection.connect(self.new_instance.emit) | ||
106 | 35 | self.aboutToQuit.connect(self.cleanup) | ||
107 | 36 | # Try to connect to existing app | ||
108 | 37 | socket = QtNetwork.QLocalSocket() | ||
109 | 38 | socket.connectToServer(key, QtCore.QIODevice.WriteOnly) | ||
110 | 39 | if socket.waitForConnected(500): | ||
111 | 40 | # Connected, exit | ||
112 | 41 | sys.exit() | ||
113 | 42 | |||
114 | 43 | # Not connected, start server | ||
115 | 44 | self.ready = self.server.listen(key) | ||
116 | 45 | |||
117 | 46 | def cleanup(self): | ||
118 | 47 | """Remove the socket when we die.""" | ||
119 | 48 | self.server.removeServer(self.key) | ||
120 | 29 | 49 | ||
121 | === removed file 'ubuntuone/controlpanel/gui/qt/uniqueapp/linux.py' | |||
122 | --- ubuntuone/controlpanel/gui/qt/uniqueapp/linux.py 2012-02-24 02:49:47 +0000 | |||
123 | +++ ubuntuone/controlpanel/gui/qt/uniqueapp/linux.py 1970-01-01 00:00:00 +0000 | |||
124 | @@ -1,29 +0,0 @@ | |||
125 | 1 | # -*- coding: utf-8 -*- | ||
126 | 2 | # | ||
127 | 3 | # Copyright 2011 Canonical Ltd. | ||
128 | 4 | # | ||
129 | 5 | # This program is free software: you can redistribute it and/or modify it | ||
130 | 6 | # under the terms of the GNU General Public License version 3, as published | ||
131 | 7 | # by the Free Software Foundation. | ||
132 | 8 | # | ||
133 | 9 | # This program is distributed in the hope that it will be useful, but | ||
134 | 10 | # WITHOUT ANY WARRANTY; without even the implied warranties of | ||
135 | 11 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
136 | 12 | # PURPOSE. See the GNU General Public License for more details. | ||
137 | 13 | # | ||
138 | 14 | # You should have received a copy of the GNU General Public License along | ||
139 | 15 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
140 | 16 | |||
141 | 17 | """A QApplication that starts a single instance.""" | ||
142 | 18 | |||
143 | 19 | from PyQt4 import QtGui, QtCore | ||
144 | 20 | |||
145 | 21 | |||
146 | 22 | class UniqueApplication(QtGui.QApplication): | ||
147 | 23 | |||
148 | 24 | """A dummy UniqueApplication class.""" | ||
149 | 25 | |||
150 | 26 | new_instance = QtCore.pyqtSignal() | ||
151 | 27 | |||
152 | 28 | def __init__(self, argv, key): | ||
153 | 29 | super(UniqueApplication, self).__init__(argv) | ||
154 | 30 | 0 | ||
155 | === renamed file 'ubuntuone/controlpanel/gui/qt/uniqueapp/tests/test_windows.py' => 'ubuntuone/controlpanel/gui/qt/uniqueapp/tests/test_unique_app.py' | |||
156 | --- ubuntuone/controlpanel/gui/qt/uniqueapp/tests/test_windows.py 2012-01-02 14:29:16 +0000 | |||
157 | +++ ubuntuone/controlpanel/gui/qt/uniqueapp/tests/test_unique_app.py 2012-04-25 13:38:20 +0000 | |||
158 | @@ -19,8 +19,9 @@ | |||
159 | 19 | from PyQt4 import QtCore | 19 | from PyQt4 import QtCore |
160 | 20 | from twisted.internet.defer import inlineCallbacks | 20 | from twisted.internet.defer import inlineCallbacks |
161 | 21 | 21 | ||
163 | 22 | from ubuntuone.controlpanel.gui.qt.uniqueapp import windows as uniqueapp | 22 | from ubuntuone.controlpanel.gui.qt import uniqueapp |
164 | 23 | from ubuntuone.controlpanel.tests import TestCase | 23 | from ubuntuone.controlpanel.tests import TestCase |
165 | 24 | from ubuntuone.controlpanel.gui.tests import FakeSignal | ||
166 | 24 | 25 | ||
167 | 25 | 26 | ||
168 | 26 | #pylint: disable=C0103 | 27 | #pylint: disable=C0103 |
169 | @@ -42,28 +43,6 @@ | |||
170 | 42 | return self.connect_succeeds | 43 | return self.connect_succeeds |
171 | 43 | 44 | ||
172 | 44 | 45 | ||
173 | 45 | class FakeSignal(object): | ||
174 | 46 | |||
175 | 47 | """A fake PyQt signal.""" | ||
176 | 48 | |||
177 | 49 | def __init__(self, *args, **kwargs): | ||
178 | 50 | """Initialize.""" | ||
179 | 51 | self.target = None | ||
180 | 52 | |||
181 | 53 | def connect(self, target): | ||
182 | 54 | """Fake connect.""" | ||
183 | 55 | self.target = target | ||
184 | 56 | |||
185 | 57 | def disconnect(self, *args): | ||
186 | 58 | """Fake disconnect.""" | ||
187 | 59 | self.target = None | ||
188 | 60 | |||
189 | 61 | def emit(self, *args): | ||
190 | 62 | """Fake emit.""" | ||
191 | 63 | if self.target: | ||
192 | 64 | self.target(*args) | ||
193 | 65 | |||
194 | 66 | |||
195 | 67 | class FakeLocalServer(object): | 46 | class FakeLocalServer(object): |
196 | 68 | 47 | ||
197 | 69 | """A fake QLocalServer.""" | 48 | """A fake QLocalServer.""" |
198 | 70 | 49 | ||
199 | === removed file 'ubuntuone/controlpanel/gui/qt/uniqueapp/windows.py' | |||
200 | --- ubuntuone/controlpanel/gui/qt/uniqueapp/windows.py 2012-01-04 11:09:35 +0000 | |||
201 | +++ ubuntuone/controlpanel/gui/qt/uniqueapp/windows.py 1970-01-01 00:00:00 +0000 | |||
202 | @@ -1,52 +0,0 @@ | |||
203 | 1 | # -*- coding: utf-8 -*- | ||
204 | 2 | # | ||
205 | 3 | # Copyright 2011 Canonical Ltd. | ||
206 | 4 | # | ||
207 | 5 | # This program is free software: you can redistribute it and/or modify it | ||
208 | 6 | # under the terms of the GNU General Public License version 3, as published | ||
209 | 7 | # by the Free Software Foundation. | ||
210 | 8 | # | ||
211 | 9 | # This program is distributed in the hope that it will be useful, but | ||
212 | 10 | # WITHOUT ANY WARRANTY; without even the implied warranties of | ||
213 | 11 | # MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
214 | 12 | # PURPOSE. See the GNU General Public License for more details. | ||
215 | 13 | # | ||
216 | 14 | # You should have received a copy of the GNU General Public License along | ||
217 | 15 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
218 | 16 | |||
219 | 17 | """A QApplication that starts a single instance.""" | ||
220 | 18 | |||
221 | 19 | import sys | ||
222 | 20 | |||
223 | 21 | from PyQt4 import QtNetwork, QtGui, QtCore | ||
224 | 22 | |||
225 | 23 | |||
226 | 24 | class UniqueApplication(QtGui.QApplication): | ||
227 | 25 | |||
228 | 26 | """A QApplication that can only be started once. | ||
229 | 27 | |||
230 | 28 | Also, the new instance notifies the old one to show | ||
231 | 29 | its window. | ||
232 | 30 | """ | ||
233 | 31 | |||
234 | 32 | new_instance = QtCore.pyqtSignal() | ||
235 | 33 | |||
236 | 34 | def __init__(self, argv, key): | ||
237 | 35 | super(UniqueApplication, self).__init__(argv) | ||
238 | 36 | self.key = key | ||
239 | 37 | self.server = QtNetwork.QLocalServer(self) | ||
240 | 38 | self.server.newConnection.connect(self.new_instance.emit) | ||
241 | 39 | self.aboutToQuit.connect(self.cleanup) | ||
242 | 40 | # Try to connect to existing app | ||
243 | 41 | socket = QtNetwork.QLocalSocket() | ||
244 | 42 | socket.connectToServer(key, QtCore.QIODevice.WriteOnly) | ||
245 | 43 | if socket.waitForConnected(500): | ||
246 | 44 | # Connected, exit | ||
247 | 45 | sys.exit() | ||
248 | 46 | |||
249 | 47 | # Not connected, start server | ||
250 | 48 | self.ready = self.server.listen(key) | ||
251 | 49 | |||
252 | 50 | def cleanup(self): | ||
253 | 51 | """Remove the socket when we die.""" | ||
254 | 52 | self.server.removeServer(self.key) | ||
255 | 53 | 0 | ||
256 | === modified file 'ubuntuone/controlpanel/gui/tests/__init__.py' | |||
257 | --- ubuntuone/controlpanel/gui/tests/__init__.py 2012-04-03 14:49:59 +0000 | |||
258 | +++ ubuntuone/controlpanel/gui/tests/__init__.py 2012-04-25 13:38:20 +0000 | |||
259 | @@ -177,3 +177,25 @@ | |||
260 | 177 | return result | 177 | return result |
261 | 178 | 178 | ||
262 | 179 | return faked_call_in_faked_object | 179 | return faked_call_in_faked_object |
263 | 180 | |||
264 | 181 | |||
265 | 182 | class FakeSignal(object): | ||
266 | 183 | |||
267 | 184 | """A fake PyQt signal.""" | ||
268 | 185 | |||
269 | 186 | def __init__(self, *args, **kwargs): | ||
270 | 187 | """Initialize.""" | ||
271 | 188 | self.target = None | ||
272 | 189 | |||
273 | 190 | def connect(self, target): | ||
274 | 191 | """Fake connect.""" | ||
275 | 192 | self.target = target | ||
276 | 193 | |||
277 | 194 | def disconnect(self, *args): | ||
278 | 195 | """Fake disconnect.""" | ||
279 | 196 | self.target = None | ||
280 | 197 | |||
281 | 198 | def emit(self, *args): | ||
282 | 199 | """Fake emit.""" | ||
283 | 200 | if self.target: | ||
284 | 201 | self.target(*args) |
+1