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

Proposed by Roberto Alsina
Status: Merged
Approved by: Roberto Alsina
Approved revision: 254
Merged at revision: 248
Proposed branch: lp:~ralsina/ubuntuone-control-panel/fix_908888
Merge into: lp:ubuntuone-control-panel
Diff against target: 142 lines (+44/-12)
2 files modified
ubuntuone/controlpanel/gui/qt/systray.py (+14/-3)
ubuntuone/controlpanel/gui/qt/tests/test_systray.py (+30/-9)
To merge this branch: bzr merge lp:~ralsina/ubuntuone-control-panel/fix_908888
Reviewer Review Type Date Requested Status
Guillermo Gonzalez Approve
Roman Yepishev (community) fieldtest Approve
Review via email: mp+86920@code.launchpad.net

Commit message

When selecting "Quit Ubuntu One" from the tray context menu, shutdown syncdaemon.

Description of the change

When selecting "Quit Ubuntu One" from the tray context menu, shutdown syncdaemon.

To post a comment you must log in.
Revision history for this message
Roman Yepishev (rye) wrote :

Now when Ubuntu One control panel's quit systray menu item is selected, ubuntuone-syncdaemon.exe quits.
ubuntu-sso-login keeps working.

<rye> ralsina, hm, ubuntu-sso-login.exe keeps working though
<ralsina> rye: yes
<rye> ralsina, but syncdaemon is stopped, true
<ralsina> rye: I am not sure we even want to stop it
<ralsina> rye: cool

review: Approve (fieldtest)
Revision history for this message
Guillermo Gonzalez (verterok) wrote :

looks ok.

review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ubuntuone/controlpanel/gui/qt/systray.py'
2--- ubuntuone/controlpanel/gui/qt/systray.py 2011-09-14 20:25:55 +0000
3+++ ubuntuone/controlpanel/gui/qt/systray.py 2011-12-27 18:52:24 +0000
4@@ -1,6 +1,4 @@
5 # -*- coding: utf-8 -*-
6-
7-# Authors: Roberto Alsina <roberto.alsina@canonical.com>
8 #
9 # Copyright 2011 Canonical Ltd.
10 #
11@@ -18,6 +16,9 @@
12 """System notification area icon."""
13
14 from PyQt4 import QtGui
15+from twisted.internet.defer import inlineCallbacks
16+
17+from ubuntuone.platform.tools import SyncDaemonTool
18
19
20 class TrayIcon(QtGui.QSystemTrayIcon):
21@@ -60,8 +61,18 @@
22 self.window.close()
23 self.window = None
24
25- def stop(self):
26+ @inlineCallbacks
27+ def stop(self, *args, **kwargs):
28 """Stop the application."""
29+ # Stop syncdaemon
30+ # pylint: disable=W0702
31+ # Really, if it fails we can't do anything about it.
32+ try:
33+ st = SyncDaemonTool()
34+ yield st.quit()
35+ except:
36+ # Maybe it was not running?
37+ pass
38 # pylint: disable=W0404
39 from twisted.internet import reactor
40 # pylint: enable=W0404
41
42=== modified file 'ubuntuone/controlpanel/gui/qt/tests/test_systray.py'
43--- ubuntuone/controlpanel/gui/qt/tests/test_systray.py 2011-09-07 17:33:09 +0000
44+++ ubuntuone/controlpanel/gui/qt/tests/test_systray.py 2011-12-27 18:52:24 +0000
45@@ -19,12 +19,24 @@
46 """Tests for the notification area icon."""
47
48 from PyQt4 import QtGui
49+from twisted.internet.defer import inlineCallbacks
50
51-from ubuntuone.controlpanel.gui.qt.systray import TrayIcon
52+from ubuntuone.controlpanel.gui.qt import systray
53 from ubuntuone.controlpanel.tests import TestCase
54 import ubuntuone.controlpanel.gui.qt.gui
55
56
57+class FakeSDTool(object):
58+
59+ """Fake SyncDaemonTool."""
60+
61+ called = False
62+
63+ def quit(self):
64+ """Fake quit."""
65+ self.called = True
66+
67+
68 class FakeMainWindow(QtGui.QWidget):
69
70 """Fake Main Window."""
71@@ -42,16 +54,25 @@
72 """Test the quit option in the menu."""
73 # Not done on setup, because if I patch stop
74 # after instantiation, it doesn't get called.
75- self.patch(TrayIcon, "stop", self._set_called)
76- tray = TrayIcon()
77+ self.patch(systray.TrayIcon, "stop", self._set_called)
78+ tray = systray.TrayIcon()
79 tray.quit.trigger()
80 self.assertEqual(self._called, ((False,), {}))
81
82+ @inlineCallbacks
83+ def test_stop_sd(self):
84+ """Quit should call SyncDaemonTool.quit()."""
85+ st = FakeSDTool()
86+ self.patch(systray, "SyncDaemonTool", lambda: st)
87+ tray = systray.TrayIcon()
88+ yield tray.stop()
89+ self.assertTrue(st.called)
90+
91 def test_restore_no_window(self):
92 """Test the restore window option in the menu, with no window."""
93 self.patch(ubuntuone.controlpanel.gui.qt.gui,
94 "MainWindow", FakeMainWindow)
95- tray = TrayIcon()
96+ tray = systray.TrayIcon()
97 self.assertEqual(tray.window, None)
98 tray.restore.trigger()
99 self.assertIsInstance(tray.window, FakeMainWindow)
100@@ -61,7 +82,7 @@
101
102 def test_activate(self):
103 """Test the icon activation."""
104- tray = TrayIcon()
105+ tray = systray.TrayIcon()
106 window = FakeMainWindow()
107 tray.window = window
108 self.assertFalse(tray.window.isVisible())
109@@ -71,7 +92,7 @@
110
111 def test_restore_window(self):
112 """Test the restore window option in the menu, with a window."""
113- tray = TrayIcon()
114+ tray = systray.TrayIcon()
115 window = FakeMainWindow()
116 tray.window = window
117 self.assertFalse(tray.window.isVisible())
118@@ -81,7 +102,7 @@
119
120 def test_delete_window(self):
121 """Test deleting an existing window."""
122- tray = TrayIcon()
123+ tray = systray.TrayIcon()
124 window = FakeMainWindow()
125 tray.window = window
126 tray.delete_window()
127@@ -90,13 +111,13 @@
128
129 def test_delete_no_window(self):
130 """Test deleting without an existing window."""
131- tray = TrayIcon()
132+ tray = systray.TrayIcon()
133 tray.delete_window()
134 self.assertEqual(tray.window, None)
135
136 def test_initialization(self):
137 """Test that everything initializes correctly."""
138- tray = TrayIcon()
139+ tray = systray.TrayIcon()
140 self.assertTrue(tray.isVisible())
141 self.assertEqual(tray.window, None)
142 self.assertIsInstance(tray.context_menu, QtGui.QMenu)

Subscribers

People subscribed via source and target branches