Merge lp:~diegosarmentero/ubuntuone-control-panel/menu-desktop-services-actions into lp:ubuntuone-control-panel

Proposed by Diego Sarmentero
Status: Merged
Approved by: Diego Sarmentero
Approved revision: 349
Merged at revision: 343
Proposed branch: lp:~diegosarmentero/ubuntuone-control-panel/menu-desktop-services-actions
Merge into: lp:ubuntuone-control-panel
Prerequisite: lp:~diegosarmentero/ubuntuone-control-panel/refactor-sync-status
Diff against target: 539 lines (+397/-54) (has conflicts)
2 files modified
ubuntuone/controlpanel/gui/qt/systray.py (+194/-51)
ubuntuone/controlpanel/gui/qt/tests/test_systray.py (+203/-3)
Text conflict in ubuntuone/controlpanel/gui/qt/systray.py
Text conflict in ubuntuone/controlpanel/gui/qt/tests/test_systray.py
To merge this branch: bzr merge lp:~diegosarmentero/ubuntuone-control-panel/menu-desktop-services-actions
Reviewer Review Type Date Requested Status
Brian Curtin (community) Approve
Manuel de la Peña (community) Approve
Review via email: mp+119370@code.launchpad.net

Commit message

- Adding open (folder, program, url) actions to the menu (LP: #1034542)

To post a comment you must log in.
Revision history for this message
Manuel de la Peña (mandel) wrote :

Some small fixes:

icon is always not None, I suppose it is icon_name

127 + icon = QtGui.QIcon()
128 + if icon is not None:
129 + icon = icon_from_name(icon_name)
130 + text = data.get('msg')
131 + self.status.setIcon(icon)
132 + self.status.setText(text)

Possible attr error:

135 + self._backend_method = getattr(self.backend, data['backend_method'])

A little cleaner way:

326 + @inlineCallbacks
327 + def test_refresh_status(self):
328 + """Test that it receives the proper information from syncdaemon."""
329 + yield self.ui.refresh_status()

do instead:

def test_refresh_status(self):
    """Test that it receives the proper information from syncdaemon."""
    return self.ui.refresh_status()

Tests can return deferreds so no need for the inlineCallbacks

The following is a personal thing, ignore it if you wish:

signal_pairs = (
    (self.status_action, self.change_status)
    (self.open_u1, self.restore_window)
    (self.open_u1_folder, self.open_u1_folder_action)
    (self.get_more_storage, self.get_more_storage_action)
    (self.go_to_web, self.go_to_web_action)
    (self.get_help_online, self.get_help_action)
    (self.quit, self.stop)
)

for button, callback in signal_pairs:
    button.triggered.connect(callback)

Instead of:

# Connect Signals
self.status_action.triggered.connect(self.change_status)
self.open_u1.triggered.connect(self.restore_window)
self.open_u1_folder.triggered.connect(self.open_u1_folder_action)
self.get_more_storage.triggered.connect(self.get_more_storage_action)
self.go_to_web.triggered.connect(self.go_to_web_action)
self.get_help_online.triggered.connect(self.get_help_action)
self.quit.triggered.connect(self.stop)

review: Needs Fixing
Revision history for this message
Manuel de la Peña (mandel) wrote :

Looks good to me.

review: Approve
Revision history for this message
Brian Curtin (brian.curtin) wrote :

Agree on the last part with iterating over signal_pairs.

Revision history for this message
Brian Curtin (brian.curtin) wrote :

You still have TODO's on lines 73, 79, and 81.

review: Needs Fixing
Revision history for this message
Diego Sarmentero (diegosarmentero) wrote :

> You still have TODO's on lines 73, 79, and 81.

Yes, those are for the future branches i'm working right now

Revision history for this message
Brian Curtin (brian.curtin) :
review: Approve
Revision history for this message
Ubuntu One Auto Pilot (otto-pilot) wrote :
Download full text (147.2 KiB)

The attempt to merge lp:~diegosarmentero/ubuntuone-control-panel/menu-desktop-services-actions into lp:ubuntuone-control-panel failed. Below is the output from the failed tests.

*** Running DBus test suite ***
ubuntuone.controlpanel.dbustests.test_dbus_service
  BaseTestCase
    runTest ... [OK]
  DBusServiceMainTestCase
    test_dbus_service_cant_register ... Control panel backend already running.
                                   [OK]
    test_dbus_service_main ... [OK]
  DBusServiceTestCase
    test_cant_register_twice ... [SKIPPED]
    test_dbus_busname_created ... [OK]
    test_error_handler_default ... [OK]
    test_error_handler_with_exception ... [OK]
    test_error_handler_with_failure ... [OK]
    test_error_handler_with_non_string_dict ... [OK]
    test_error_handler_with_string_dict ... [OK]
    test_register_service ... [OK]
  FileSyncTestCase
    test_file_sync_status_changed ... [OK]
    test_file_sync_status_disabled ... [OK]
    test_file_sync_status_disconnected ... [OK]
    test_file_sync_status_error ... [OK]
    test_file_sync_status_idle ... [OK]
    test_file_sync_status_starting ... [OK]
    test_file_sync_status_stopped ... [OK]
    test_file_sync_status_syncing ... [OK]
    test_file_sync_status_unknown ... [OK]
    test_status_changed_handler ... [OK]
    test_status_changed_handler_after_status_requested ... [OK]
    test_status_changed_handler_after_status_requested_twice ... [OK]
  OperationsAuthErrorTestCase
    test_account_info_returned ... [OK]
    test_change_device_settings ... [OK]
    test_change_replication_settings ... [OK]
    test_change_volume_settings ... [OK]
    test_connect_files ... [OK]
    test_devices_info_returned ... [OK]
    test_disable_files ... [OK]
    test_disconnect_files ... [OK]
    test_enable_files ... [OK]
    test_remove_device ... [OK]
    test_replications_info ... [OK]
    test_restart_files ... ...

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

The attempt to merge lp:~diegosarmentero/ubuntuone-control-panel/menu-desktop-services-actions into lp:ubuntuone-control-panel failed. Below is the output from the failed tests.

*** Running DBus test suite ***
ubuntuone.controlpanel.dbustests.test_dbus_service
  BaseTestCase
    runTest ... [OK]
  DBusServiceMainTestCase
    test_dbus_service_cant_register ... Control panel backend already running.
                                   [OK]
    test_dbus_service_main ... [OK]
  DBusServiceTestCase
    test_cant_register_twice ... [SKIPPED]
    test_dbus_busname_created ... [OK]
    test_error_handler_default ... [OK]
    test_error_handler_with_exception ... [OK]
    test_error_handler_with_failure ... [OK]
    test_error_handler_with_non_string_dict ... [OK]
    test_error_handler_with_string_dict ... [OK]
    test_register_service ... [OK]
  FileSyncTestCase
    test_file_sync_status_changed ... [OK]
    test_file_sync_status_disabled ... [OK]
    test_file_sync_status_disconnected ... [OK]
    test_file_sync_status_error ... [OK]
    test_file_sync_status_idle ... [OK]
    test_file_sync_status_starting ... [OK]
    test_file_sync_status_stopped ... [OK]
    test_file_sync_status_syncing ... [OK]
    test_file_sync_status_unknown ... [OK]
    test_status_changed_handler ... [OK]
    test_status_changed_handler_after_status_requested ... [OK]
    test_status_changed_handler_after_status_requested_twice ... [OK]
  OperationsAuthErrorTestCase
    test_account_info_returned ... [OK]
    test_change_device_settings ... [OK]
    test_change_replication_settings ... [OK]
    test_change_volume_settings ... [OK]
    test_connect_files ... [OK]
    test_devices_info_returned ... [OK]
    test_disable_files ... [OK]
    test_disconnect_files ... [OK]
    test_enable_files ... [OK]
    test_remove_device ... [OK]
    test_replications_info ... [OK]
    test_restart_files ... ...

349. By Diego Sarmentero

fixing pep8 issue

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'ubuntuone/controlpanel/gui/qt/systray.py'
--- ubuntuone/controlpanel/gui/qt/systray.py 2012-08-13 12:08:15 +0000
+++ ubuntuone/controlpanel/gui/qt/systray.py 2012-08-14 19:00:25 +0000
@@ -15,13 +15,14 @@
15# with this program. If not, see <http://www.gnu.org/licenses/>.15# with this program. If not, see <http://www.gnu.org/licenses/>.
16"""System notification area icon."""16"""System notification area icon."""
1717
18from PyQt4 import QtGui18from PyQt4 import QtGui, QtCore
19from twisted.internet.defer import inlineCallbacks19from twisted.internet.defer import inlineCallbacks
20from ubuntuone.platform.tools import SyncDaemonTool20from ubuntuone.platform.tools import SyncDaemonTool
2121
22from ubuntuone.controlpanel import backend, cache22from ubuntuone.controlpanel import backend, cache
23from ubuntuone.controlpanel.logger import setup_logging23from ubuntuone.controlpanel.logger import setup_logging
24from ubuntuone.controlpanel.gui import (24from ubuntuone.controlpanel.gui import (
25<<<<<<< TREE
25 LOADING,26 LOADING,
26 OPEN_UBUNTU_ONE,27 OPEN_UBUNTU_ONE,
27 PLEASE_WAIT,28 PLEASE_WAIT,
@@ -37,6 +38,29 @@
3738
3839
39class TrayIcon(QtGui.QSystemTrayIcon, cache.Cache):40class TrayIcon(QtGui.QSystemTrayIcon, cache.Cache):
41=======
42 DASHBOARD,
43 GET_HELP_ONLINE,
44 GET_MORE_STORAGE,
45 GET_STORAGE_LINK,
46 GET_SUPPORT_LINK,
47 GO_TO_WEB,
48 LOADING,
49 OPEN_UBUNTU_ONE,
50 OPEN_UBUNTU_ONE_FOLDER,
51 PLEASE_WAIT,
52)
53from ubuntuone.controlpanel.gui.qt import (
54 FILE_SYNC_STATUS,
55 icon_from_name,
56)
57
58
59logger = setup_logging('qt.systray')
60
61
62class TrayIcon(QtGui.QSystemTrayIcon, cache.Cache):
63>>>>>>> MERGE-SOURCE
4064
41 """System notification icon."""65 """System notification icon."""
4266
@@ -45,10 +69,20 @@
45 self.setIcon(QtGui.QIcon(":/icon.png"))69 self.setIcon(QtGui.QIcon(":/icon.png"))
46 self.setVisible(True)70 self.setVisible(True)
47 self.window = window71 self.window = window
48 self._backend_method = None72<<<<<<< TREE
4973 self._backend_method = None
50 # Items74
75 # Items
76=======
77 self.root_path = ''
78 self.recent_transfers = {}
79 self.uploading = {}
80 self._backend_method = None
81
82 # Items
83>>>>>>> MERGE-SOURCE
51 self.context_menu = QtGui.QMenu()84 self.context_menu = QtGui.QMenu()
85<<<<<<< TREE
5286
53 self.status = self.context_menu.addAction(LOADING)87 self.status = self.context_menu.addAction(LOADING)
54 self.status.setEnabled(False)88 self.status.setEnabled(False)
@@ -61,56 +95,165 @@
6195
62 self.quit = self.context_menu.addAction(QUIT_LABEL)96 self.quit = self.context_menu.addAction(QUIT_LABEL)
6397
98=======
99
100 self.status = self.context_menu.addAction(LOADING)
101 self.status.setEnabled(False)
102 self.status_action = self.context_menu.addAction(PLEASE_WAIT)
103 self.refresh_status()
104 self.context_menu.addSeparator()
105
106 self.open_u1 = self.context_menu.addAction(OPEN_UBUNTU_ONE)
107 # TODO: Share a file action when the Shares tab is ready in U1-CP
108 self.open_u1_folder = self.context_menu.addAction(
109 OPEN_UBUNTU_ONE_FOLDER)
110 self.go_to_web = self.context_menu.addAction(GO_TO_WEB)
111 self.context_menu.addSeparator()
112
113 # TODO: Shares
114
115 # TODO: Transfers
116
117 self.get_more_storage = self.context_menu.addAction(GET_MORE_STORAGE)
118 self.get_help_online = self.context_menu.addAction(GET_HELP_ONLINE)
119 self.quit = self.context_menu.addAction("Quit")
120
121>>>>>>> MERGE-SOURCE
64 self.setContextMenu(self.context_menu)122 self.setContextMenu(self.context_menu)
65123
66 # Connect Signals124<<<<<<< TREE
67 self.status_action.triggered.connect(self.change_status)125 # Connect Signals
68 self.open_u1.triggered.connect(self.restore_window)126 self.status_action.triggered.connect(self.change_status)
69 self.quit.triggered.connect(self.stop)127 self.open_u1.triggered.connect(self.restore_window)
70128 self.quit.triggered.connect(self.stop)
129
130=======
131 # Connect Signals
132 self.status_action.triggered.connect(self.change_status)
133 self.open_u1.triggered.connect(self.restore_window)
134 self.open_u1_folder.triggered.connect(self.open_u1_folder_action)
135 self.get_more_storage.triggered.connect(self.get_more_storage_action)
136 self.go_to_web.triggered.connect(self.go_to_web_action)
137 self.get_help_online.triggered.connect(self.get_help_action)
138 self.quit.triggered.connect(self.stop)
139
140>>>>>>> MERGE-SOURCE
71 self.close_callback = close_callback141 self.close_callback = close_callback
72142<<<<<<< TREE
73 @inlineCallbacks143
74 def refresh_status(self):144 @inlineCallbacks
75 """Update Ubuntu One status."""145 def refresh_status(self):
76 info = yield self.backend.file_sync_status()146 """Update Ubuntu One status."""
77 self._process_status(info)147 info = yield self.backend.file_sync_status()
78 self.backend.status_changed_handler = self._process_status148 self._process_status(info)
79149 self.backend.status_changed_handler = self._process_status
80 def _process_status(self, status):150
81 """Match status with signals."""151 def _process_status(self, status):
82 if status is None:152 """Match status with signals."""
83 return153 if status is None:
84 try:154 return
85 status_key = status[backend.STATUS_KEY]155 try:
86 data = FILE_SYNC_STATUS[status_key]156 status_key = status[backend.STATUS_KEY]
87 except (KeyError, TypeError):157 data = FILE_SYNC_STATUS[status_key]
88 logger.exception(158 except (KeyError, TypeError):
89 '_process_status: received unknown status dict %r', status)159 logger.exception(
90 return160 '_process_status: received unknown status dict %r', status)
91161 return
92 self.status_action.setEnabled(True)162
93 icon_name = data.get('icon')163 self.status_action.setEnabled(True)
94 icon = QtGui.QIcon()164 icon_name = data.get('icon')
95 if icon_name is not None:165 icon = QtGui.QIcon()
96 icon = icon_from_name(icon_name)166 if icon_name is not None:
97 text = data.get('msg')167 icon = icon_from_name(icon_name)
98 self.status.setIcon(icon)168 text = data.get('msg')
99 self.status.setText(text)169 self.status.setIcon(icon)
100170 self.status.setText(text)
101 action = data.get('action')171
102 self._backend_method = getattr(self.backend,172 action = data.get('action')
103 data['backend_method'], None)173 self._backend_method = getattr(self.backend,
104 self.status_action.setText(action)174 data['backend_method'], None)
105175 self.status_action.setText(action)
106 def change_status(self):176
107 """Change the Syncing status of syncdaemon."""177 def change_status(self):
108 if self._backend_method is not None:178 """Change the Syncing status of syncdaemon."""
109 self.status_action.setEnabled(False)179 if self._backend_method is not None:
110 self._backend_method()180 self.status_action.setEnabled(False)
111 else:181 self._backend_method()
112 logger.error('on_sync_status_button_clicked: backend method is '182 else:
113 'None!')183 logger.error('on_sync_status_button_clicked: backend method is '
184 'None!')
185=======
186 self._get_volumes_info()
187
188 @inlineCallbacks
189 def refresh_status(self):
190 """Update Ubuntu One status."""
191 info = yield self.backend.file_sync_status()
192 self._process_status(info)
193 self.backend.status_changed_handler = self._process_status
194
195 def _process_status(self, status):
196 """Match status with signals."""
197 if status is None:
198 return
199 try:
200 status_key = status[backend.STATUS_KEY]
201 data = FILE_SYNC_STATUS[status_key]
202 except (KeyError, TypeError):
203 logger.exception(
204 '_process_status: received unknown status dict %r', status)
205 return
206
207 self.status_action.setEnabled(True)
208 icon_name = data.get('icon')
209 icon = QtGui.QIcon()
210 if icon_name is not None:
211 icon = icon_from_name(icon_name)
212 text = data.get('msg')
213 self.status.setIcon(icon)
214 self.status.setText(text)
215
216 action = data.get('action')
217 self._backend_method = getattr(self.backend,
218 data['backend_method'], None)
219 self.status_action.setText(action)
220
221 def change_status(self):
222 """Change the Syncing status of syncdaemon."""
223 if self._backend_method is not None:
224 self.status_action.setEnabled(False)
225 self._backend_method()
226 else:
227 logger.error('on_sync_status_button_clicked: backend method is '
228 'None!')
229
230 @inlineCallbacks
231 def _get_volumes_info(self):
232 """Get the volumes info."""
233 info = yield self.backend.volumes_info()
234 self._process_volumes_info(info)
235
236 def _process_volumes_info(self, info):
237 """Process the volumes info."""
238 _, _, volumes = info[0]
239 self.root_path = u'file://%s' % unicode(volumes[0]['path'])
240
241 def open_u1_folder_action(self):
242 """Open the web to get more storage."""
243 QtGui.QDesktopServices.openUrl(QtCore.QUrl(self.root_path))
244
245 def get_more_storage_action(self):
246 """Open the web to get more storage."""
247 QtGui.QDesktopServices.openUrl(QtCore.QUrl(GET_STORAGE_LINK))
248
249 def go_to_web_action(self):
250 """Open the web in the dashboard."""
251 QtGui.QDesktopServices.openUrl(QtCore.QUrl(DASHBOARD))
252
253 def get_help_action(self):
254 """Open the web in the dashboard."""
255 QtGui.QDesktopServices.openUrl(QtCore.QUrl(GET_SUPPORT_LINK))
256>>>>>>> MERGE-SOURCE
114257
115 def restore_window(self):258 def restore_window(self):
116 """Show the main window."""259 """Show the main window."""
117260
=== modified file 'ubuntuone/controlpanel/gui/qt/tests/test_systray.py'
--- ubuntuone/controlpanel/gui/qt/tests/test_systray.py 2012-08-10 20:01:40 +0000
+++ ubuntuone/controlpanel/gui/qt/tests/test_systray.py 2012-08-14 19:00:25 +0000
@@ -18,13 +18,27 @@
1818
19"""Tests for the notification area icon."""19"""Tests for the notification area icon."""
2020
21from PyQt4 import QtGui21from PyQt4 import QtGui, QtCore
22from twisted.internet.defer import inlineCallbacks22from twisted.internet.defer import inlineCallbacks
2323
24from ubuntuone.controlpanel.gui import qt24<<<<<<< TREE
25from ubuntuone.controlpanel.gui import qt
26=======
27import ubuntuone.controlpanel.gui.qt.gui
28from ubuntuone.controlpanel.gui import qt
29>>>>>>> MERGE-SOURCE
25from ubuntuone.controlpanel.gui.qt import systray30from ubuntuone.controlpanel.gui.qt import systray
31<<<<<<< TREE
26from ubuntuone.controlpanel.gui.qt.tests import BaseTestCase32from ubuntuone.controlpanel.gui.qt.tests import BaseTestCase
27import ubuntuone.controlpanel.gui.qt.gui33import ubuntuone.controlpanel.gui.qt.gui
34=======
35from ubuntuone.controlpanel.gui.qt.tests import BaseTestCase
36from ubuntuone.controlpanel.tests import ROOT_PATH
37
38
39# pylint: disable=C0103, W0212
40backend = systray.backend
41>>>>>>> MERGE-SOURCE
2842
2943
30backend = systray.backend # pylint: disable=C010344backend = systray.backend # pylint: disable=C0103
@@ -50,10 +64,28 @@
50 super(FakeMainWindow, self).__init__()64 super(FakeMainWindow, self).__init__()
5165
5266
53class SystrayTestCase(BaseTestCase):67<<<<<<< TREE
68class SystrayTestCase(BaseTestCase):
69=======
70class FakeDesktopService(object):
71
72 """Fake QDesktopService."""
73
74 data = {}
75
76 @classmethod
77 def openUrl(cls, url):
78 """Fake openUrl."""
79 FakeDesktopService.data['cls'] = cls
80 FakeDesktopService.data['url'] = url
81
82
83class SystrayTestCase(BaseTestCase):
84>>>>>>> MERGE-SOURCE
5485
55 """Test the notification area icon."""86 """Test the notification area icon."""
5687
88<<<<<<< TREE
57 class_ui = systray.TrayIcon89 class_ui = systray.TrayIcon
5890
59 # pylint: disable=W021291 # pylint: disable=W0212
@@ -182,6 +214,129 @@
182 self.assertTrue(data['called'])214 self.assertTrue(data['called'])
183 self.assertEqual(data['status'], [])215 self.assertEqual(data['status'], [])
184216
217=======
218 class_ui = systray.TrayIcon
219
220 @inlineCallbacks
221 def setUp(self):
222 yield super(SystrayTestCase, self).setUp()
223 self.patch(QtGui, "QDesktopServices", FakeDesktopService)
224
225 def assert_status_correct(self, status_bd, status_ui, action,
226 callback=None):
227 """The shown status is correct."""
228 expected_text = status_ui
229
230 status = {backend.STATUS_KEY: status_bd}
231 self.ui._process_status(status)
232
233 actual_text = unicode(self.ui.status.text())
234 self.assertEqual(expected_text, actual_text)
235
236 self.assertFalse(self.ui.status.isEnabled())
237 self.assertEqual(unicode(self.ui.status_action.text()), action)
238
239 self.ui.status_action.trigger()
240 self.assertFalse(self.ui.status_action.isEnabled())
241 self.assert_backend_called(callback)
242
243 def test_process_info_invalid_status(self):
244 """File sync status invalid, ignore event."""
245 status = {backend.STATUS_KEY: backend.FILE_SYNC_STARTING,
246 backend.MSG_KEY: qt.FILE_SYNC_STARTING,
247 'icon': backend.FILE_SYNC_STARTING}
248 self.ui._process_status(status)
249 self.ui._process_status(3)
250
251 actual_text = unicode(self.ui.status.text())
252 self.assertEqual(qt.FILE_SYNC_STARTING, actual_text)
253
254 def test_process_info_changed(self):
255 """Backend's file sync status changed callback is connected."""
256 self.ui.refresh_status()
257 self.assertEqual(self.ui.backend.status_changed_handler,
258 self.ui._process_status)
259
260 def test_process_info_disabled(self):
261 """File sync status disabled update the label."""
262 self.ui.refresh_status()
263 self.assert_status_correct(status_bd=backend.FILE_SYNC_DISABLED,
264 status_ui=qt.FILE_SYNC_DISABLED,
265 action=qt.FILE_SYNC_ENABLE,
266 callback='enable_files')
267
268 def test_process_info_disconnected(self):
269 """File sync status disconnected update the label."""
270 self.assert_status_correct(status_bd=backend.FILE_SYNC_DISCONNECTED,
271 status_ui=qt.FILE_SYNC_DISCONNECTED,
272 action=qt.FILE_SYNC_CONNECT,
273 callback='connect_files')
274
275 def test_process_info_error(self):
276 """File sync status error update the label."""
277 msg = qt.WARNING_MARKUP % qt.FILE_SYNC_ERROR
278 self.assert_status_correct(status_bd=backend.FILE_SYNC_ERROR,
279 status_ui=msg,
280 action=qt.FILE_SYNC_RESTART,
281 callback='restart_files')
282
283 def test_process_info_idle(self):
284 """File sync status idle update the label."""
285 self.assert_status_correct(status_bd=backend.FILE_SYNC_IDLE,
286 status_ui=qt.FILE_SYNC_IDLE,
287 action=qt.FILE_SYNC_DISCONNECT,
288 callback='disconnect_files')
289
290 def test_process_info_starting(self):
291 """File sync status starting update the label."""
292 self.assert_status_correct(status_bd=backend.FILE_SYNC_STARTING,
293 status_ui=qt.FILE_SYNC_STARTING,
294 action=qt.FILE_SYNC_STOP,
295 callback='stop_files')
296
297 def test_process_info_stopped(self):
298 """File sync status stopped update the label."""
299 self.assert_status_correct(status_bd=backend.FILE_SYNC_STOPPED,
300 status_ui=qt.FILE_SYNC_STOPPED,
301 action=qt.FILE_SYNC_START,
302 callback='start_files')
303
304 def test_process_info_syncing(self):
305 """File sync status syncing update the label."""
306 self.assert_status_correct(status_bd=backend.FILE_SYNC_SYNCING,
307 status_ui=qt.FILE_SYNC_SYNCING,
308 action=qt.FILE_SYNC_DISCONNECT,
309 callback='disconnect_files')
310
311 def test_process_info_unknown(self):
312 """File sync status unknown update the label."""
313 msg = qt.WARNING_MARKUP % qt.FILE_SYNC_ERROR
314 self.assert_status_correct(status_bd=backend.FILE_SYNC_UNKNOWN,
315 status_ui=msg,
316 action=qt.FILE_SYNC_RESTART,
317 callback='restart_files')
318
319 def test_backend(self):
320 """Backend is created."""
321 self.assertIsInstance(self.ui.backend,
322 backend.ControlBackend)
323
324 def test_refresh_status_requested(self):
325 """test refresh_status was requested on initialized."""
326 data = {}
327
328 def callback(status):
329 """Fake _process_status callback."""
330 data['called'] = True
331 data['status'] = status
332
333 self.patch(self.ui, "_process_status", callback)
334 self.ui.refresh_status()
335 self.assert_backend_called('file_sync_status')
336 self.assertTrue(data['called'])
337 self.assertEqual(data['status'], [])
338
339>>>>>>> MERGE-SOURCE
185 def test_quit(self):340 def test_quit(self):
186 """Test the quit option in the menu."""341 """Test the quit option in the menu."""
187 # Not done on setup, because if I patch stop342 # Not done on setup, because if I patch stop
@@ -249,13 +404,58 @@
249 tray.delete_window()404 tray.delete_window()
250 self.assertEqual(tray.window, None)405 self.assertEqual(tray.window, None)
251406
407 def test_open_u1_folder_action(self):
408 """Test open_u1_folder_action."""
409 self.ui.open_u1_folder.trigger()
410 self.assertEqual(FakeDesktopService.data['cls'], FakeDesktopService)
411 expected_url = QtCore.QUrl(u'file://%s' % ROOT_PATH)
412 self.assertEqual(FakeDesktopService.data['url'], expected_url)
413
414 def test_get_more_storage_action(self):
415 """Test get_more_storage."""
416 self.ui.get_more_storage.trigger()
417 self.assertEqual(FakeDesktopService.data['cls'], FakeDesktopService)
418 expected_url = QtCore.QUrl(systray.GET_STORAGE_LINK)
419 self.assertEqual(FakeDesktopService.data['url'], expected_url)
420
421 def test_go_to_web_action(self):
422 """Test go_to_web."""
423 self.ui.go_to_web.trigger()
424 self.assertEqual(FakeDesktopService.data['cls'], FakeDesktopService)
425 expected_url = QtCore.QUrl(systray.DASHBOARD)
426 self.assertEqual(FakeDesktopService.data['url'], expected_url)
427
428 def test_get_help_action(self):
429 """Test get_help_online."""
430 self.ui.get_help_online.trigger()
431 self.assertEqual(FakeDesktopService.data['cls'], FakeDesktopService)
432 expected_url = QtCore.QUrl(systray.GET_SUPPORT_LINK)
433 self.assertEqual(FakeDesktopService.data['url'], expected_url)
434
252 def test_initialization(self):435 def test_initialization(self):
253 """Test that everything initializes correctly."""436 """Test that everything initializes correctly."""
254 tray = systray.TrayIcon()437 tray = systray.TrayIcon()
255 self.assertTrue(tray.isVisible())438 self.assertTrue(tray.isVisible())
256 self.assertEqual(tray.window, None)439 self.assertEqual(tray.window, None)
440 self.assertNotEqual(tray.icon(), None)
441 self.assertEqual(tray.uploading, {})
442 self.assertEqual(tray.recent_transfers, {})
257 self.assertIsInstance(tray.context_menu, QtGui.QMenu)443 self.assertIsInstance(tray.context_menu, QtGui.QMenu)
444<<<<<<< TREE
258 self.assertIsInstance(tray.status, QtGui.QAction)445 self.assertIsInstance(tray.status, QtGui.QAction)
259 self.assertIsInstance(tray.status_action, QtGui.QAction)446 self.assertIsInstance(tray.status_action, QtGui.QAction)
260 self.assertIsInstance(tray.open_u1, QtGui.QAction)447 self.assertIsInstance(tray.open_u1, QtGui.QAction)
261 self.assertNotEqual(tray.icon(), None)448 self.assertNotEqual(tray.icon(), None)
449=======
450 self.assertIsInstance(tray.status, QtGui.QAction)
451 self.assertIsInstance(tray.status_action, QtGui.QAction)
452 self.assertIsInstance(tray.open_u1, QtGui.QAction)
453 self.assertIsInstance(tray.open_u1_folder, QtGui.QAction)
454 self.assertIsInstance(tray.go_to_web, QtGui.QAction)
455 self.assertIsInstance(tray.get_more_storage, QtGui.QAction)
456 self.assertIsInstance(tray.get_help_online, QtGui.QAction)
457 # This checks that _get_volumes_info and _process_volumes_info
458 # is being called correctly on initialization.
459 expected_home = u'file://%s' % ROOT_PATH
460 self.assertEqual(tray.root_path, expected_home)
461>>>>>>> MERGE-SOURCE

Subscribers

People subscribed via source and target branches