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
1=== modified file 'ubuntuone/controlpanel/gui/qt/systray.py'
2--- ubuntuone/controlpanel/gui/qt/systray.py 2012-08-13 12:08:15 +0000
3+++ ubuntuone/controlpanel/gui/qt/systray.py 2012-08-14 19:00:25 +0000
4@@ -15,13 +15,14 @@
5 # with this program. If not, see <http://www.gnu.org/licenses/>.
6 """System notification area icon."""
7
8-from PyQt4 import QtGui
9+from PyQt4 import QtGui, QtCore
10 from twisted.internet.defer import inlineCallbacks
11 from ubuntuone.platform.tools import SyncDaemonTool
12
13 from ubuntuone.controlpanel import backend, cache
14 from ubuntuone.controlpanel.logger import setup_logging
15 from ubuntuone.controlpanel.gui import (
16+<<<<<<< TREE
17 LOADING,
18 OPEN_UBUNTU_ONE,
19 PLEASE_WAIT,
20@@ -37,6 +38,29 @@
21
22
23 class TrayIcon(QtGui.QSystemTrayIcon, cache.Cache):
24+=======
25+ DASHBOARD,
26+ GET_HELP_ONLINE,
27+ GET_MORE_STORAGE,
28+ GET_STORAGE_LINK,
29+ GET_SUPPORT_LINK,
30+ GO_TO_WEB,
31+ LOADING,
32+ OPEN_UBUNTU_ONE,
33+ OPEN_UBUNTU_ONE_FOLDER,
34+ PLEASE_WAIT,
35+)
36+from ubuntuone.controlpanel.gui.qt import (
37+ FILE_SYNC_STATUS,
38+ icon_from_name,
39+)
40+
41+
42+logger = setup_logging('qt.systray')
43+
44+
45+class TrayIcon(QtGui.QSystemTrayIcon, cache.Cache):
46+>>>>>>> MERGE-SOURCE
47
48 """System notification icon."""
49
50@@ -45,10 +69,20 @@
51 self.setIcon(QtGui.QIcon(":/icon.png"))
52 self.setVisible(True)
53 self.window = window
54- self._backend_method = None
55-
56- # Items
57+<<<<<<< TREE
58+ self._backend_method = None
59+
60+ # Items
61+=======
62+ self.root_path = ''
63+ self.recent_transfers = {}
64+ self.uploading = {}
65+ self._backend_method = None
66+
67+ # Items
68+>>>>>>> MERGE-SOURCE
69 self.context_menu = QtGui.QMenu()
70+<<<<<<< TREE
71
72 self.status = self.context_menu.addAction(LOADING)
73 self.status.setEnabled(False)
74@@ -61,56 +95,165 @@
75
76 self.quit = self.context_menu.addAction(QUIT_LABEL)
77
78+=======
79+
80+ self.status = self.context_menu.addAction(LOADING)
81+ self.status.setEnabled(False)
82+ self.status_action = self.context_menu.addAction(PLEASE_WAIT)
83+ self.refresh_status()
84+ self.context_menu.addSeparator()
85+
86+ self.open_u1 = self.context_menu.addAction(OPEN_UBUNTU_ONE)
87+ # TODO: Share a file action when the Shares tab is ready in U1-CP
88+ self.open_u1_folder = self.context_menu.addAction(
89+ OPEN_UBUNTU_ONE_FOLDER)
90+ self.go_to_web = self.context_menu.addAction(GO_TO_WEB)
91+ self.context_menu.addSeparator()
92+
93+ # TODO: Shares
94+
95+ # TODO: Transfers
96+
97+ self.get_more_storage = self.context_menu.addAction(GET_MORE_STORAGE)
98+ self.get_help_online = self.context_menu.addAction(GET_HELP_ONLINE)
99+ self.quit = self.context_menu.addAction("Quit")
100+
101+>>>>>>> MERGE-SOURCE
102 self.setContextMenu(self.context_menu)
103
104- # Connect Signals
105- self.status_action.triggered.connect(self.change_status)
106- self.open_u1.triggered.connect(self.restore_window)
107- self.quit.triggered.connect(self.stop)
108-
109+<<<<<<< TREE
110+ # Connect Signals
111+ self.status_action.triggered.connect(self.change_status)
112+ self.open_u1.triggered.connect(self.restore_window)
113+ self.quit.triggered.connect(self.stop)
114+
115+=======
116+ # Connect Signals
117+ self.status_action.triggered.connect(self.change_status)
118+ self.open_u1.triggered.connect(self.restore_window)
119+ self.open_u1_folder.triggered.connect(self.open_u1_folder_action)
120+ self.get_more_storage.triggered.connect(self.get_more_storage_action)
121+ self.go_to_web.triggered.connect(self.go_to_web_action)
122+ self.get_help_online.triggered.connect(self.get_help_action)
123+ self.quit.triggered.connect(self.stop)
124+
125+>>>>>>> MERGE-SOURCE
126 self.close_callback = close_callback
127-
128- @inlineCallbacks
129- def refresh_status(self):
130- """Update Ubuntu One status."""
131- info = yield self.backend.file_sync_status()
132- self._process_status(info)
133- self.backend.status_changed_handler = self._process_status
134-
135- def _process_status(self, status):
136- """Match status with signals."""
137- if status is None:
138- return
139- try:
140- status_key = status[backend.STATUS_KEY]
141- data = FILE_SYNC_STATUS[status_key]
142- except (KeyError, TypeError):
143- logger.exception(
144- '_process_status: received unknown status dict %r', status)
145- return
146-
147- self.status_action.setEnabled(True)
148- icon_name = data.get('icon')
149- icon = QtGui.QIcon()
150- if icon_name is not None:
151- icon = icon_from_name(icon_name)
152- text = data.get('msg')
153- self.status.setIcon(icon)
154- self.status.setText(text)
155-
156- action = data.get('action')
157- self._backend_method = getattr(self.backend,
158- data['backend_method'], None)
159- self.status_action.setText(action)
160-
161- def change_status(self):
162- """Change the Syncing status of syncdaemon."""
163- if self._backend_method is not None:
164- self.status_action.setEnabled(False)
165- self._backend_method()
166- else:
167- logger.error('on_sync_status_button_clicked: backend method is '
168- 'None!')
169+<<<<<<< TREE
170+
171+ @inlineCallbacks
172+ def refresh_status(self):
173+ """Update Ubuntu One status."""
174+ info = yield self.backend.file_sync_status()
175+ self._process_status(info)
176+ self.backend.status_changed_handler = self._process_status
177+
178+ def _process_status(self, status):
179+ """Match status with signals."""
180+ if status is None:
181+ return
182+ try:
183+ status_key = status[backend.STATUS_KEY]
184+ data = FILE_SYNC_STATUS[status_key]
185+ except (KeyError, TypeError):
186+ logger.exception(
187+ '_process_status: received unknown status dict %r', status)
188+ return
189+
190+ self.status_action.setEnabled(True)
191+ icon_name = data.get('icon')
192+ icon = QtGui.QIcon()
193+ if icon_name is not None:
194+ icon = icon_from_name(icon_name)
195+ text = data.get('msg')
196+ self.status.setIcon(icon)
197+ self.status.setText(text)
198+
199+ action = data.get('action')
200+ self._backend_method = getattr(self.backend,
201+ data['backend_method'], None)
202+ self.status_action.setText(action)
203+
204+ def change_status(self):
205+ """Change the Syncing status of syncdaemon."""
206+ if self._backend_method is not None:
207+ self.status_action.setEnabled(False)
208+ self._backend_method()
209+ else:
210+ logger.error('on_sync_status_button_clicked: backend method is '
211+ 'None!')
212+=======
213+ self._get_volumes_info()
214+
215+ @inlineCallbacks
216+ def refresh_status(self):
217+ """Update Ubuntu One status."""
218+ info = yield self.backend.file_sync_status()
219+ self._process_status(info)
220+ self.backend.status_changed_handler = self._process_status
221+
222+ def _process_status(self, status):
223+ """Match status with signals."""
224+ if status is None:
225+ return
226+ try:
227+ status_key = status[backend.STATUS_KEY]
228+ data = FILE_SYNC_STATUS[status_key]
229+ except (KeyError, TypeError):
230+ logger.exception(
231+ '_process_status: received unknown status dict %r', status)
232+ return
233+
234+ self.status_action.setEnabled(True)
235+ icon_name = data.get('icon')
236+ icon = QtGui.QIcon()
237+ if icon_name is not None:
238+ icon = icon_from_name(icon_name)
239+ text = data.get('msg')
240+ self.status.setIcon(icon)
241+ self.status.setText(text)
242+
243+ action = data.get('action')
244+ self._backend_method = getattr(self.backend,
245+ data['backend_method'], None)
246+ self.status_action.setText(action)
247+
248+ def change_status(self):
249+ """Change the Syncing status of syncdaemon."""
250+ if self._backend_method is not None:
251+ self.status_action.setEnabled(False)
252+ self._backend_method()
253+ else:
254+ logger.error('on_sync_status_button_clicked: backend method is '
255+ 'None!')
256+
257+ @inlineCallbacks
258+ def _get_volumes_info(self):
259+ """Get the volumes info."""
260+ info = yield self.backend.volumes_info()
261+ self._process_volumes_info(info)
262+
263+ def _process_volumes_info(self, info):
264+ """Process the volumes info."""
265+ _, _, volumes = info[0]
266+ self.root_path = u'file://%s' % unicode(volumes[0]['path'])
267+
268+ def open_u1_folder_action(self):
269+ """Open the web to get more storage."""
270+ QtGui.QDesktopServices.openUrl(QtCore.QUrl(self.root_path))
271+
272+ def get_more_storage_action(self):
273+ """Open the web to get more storage."""
274+ QtGui.QDesktopServices.openUrl(QtCore.QUrl(GET_STORAGE_LINK))
275+
276+ def go_to_web_action(self):
277+ """Open the web in the dashboard."""
278+ QtGui.QDesktopServices.openUrl(QtCore.QUrl(DASHBOARD))
279+
280+ def get_help_action(self):
281+ """Open the web in the dashboard."""
282+ QtGui.QDesktopServices.openUrl(QtCore.QUrl(GET_SUPPORT_LINK))
283+>>>>>>> MERGE-SOURCE
284
285 def restore_window(self):
286 """Show the main window."""
287
288=== modified file 'ubuntuone/controlpanel/gui/qt/tests/test_systray.py'
289--- ubuntuone/controlpanel/gui/qt/tests/test_systray.py 2012-08-10 20:01:40 +0000
290+++ ubuntuone/controlpanel/gui/qt/tests/test_systray.py 2012-08-14 19:00:25 +0000
291@@ -18,13 +18,27 @@
292
293 """Tests for the notification area icon."""
294
295-from PyQt4 import QtGui
296+from PyQt4 import QtGui, QtCore
297 from twisted.internet.defer import inlineCallbacks
298
299-from ubuntuone.controlpanel.gui import qt
300+<<<<<<< TREE
301+from ubuntuone.controlpanel.gui import qt
302+=======
303+import ubuntuone.controlpanel.gui.qt.gui
304+from ubuntuone.controlpanel.gui import qt
305+>>>>>>> MERGE-SOURCE
306 from ubuntuone.controlpanel.gui.qt import systray
307+<<<<<<< TREE
308 from ubuntuone.controlpanel.gui.qt.tests import BaseTestCase
309 import ubuntuone.controlpanel.gui.qt.gui
310+=======
311+from ubuntuone.controlpanel.gui.qt.tests import BaseTestCase
312+from ubuntuone.controlpanel.tests import ROOT_PATH
313+
314+
315+# pylint: disable=C0103, W0212
316+backend = systray.backend
317+>>>>>>> MERGE-SOURCE
318
319
320 backend = systray.backend # pylint: disable=C0103
321@@ -50,10 +64,28 @@
322 super(FakeMainWindow, self).__init__()
323
324
325-class SystrayTestCase(BaseTestCase):
326+<<<<<<< TREE
327+class SystrayTestCase(BaseTestCase):
328+=======
329+class FakeDesktopService(object):
330+
331+ """Fake QDesktopService."""
332+
333+ data = {}
334+
335+ @classmethod
336+ def openUrl(cls, url):
337+ """Fake openUrl."""
338+ FakeDesktopService.data['cls'] = cls
339+ FakeDesktopService.data['url'] = url
340+
341+
342+class SystrayTestCase(BaseTestCase):
343+>>>>>>> MERGE-SOURCE
344
345 """Test the notification area icon."""
346
347+<<<<<<< TREE
348 class_ui = systray.TrayIcon
349
350 # pylint: disable=W0212
351@@ -182,6 +214,129 @@
352 self.assertTrue(data['called'])
353 self.assertEqual(data['status'], [])
354
355+=======
356+ class_ui = systray.TrayIcon
357+
358+ @inlineCallbacks
359+ def setUp(self):
360+ yield super(SystrayTestCase, self).setUp()
361+ self.patch(QtGui, "QDesktopServices", FakeDesktopService)
362+
363+ def assert_status_correct(self, status_bd, status_ui, action,
364+ callback=None):
365+ """The shown status is correct."""
366+ expected_text = status_ui
367+
368+ status = {backend.STATUS_KEY: status_bd}
369+ self.ui._process_status(status)
370+
371+ actual_text = unicode(self.ui.status.text())
372+ self.assertEqual(expected_text, actual_text)
373+
374+ self.assertFalse(self.ui.status.isEnabled())
375+ self.assertEqual(unicode(self.ui.status_action.text()), action)
376+
377+ self.ui.status_action.trigger()
378+ self.assertFalse(self.ui.status_action.isEnabled())
379+ self.assert_backend_called(callback)
380+
381+ def test_process_info_invalid_status(self):
382+ """File sync status invalid, ignore event."""
383+ status = {backend.STATUS_KEY: backend.FILE_SYNC_STARTING,
384+ backend.MSG_KEY: qt.FILE_SYNC_STARTING,
385+ 'icon': backend.FILE_SYNC_STARTING}
386+ self.ui._process_status(status)
387+ self.ui._process_status(3)
388+
389+ actual_text = unicode(self.ui.status.text())
390+ self.assertEqual(qt.FILE_SYNC_STARTING, actual_text)
391+
392+ def test_process_info_changed(self):
393+ """Backend's file sync status changed callback is connected."""
394+ self.ui.refresh_status()
395+ self.assertEqual(self.ui.backend.status_changed_handler,
396+ self.ui._process_status)
397+
398+ def test_process_info_disabled(self):
399+ """File sync status disabled update the label."""
400+ self.ui.refresh_status()
401+ self.assert_status_correct(status_bd=backend.FILE_SYNC_DISABLED,
402+ status_ui=qt.FILE_SYNC_DISABLED,
403+ action=qt.FILE_SYNC_ENABLE,
404+ callback='enable_files')
405+
406+ def test_process_info_disconnected(self):
407+ """File sync status disconnected update the label."""
408+ self.assert_status_correct(status_bd=backend.FILE_SYNC_DISCONNECTED,
409+ status_ui=qt.FILE_SYNC_DISCONNECTED,
410+ action=qt.FILE_SYNC_CONNECT,
411+ callback='connect_files')
412+
413+ def test_process_info_error(self):
414+ """File sync status error update the label."""
415+ msg = qt.WARNING_MARKUP % qt.FILE_SYNC_ERROR
416+ self.assert_status_correct(status_bd=backend.FILE_SYNC_ERROR,
417+ status_ui=msg,
418+ action=qt.FILE_SYNC_RESTART,
419+ callback='restart_files')
420+
421+ def test_process_info_idle(self):
422+ """File sync status idle update the label."""
423+ self.assert_status_correct(status_bd=backend.FILE_SYNC_IDLE,
424+ status_ui=qt.FILE_SYNC_IDLE,
425+ action=qt.FILE_SYNC_DISCONNECT,
426+ callback='disconnect_files')
427+
428+ def test_process_info_starting(self):
429+ """File sync status starting update the label."""
430+ self.assert_status_correct(status_bd=backend.FILE_SYNC_STARTING,
431+ status_ui=qt.FILE_SYNC_STARTING,
432+ action=qt.FILE_SYNC_STOP,
433+ callback='stop_files')
434+
435+ def test_process_info_stopped(self):
436+ """File sync status stopped update the label."""
437+ self.assert_status_correct(status_bd=backend.FILE_SYNC_STOPPED,
438+ status_ui=qt.FILE_SYNC_STOPPED,
439+ action=qt.FILE_SYNC_START,
440+ callback='start_files')
441+
442+ def test_process_info_syncing(self):
443+ """File sync status syncing update the label."""
444+ self.assert_status_correct(status_bd=backend.FILE_SYNC_SYNCING,
445+ status_ui=qt.FILE_SYNC_SYNCING,
446+ action=qt.FILE_SYNC_DISCONNECT,
447+ callback='disconnect_files')
448+
449+ def test_process_info_unknown(self):
450+ """File sync status unknown update the label."""
451+ msg = qt.WARNING_MARKUP % qt.FILE_SYNC_ERROR
452+ self.assert_status_correct(status_bd=backend.FILE_SYNC_UNKNOWN,
453+ status_ui=msg,
454+ action=qt.FILE_SYNC_RESTART,
455+ callback='restart_files')
456+
457+ def test_backend(self):
458+ """Backend is created."""
459+ self.assertIsInstance(self.ui.backend,
460+ backend.ControlBackend)
461+
462+ def test_refresh_status_requested(self):
463+ """test refresh_status was requested on initialized."""
464+ data = {}
465+
466+ def callback(status):
467+ """Fake _process_status callback."""
468+ data['called'] = True
469+ data['status'] = status
470+
471+ self.patch(self.ui, "_process_status", callback)
472+ self.ui.refresh_status()
473+ self.assert_backend_called('file_sync_status')
474+ self.assertTrue(data['called'])
475+ self.assertEqual(data['status'], [])
476+
477+>>>>>>> MERGE-SOURCE
478 def test_quit(self):
479 """Test the quit option in the menu."""
480 # Not done on setup, because if I patch stop
481@@ -249,13 +404,58 @@
482 tray.delete_window()
483 self.assertEqual(tray.window, None)
484
485+ def test_open_u1_folder_action(self):
486+ """Test open_u1_folder_action."""
487+ self.ui.open_u1_folder.trigger()
488+ self.assertEqual(FakeDesktopService.data['cls'], FakeDesktopService)
489+ expected_url = QtCore.QUrl(u'file://%s' % ROOT_PATH)
490+ self.assertEqual(FakeDesktopService.data['url'], expected_url)
491+
492+ def test_get_more_storage_action(self):
493+ """Test get_more_storage."""
494+ self.ui.get_more_storage.trigger()
495+ self.assertEqual(FakeDesktopService.data['cls'], FakeDesktopService)
496+ expected_url = QtCore.QUrl(systray.GET_STORAGE_LINK)
497+ self.assertEqual(FakeDesktopService.data['url'], expected_url)
498+
499+ def test_go_to_web_action(self):
500+ """Test go_to_web."""
501+ self.ui.go_to_web.trigger()
502+ self.assertEqual(FakeDesktopService.data['cls'], FakeDesktopService)
503+ expected_url = QtCore.QUrl(systray.DASHBOARD)
504+ self.assertEqual(FakeDesktopService.data['url'], expected_url)
505+
506+ def test_get_help_action(self):
507+ """Test get_help_online."""
508+ self.ui.get_help_online.trigger()
509+ self.assertEqual(FakeDesktopService.data['cls'], FakeDesktopService)
510+ expected_url = QtCore.QUrl(systray.GET_SUPPORT_LINK)
511+ self.assertEqual(FakeDesktopService.data['url'], expected_url)
512+
513 def test_initialization(self):
514 """Test that everything initializes correctly."""
515 tray = systray.TrayIcon()
516 self.assertTrue(tray.isVisible())
517 self.assertEqual(tray.window, None)
518+ self.assertNotEqual(tray.icon(), None)
519+ self.assertEqual(tray.uploading, {})
520+ self.assertEqual(tray.recent_transfers, {})
521 self.assertIsInstance(tray.context_menu, QtGui.QMenu)
522+<<<<<<< TREE
523 self.assertIsInstance(tray.status, QtGui.QAction)
524 self.assertIsInstance(tray.status_action, QtGui.QAction)
525 self.assertIsInstance(tray.open_u1, QtGui.QAction)
526 self.assertNotEqual(tray.icon(), None)
527+=======
528+ self.assertIsInstance(tray.status, QtGui.QAction)
529+ self.assertIsInstance(tray.status_action, QtGui.QAction)
530+ self.assertIsInstance(tray.open_u1, QtGui.QAction)
531+ self.assertIsInstance(tray.open_u1_folder, QtGui.QAction)
532+ self.assertIsInstance(tray.go_to_web, QtGui.QAction)
533+ self.assertIsInstance(tray.get_more_storage, QtGui.QAction)
534+ self.assertIsInstance(tray.get_help_online, QtGui.QAction)
535+ # This checks that _get_volumes_info and _process_volumes_info
536+ # is being called correctly on initialization.
537+ expected_home = u'file://%s' % ROOT_PATH
538+ self.assertEqual(tray.root_path, expected_home)
539+>>>>>>> MERGE-SOURCE

Subscribers

People subscribed via source and target branches