Merge lp:~ralsina/ubuntuone-control-panel/unique_in_ubuntu into lp:ubuntuone-control-panel

Proposed by Roberto Alsina
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
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!

To post a comment you must log in.
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

+1

review: Approve
Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (28.7 KiB)

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/controlpanel ***
ubuntuone.controlpanel.tests.test_replication_client
  ReplicationsTestCase
    test_exclude ... [OK]
    test_exclude_name_in_exclusions ... [OK]
    test_exclude_name_not_in_replications ... [OK]
    test_get_exclusions ... [OK]
    test_get_replications ... [OK]
    test_no_pairing_record ... [OK]
    test_replicate ... [OK]
    test_replicate_name_not_in_exclusions ... [OK]
    test_replicate_name_not_in_replications ... [OK]
ubuntuone.controlpanel.tests
  TestCase
    runTest ... [OK]
ubuntuone.controlpanel.tests.test_sd_client
  AutoconnectTestCase
    test_disable ... [OK]
    test_disable_throws_an_error ... [OK]
    test_enable ... [OK]
    test_enable_throws_an_error ... [OK]
    test_get_value ... [OK]
    test_get_value_throws_an_error ... [OK]
  BaseTestCase
    runTest ... [OK]
  BasicTestCase
    test_get_current_status ... [OK]
    test_get_current_status_error ... [OK]
    test_get_root_dir ... [OK]
    test_get_shares_dir ... [OK]
    test_get_shares_dir_link ... [OK]
  FileSyncTestCase
    test_connect_file_sync ... [OK]
    test_disable_file_sync ... [OK]
    test_disconnect_file_sync ... [OK]
    test_enable_file_sync ... [OK]
    test_file_sync_enabled ... [OK]
    test_set_status_changed_handler ... [OK]
    test_start_file_sync ... [OK]
    test_stop_file_sync ... [OK]
  FoldersTestCase
    test_create_folder ... [OK]
    test_create_folder_error ... [OK]
    test_get_folders ... [OK]
    test_get_folders_error ... [OK]
    test_subscribe...

Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (28.7 KiB)

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/controlpanel ***
ubuntuone.controlpanel.tests.test_replication_client
  ReplicationsTestCase
    test_exclude ... [OK]
    test_exclude_name_in_exclusions ... [OK]
    test_exclude_name_not_in_replications ... [OK]
    test_get_exclusions ... [OK]
    test_get_replications ... [OK]
    test_no_pairing_record ... [OK]
    test_replicate ... [OK]
    test_replicate_name_not_in_exclusions ... [OK]
    test_replicate_name_not_in_replications ... [OK]
ubuntuone.controlpanel.tests
  TestCase
    runTest ... [OK]
ubuntuone.controlpanel.tests.test_sd_client
  AutoconnectTestCase
    test_disable ... [OK]
    test_disable_throws_an_error ... [OK]
    test_enable ... [OK]
    test_enable_throws_an_error ... [OK]
    test_get_value ... [OK]
    test_get_value_throws_an_error ... [OK]
  BaseTestCase
    runTest ... [OK]
  BasicTestCase
    test_get_current_status ... [OK]
    test_get_current_status_error ... [OK]
    test_get_root_dir ... [OK]
    test_get_shares_dir ... [OK]
    test_get_shares_dir_link ... [OK]
  FileSyncTestCase
    test_connect_file_sync ... [OK]
    test_disable_file_sync ... [OK]
    test_disconnect_file_sync ... [OK]
    test_enable_file_sync ... [OK]
    test_file_sync_enabled ... [OK]
    test_set_status_changed_handler ... [OK]
    test_start_file_sync ... [OK]
    test_stop_file_sync ... [OK]
  FoldersTestCase
    test_create_folder ... [OK]
    test_create_folder_error ... [OK]
    test_get_folders ... [OK]
    test_get_folders_error ... [OK]
    test_subscribe...

319. By Roberto Alsina

put the tests in the right variable so they work on tarmac

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'run-tests'
--- run-tests 2012-02-29 19:49:44 +0000
+++ run-tests 2012-04-25 13:38:20 +0000
@@ -16,7 +16,7 @@
16# You should have received a copy of the GNU General Public License along16# You should have received a copy of the GNU General Public License along
17# with this program. If not, see <http://www.gnu.org/licenses/>.17# with this program. If not, see <http://www.gnu.org/licenses/>.
1818
19QT_TESTS_PATH="ubuntuone/controlpanel/gui/qt/tests, ubuntuone/controlpanel/gui/qt/main/tests"19QT_TESTS_PATH="ubuntuone/controlpanel/gui/qt/tests, ubuntuone/controlpanel/gui/qt/main/tests, ubuntuone/controlpanel/gui/qt/uniqueapp/tests"
20DBUS_TESTS_PATH=ubuntuone/controlpanel/dbustests20DBUS_TESTS_PATH=ubuntuone/controlpanel/dbustests
21WINDOWS_TESTS=test_windows.py21WINDOWS_TESTS=test_windows.py
2222
2323
=== modified file 'ubuntuone/controlpanel/gui/qt/main/__init__.py'
--- ubuntuone/controlpanel/gui/qt/main/__init__.py 2012-03-29 17:20:14 +0000
+++ ubuntuone/controlpanel/gui/qt/main/__init__.py 2012-04-25 13:38:20 +0000
@@ -100,6 +100,7 @@
100 installer=installer)100 installer=installer)
101 if window:101 if window:
102 window.switch_to(switch_to)102 window.switch_to(switch_to)
103 app.new_instance.connect(window.raise_)
103 # pylint: enable=W0612104 # pylint: enable=W0612
104 if icon:105 if icon:
105 app.new_instance.connect(icon.restore_window)106 app.new_instance.connect(icon.restore_window)
106107
=== modified file 'ubuntuone/controlpanel/gui/qt/main/tests/test_main.py'
--- ubuntuone/controlpanel/gui/qt/main/tests/test_main.py 2012-03-29 17:08:33 +0000
+++ ubuntuone/controlpanel/gui/qt/main/tests/test_main.py 2012-04-25 13:38:20 +0000
@@ -23,6 +23,7 @@
2323
24from ubuntuone.controlpanel.gui.qt import main24from ubuntuone.controlpanel.gui.qt import main
25from ubuntuone.controlpanel.tests import TestCase25from ubuntuone.controlpanel.tests import TestCase
26from ubuntuone.controlpanel.gui.tests import FakeSignal
2627
2728
28class FakeTranslator(object):29class FakeTranslator(object):
@@ -44,6 +45,7 @@
44 self.args = None45 self.args = None
45 self.style = None46 self.style = None
46 self.translator = None47 self.translator = None
48 self.new_instance = FakeSignal()
4749
48 def __call__(self, argv, *args, **kwargs):50 def __call__(self, argv, *args, **kwargs):
49 """Fake arg filtering function."""51 """Fake arg filtering function."""
@@ -77,6 +79,7 @@
7779
78 tabname = None80 tabname = None
79 urgent = None81 urgent = None
82 raised = None
8083
81 def switch_to(self, tabname):84 def switch_to(self, tabname):
82 """Fake switch_to."""85 """Fake switch_to."""
@@ -86,6 +89,10 @@
86 """Fake set_urgent."""89 """Fake set_urgent."""
87 self.urgent = value90 self.urgent = value
8891
92 def raise_(self):
93 """Fake raise."""
94 self.raised = True
95
8996
90class FakeStart(object):97class FakeStart(object):
9198
@@ -183,3 +190,9 @@
183 self.assertEqual(self.translator.args, (("qt_" + locale,190 self.assertEqual(self.translator.args, (("qt_" + locale,
184 QtCore.QLibraryInfo.location(191 QtCore.QLibraryInfo.location(
185 QtCore.QLibraryInfo.TranslationsPath)), {}))192 QtCore.QLibraryInfo.TranslationsPath)), {}))
193
194 def test_new_instance(self):
195 """Ensure the new_instance signal is connected."""
196 main.main([sys.argv[0]])
197 self.assertEqual(self.app.new_instance.target,
198 self.start.window.raise_)
186199
=== modified file 'ubuntuone/controlpanel/gui/qt/uniqueapp/__init__.py'
--- ubuntuone/controlpanel/gui/qt/uniqueapp/__init__.py 2012-01-23 20:15:09 +0000
+++ ubuntuone/controlpanel/gui/qt/uniqueapp/__init__.py 2012-04-25 13:38:20 +0000
@@ -16,13 +16,33 @@
1616
17"""A QApplication that starts a single instance."""17"""A QApplication that starts a single instance."""
1818
19#pylint: disable=W0404
20import sys19import sys
2120
22if sys.platform == "win32":21from PyQt4 import QtNetwork, QtGui, QtCore
23 from ubuntuone.controlpanel.gui.qt.uniqueapp import windows as platform22
24else:23
25 from ubuntuone.controlpanel.gui.qt.uniqueapp import linux as platform24class UniqueApplication(QtGui.QApplication):
2625
27#pylint: disable=C010326 """A dummy UniqueApplication class."""
28UniqueApplication = platform.UniqueApplication27
28 new_instance = QtCore.pyqtSignal()
29
30 def __init__(self, argv, key):
31 super(UniqueApplication, self).__init__(argv)
32 self.key = key
33 self.server = QtNetwork.QLocalServer(self)
34 self.server.newConnection.connect(self.new_instance.emit)
35 self.aboutToQuit.connect(self.cleanup)
36 # Try to connect to existing app
37 socket = QtNetwork.QLocalSocket()
38 socket.connectToServer(key, QtCore.QIODevice.WriteOnly)
39 if socket.waitForConnected(500):
40 # Connected, exit
41 sys.exit()
42
43 # Not connected, start server
44 self.ready = self.server.listen(key)
45
46 def cleanup(self):
47 """Remove the socket when we die."""
48 self.server.removeServer(self.key)
2949
=== removed file 'ubuntuone/controlpanel/gui/qt/uniqueapp/linux.py'
--- ubuntuone/controlpanel/gui/qt/uniqueapp/linux.py 2012-02-24 02:49:47 +0000
+++ ubuntuone/controlpanel/gui/qt/uniqueapp/linux.py 1970-01-01 00:00:00 +0000
@@ -1,29 +0,0 @@
1# -*- coding: utf-8 -*-
2#
3# Copyright 2011 Canonical Ltd.
4#
5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program. If not, see <http://www.gnu.org/licenses/>.
16
17"""A QApplication that starts a single instance."""
18
19from PyQt4 import QtGui, QtCore
20
21
22class UniqueApplication(QtGui.QApplication):
23
24 """A dummy UniqueApplication class."""
25
26 new_instance = QtCore.pyqtSignal()
27
28 def __init__(self, argv, key):
29 super(UniqueApplication, self).__init__(argv)
300
=== renamed file 'ubuntuone/controlpanel/gui/qt/uniqueapp/tests/test_windows.py' => 'ubuntuone/controlpanel/gui/qt/uniqueapp/tests/test_unique_app.py'
--- ubuntuone/controlpanel/gui/qt/uniqueapp/tests/test_windows.py 2012-01-02 14:29:16 +0000
+++ ubuntuone/controlpanel/gui/qt/uniqueapp/tests/test_unique_app.py 2012-04-25 13:38:20 +0000
@@ -19,8 +19,9 @@
19from PyQt4 import QtCore19from PyQt4 import QtCore
20from twisted.internet.defer import inlineCallbacks20from twisted.internet.defer import inlineCallbacks
2121
22from ubuntuone.controlpanel.gui.qt.uniqueapp import windows as uniqueapp22from ubuntuone.controlpanel.gui.qt import uniqueapp
23from ubuntuone.controlpanel.tests import TestCase23from ubuntuone.controlpanel.tests import TestCase
24from ubuntuone.controlpanel.gui.tests import FakeSignal
2425
2526
26#pylint: disable=C010327#pylint: disable=C0103
@@ -42,28 +43,6 @@
42 return self.connect_succeeds43 return self.connect_succeeds
4344
4445
45class FakeSignal(object):
46
47 """A fake PyQt signal."""
48
49 def __init__(self, *args, **kwargs):
50 """Initialize."""
51 self.target = None
52
53 def connect(self, target):
54 """Fake connect."""
55 self.target = target
56
57 def disconnect(self, *args):
58 """Fake disconnect."""
59 self.target = None
60
61 def emit(self, *args):
62 """Fake emit."""
63 if self.target:
64 self.target(*args)
65
66
67class FakeLocalServer(object):46class FakeLocalServer(object):
6847
69 """A fake QLocalServer."""48 """A fake QLocalServer."""
7049
=== removed file 'ubuntuone/controlpanel/gui/qt/uniqueapp/windows.py'
--- ubuntuone/controlpanel/gui/qt/uniqueapp/windows.py 2012-01-04 11:09:35 +0000
+++ ubuntuone/controlpanel/gui/qt/uniqueapp/windows.py 1970-01-01 00:00:00 +0000
@@ -1,52 +0,0 @@
1# -*- coding: utf-8 -*-
2#
3# Copyright 2011 Canonical Ltd.
4#
5# This program is free software: you can redistribute it and/or modify it
6# under the terms of the GNU General Public License version 3, as published
7# by the Free Software Foundation.
8#
9# This program is distributed in the hope that it will be useful, but
10# WITHOUT ANY WARRANTY; without even the implied warranties of
11# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
12# PURPOSE. See the GNU General Public License for more details.
13#
14# You should have received a copy of the GNU General Public License along
15# with this program. If not, see <http://www.gnu.org/licenses/>.
16
17"""A QApplication that starts a single instance."""
18
19import sys
20
21from PyQt4 import QtNetwork, QtGui, QtCore
22
23
24class UniqueApplication(QtGui.QApplication):
25
26 """A QApplication that can only be started once.
27
28 Also, the new instance notifies the old one to show
29 its window.
30 """
31
32 new_instance = QtCore.pyqtSignal()
33
34 def __init__(self, argv, key):
35 super(UniqueApplication, self).__init__(argv)
36 self.key = key
37 self.server = QtNetwork.QLocalServer(self)
38 self.server.newConnection.connect(self.new_instance.emit)
39 self.aboutToQuit.connect(self.cleanup)
40 # Try to connect to existing app
41 socket = QtNetwork.QLocalSocket()
42 socket.connectToServer(key, QtCore.QIODevice.WriteOnly)
43 if socket.waitForConnected(500):
44 # Connected, exit
45 sys.exit()
46
47 # Not connected, start server
48 self.ready = self.server.listen(key)
49
50 def cleanup(self):
51 """Remove the socket when we die."""
52 self.server.removeServer(self.key)
530
=== modified file 'ubuntuone/controlpanel/gui/tests/__init__.py'
--- ubuntuone/controlpanel/gui/tests/__init__.py 2012-04-03 14:49:59 +0000
+++ ubuntuone/controlpanel/gui/tests/__init__.py 2012-04-25 13:38:20 +0000
@@ -177,3 +177,25 @@
177 return result177 return result
178178
179 return faked_call_in_faked_object179 return faked_call_in_faked_object
180
181
182class FakeSignal(object):
183
184 """A fake PyQt signal."""
185
186 def __init__(self, *args, **kwargs):
187 """Initialize."""
188 self.target = None
189
190 def connect(self, target):
191 """Fake connect."""
192 self.target = target
193
194 def disconnect(self, *args):
195 """Fake disconnect."""
196 self.target = None
197
198 def emit(self, *args):
199 """Fake emit."""
200 if self.target:
201 self.target(*args)

Subscribers

People subscribed via source and target branches