Merge lp:~facundo/magicicada-client/remove-sync-menu into lp:magicicada-client

Proposed by Facundo Batista
Status: Merged
Approved by: Natalia Bidart
Approved revision: 1445
Merged at revision: 1444
Proposed branch: lp:~facundo/magicicada-client/remove-sync-menu
Merge into: lp:magicicada-client
Diff against target: 1535 lines (+23/-1209)
17 files modified
contrib/testing/testcase.py (+9/-18)
setup.py (+0/-1)
ubuntuone/clientdefs.py.in (+2/-11)
ubuntuone/platform/ipc/ipc_client.py (+1/-16)
ubuntuone/platform/ipc/linux.py (+1/-33)
ubuntuone/platform/ipc/perspective_broker.py (+1/-5)
ubuntuone/platform/sync_menu/__init__.py (+0/-41)
ubuntuone/platform/sync_menu/common.py (+0/-41)
ubuntuone/platform/sync_menu/linux.py (+0/-330)
ubuntuone/platform/tests/ipc/test_external_interface.py (+2/-15)
ubuntuone/platform/tests/sync_menu/__init__.py (+0/-27)
ubuntuone/platform/tests/sync_menu/test_common.py (+0/-54)
ubuntuone/platform/tests/sync_menu/test_linux.py (+0/-586)
ubuntuone/platform/tests/test_tools.py (+5/-13)
ubuntuone/platform/tools/__init__.py (+1/-7)
ubuntuone/syncdaemon/__init__.py (+1/-7)
ubuntuone/syncdaemon/interaction_interfaces.py (+0/-4)
To merge this branch: bzr merge lp:~facundo/magicicada-client/remove-sync-menu
Reviewer Review Type Date Requested Status
Natalia Bidart Approve
Review via email: mp+343773@code.launchpad.net

Commit message

Remove SyncMenu traces - no more UI client except Magicicada own shiny thing.

To post a comment you must log in.
1444. By Facundo Batista

Removed more unused constants.

1445. By Facundo Batista

Merged trunk in.

Revision history for this message
Natalia Bidart (nataliabidart) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'contrib/testing/testcase.py'
2--- contrib/testing/testcase.py 2018-03-14 21:01:56 +0000
3+++ contrib/testing/testcase.py 2018-04-24 23:14:39 +0000
4@@ -58,8 +58,6 @@
5 main,
6 local_rescan,
7 tritcask,
8- RECENT_TRANSFERS,
9- UPLOADING,
10 )
11 from ubuntuone.syncdaemon import logger
12 from ubuntuone import platform
13@@ -78,6 +76,10 @@
14 'password': 'test_password'}
15
16
17+def NOOP(*a, **kw):
18+ """Do nothing."""
19+
20+
21 @contextlib.contextmanager
22 def environ(env_var, new_value):
23 """context manager to replace/add an environ value"""
24@@ -190,14 +192,6 @@
25 node_is_with_queued_move = cleanup = get_public_files = disconnect
26
27
28-class FakeStatusListener(object):
29- """A fake StatusListener."""
30-
31- def menu_data(self):
32- """Fake menu_data."""
33- return {RECENT_TRANSFERS: [], UPLOADING: []}
34-
35-
36 class FakeMonitor(object):
37 """A fake FilesystemMonitor."""
38
39@@ -259,8 +253,8 @@
40 self.vm = volume_manager.VolumeManager(self)
41 self.fs = fs_manager.FileSystemManager(
42 self.data_dir, self.partials_dir, self.vm, self.db)
43- self.event_q = event_queue.EventQueue(self.fs,
44- monitor_class=self._monitor_class)
45+ self.event_q = event_queue.EventQueue(
46+ self.fs, monitor_class=self._monitor_class)
47 self.fs.register_eq(self.event_q)
48 self.action_q = self._fake_AQ_class(self.event_q, self,
49 *self._fake_AQ_params)
50@@ -275,8 +269,6 @@
51 self.lr = local_rescan.LocalRescan(self.vm, self.fs,
52 self.event_q, self.action_q)
53
54- self.status_listener = FakeStatusListener()
55-
56 def _connect_aq(self, _):
57 """Connect the fake action queue."""
58 self.action_q.connect()
59@@ -408,9 +400,8 @@
60 self.patch(platform, "user_home", self.home_dir)
61
62 # use the config from the branch
63- new_get_config_files = lambda: [os.path.join(os.environ['ROOTDIR'],
64- 'data', 'syncdaemon.conf')]
65- self.patch(config, 'get_config_files', new_get_config_files)
66+ self.patch(config, 'get_config_files', lambda: [
67+ os.path.join(os.environ['ROOTDIR'], 'data', 'syncdaemon.conf')])
68
69 # fake a very basic config file with sane defaults for the tests
70 config_dir = self.mktemp('config')
71@@ -626,7 +617,7 @@
72 try:
73 result = super(FakedObject, self).__getattribute__(attr_name)
74 except AttributeError:
75- result = lambda *a, **kw: None
76+ result = NOOP
77 super(FakedObject, self).__setattr__(attr_name, result)
78
79 if attr_name == '_called':
80
81=== modified file 'setup.py'
82--- setup.py 2018-03-14 21:01:56 +0000
83+++ setup.py 2018-04-24 23:14:39 +0000
84@@ -71,7 +71,6 @@
85 with open(fname, 'w') as out_file:
86 content = content.replace('@VERSION@', VERSION)
87 content = content.replace('@PROJECT_NAME@', PROJECT_NAME)
88- content = content.replace('@GETTEXT_PACKAGE@', PROJECT_NAME)
89 content = content.replace('@LOG_LEVEL@', LOG_LEVEL)
90 content = content.replace('@LOG_FILE_SIZE@', LOG_FILE_SIZE)
91 if prefix is not None:
92
93=== modified file 'ubuntuone/clientdefs.py.in'
94--- ubuntuone/clientdefs.py.in 2016-06-04 23:41:52 +0000
95+++ ubuntuone/clientdefs.py.in 2018-04-24 23:14:39 +0000
96@@ -1,8 +1,5 @@
97-# ubuntuone.clientdefs - Configure-time definitions
98-#
99-# Author: David Planella <david.planella@ubuntu.com>
100-#
101 # Copyright 2009-2012 Canonical Ltd.
102+# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
103 #
104 # This program is free software: you can redistribute it and/or modify it
105 # under the terms of the GNU General Public License version 3, as published
106@@ -30,7 +27,6 @@
107 # files in the program, then also delete it here.
108 """Configure-time definitions for the client."""
109
110-import gettext
111 import os
112 import platform
113 import urllib
114@@ -39,16 +35,11 @@
115 VERSION = "@VERSION@"
116 LOCALEDIR = "@localedir@"
117 LIBEXECDIR = "@libexecdir@"
118-GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@"
119-PROJECT_NAME = "@GETTEXT_PACKAGE@"
120+PROJECT_NAME = "@PROJECT_NAME@"
121 PROJECT_DIR = os.path.join('@prefix@', 'share', PROJECT_NAME)
122 BIN_DIR = os.path.join('@prefix@', 'lib', PROJECT_NAME)
123
124
125-def Q_(string):
126- return gettext.dgettext(GETTEXT_PACKAGE, string)
127-
128-
129 def platform_data():
130 result = {'platform': platform.system(),
131 'platform_version': platform.release(),
132
133=== modified file 'ubuntuone/platform/ipc/ipc_client.py'
134--- ubuntuone/platform/ipc/ipc_client.py 2016-09-17 01:06:23 +0000
135+++ ubuntuone/platform/ipc/ipc_client.py 2018-04-24 23:14:39 +0000
136@@ -1,6 +1,7 @@
137 # -*- coding: utf-8 -*-
138 #
139 # Copyright 2011-2012 Canonical Ltd.
140+# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
141 #
142 # This program is free software: you can redistribute it and/or modify it
143 # under the terms of the GNU General Public License version 3, as published
144@@ -197,22 +198,6 @@
145 def current_uploads(self):
146 """Return a list of files with a upload in progress."""
147
148- @remote
149- def sync_menu(self):
150- """
151- This method returns a dictionary, with the following keys and values:
152-
153- Key: 'recent-transfers'
154- Value: a list of strings (paths), each being the name of a file that
155- was recently transferred.
156-
157- Key: 'uploading'
158- Value: a list of tuples, with each tuple having the following items:
159- * str: the path of a file that's currently being uploaded
160- * int: size of the file
161- * int: bytes written
162- """
163-
164 @signal
165 def on_content_queue_changed(self):
166 """Emit ContentQueueChanged."""
167
168=== modified file 'ubuntuone/platform/ipc/linux.py'
169--- ubuntuone/platform/ipc/linux.py 2016-09-17 01:06:23 +0000
170+++ ubuntuone/platform/ipc/linux.py 2018-04-24 23:14:39 +0000
171@@ -1,6 +1,7 @@
172 # -*- coding: utf-8 -*-
173 #
174 # Copyright 2009-2012 Canonical Ltd.
175+# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
176 #
177 # This program is free software: you can redistribute it and/or modify it
178 # under the terms of the GNU General Public License version 3, as published
179@@ -38,10 +39,6 @@
180 from xml.etree import ElementTree
181
182 from ubuntuone.platform import launcher
183-from ubuntuone.syncdaemon import (
184- RECENT_TRANSFERS,
185- UPLOADING,
186-)
187
188 # Disable the "Invalid Name" check here, as we have lots of DBus style names
189
190@@ -176,35 +173,6 @@
191 warnings.warn('Use "waiting" method instead.', DeprecationWarning)
192 return self.service.status.waiting_content()
193
194- @dbus.service.method(DBUS_IFACE_STATUS_NAME, out_signature='a{sv}')
195- def sync_menu(self):
196- """
197- This method returns a dictionary, with the following keys and values:
198-
199- Key: 'recent-transfers'
200- Value: a list of strings (paths), each being the name of a file that
201- was recently transferred.
202-
203- Key: 'uploading'
204- Value: a list of tuples, with each tuple having the following items:
205- * str: the path of a file that's currently being uploaded
206- * int: size of the file
207- * int: bytes written
208- """
209- data = self.service.status.sync_menu()
210- uploading = data[UPLOADING]
211- transfers = data[RECENT_TRANSFERS]
212- upload_data = dbus.Array(signature="(sii)")
213- transfer_data = dbus.Array(signature="s")
214- for up in uploading:
215- upload_data.append(dbus.Struct(up, signature="sii"))
216- for transfer in transfers:
217- transfer_data.append(transfer)
218- result = dbus.Dictionary(signature="sv")
219- result[UPLOADING] = upload_data
220- result[RECENT_TRANSFERS] = transfer_data
221- return result
222-
223 @dbus.service.signal(DBUS_IFACE_STATUS_NAME)
224 def DownloadStarted(self, path):
225 """Fire a signal to notify that a download has started."""
226
227=== modified file 'ubuntuone/platform/ipc/perspective_broker.py'
228--- ubuntuone/platform/ipc/perspective_broker.py 2016-09-17 01:06:23 +0000
229+++ ubuntuone/platform/ipc/perspective_broker.py 2018-04-24 23:14:39 +0000
230@@ -1,6 +1,7 @@
231 # -*- coding: utf-8 -*-
232 #
233 # Copyright 2011-2012 Canonical Ltd.
234+# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
235 #
236 # This program is free software: you can redistribute it and/or modify it
237 # under the terms of the GNU General Public License version 3, as published
238@@ -235,7 +236,6 @@
239 'waiting',
240 'waiting_metadata',
241 'waiting_content',
242- 'sync_menu',
243 ]
244
245 signal_mapping = {
246@@ -296,10 +296,6 @@
247 warnings.warn('Use "waiting" method instead.', DeprecationWarning)
248 return self.service.status.waiting_content()
249
250- def sync_menu(self):
251- """Return the info necessary to construct the menu."""
252- return self.service.status.sync_menu()
253-
254 @signal
255 def DownloadStarted(self, path):
256 """Fire a signal to notify that a download has started."""
257
258=== removed directory 'ubuntuone/platform/sync_menu'
259=== removed file 'ubuntuone/platform/sync_menu/__init__.py'
260--- ubuntuone/platform/sync_menu/__init__.py 2012-09-18 16:28:28 +0000
261+++ ubuntuone/platform/sync_menu/__init__.py 1970-01-01 00:00:00 +0000
262@@ -1,41 +0,0 @@
263-# -*- coding: utf-8 *-*
264-#
265-# Copyright 2012 Canonical Ltd.
266-#
267-# This program is free software: you can redistribute it and/or modify it
268-# under the terms of the GNU General Public License version 3, as published
269-# by the Free Software Foundation.
270-#
271-# This program is distributed in the hope that it will be useful, but
272-# WITHOUT ANY WARRANTY; without even the implied warranties of
273-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
274-# PURPOSE. See the GNU General Public License for more details.
275-#
276-# You should have received a copy of the GNU General Public License along
277-# with this program. If not, see <http://www.gnu.org/licenses/>.
278-#
279-# In addition, as a special exception, the copyright holders give
280-# permission to link the code of portions of this program with the
281-# OpenSSL library under certain conditions as described in each
282-# individual source file, and distribute linked combinations
283-# including the two.
284-# You must obey the GNU General Public License in all respects
285-# for all of the code used other than OpenSSL. If you modify
286-# file(s) with this exception, you may extend this exception to your
287-# version of the file(s), but you are not obligated to do so. If you
288-# do not wish to do so, delete this exception statement from your
289-# version. If you delete this exception statement from all source
290-# files in the program, then also delete it here.
291-"""Use SyncMenu lib to integrate U1 with the Systray Sync Icon."""
292-
293-import sys
294-
295-
296-if sys.platform in ("win32", "darwin"):
297- from ubuntuone.platform.sync_menu import common
298- source = common
299-else:
300- from ubuntuone.platform.sync_menu import linux
301- source = linux
302-
303-UbuntuOneSyncMenu = source.UbuntuOneSyncMenu
304
305=== removed file 'ubuntuone/platform/sync_menu/common.py'
306--- ubuntuone/platform/sync_menu/common.py 2013-01-31 22:39:17 +0000
307+++ ubuntuone/platform/sync_menu/common.py 1970-01-01 00:00:00 +0000
308@@ -1,41 +0,0 @@
309-# -*- coding: utf-8 *-*
310-#
311-# Copyright 2012 Canonical Ltd.
312-#
313-# This program is free software: you can redistribute it and/or modify it
314-# under the terms of the GNU General Public License version 3, as published
315-# by the Free Software Foundation.
316-#
317-# This program is distributed in the hope that it will be useful, but
318-# WITHOUT ANY WARRANTY; without even the implied warranties of
319-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
320-# PURPOSE. See the GNU General Public License for more details.
321-#
322-# You should have received a copy of the GNU General Public License along
323-# with this program. If not, see <http://www.gnu.org/licenses/>.
324-#
325-# In addition, as a special exception, the copyright holders give
326-# permission to link the code of portions of this program with the
327-# OpenSSL library under certain conditions as described in each
328-# individual source file, and distribute linked combinations
329-# including the two.
330-# You must obey the GNU General Public License in all respects
331-# for all of the code used other than OpenSSL. If you modify
332-# file(s) with this exception, you may extend this exception to your
333-# version of the file(s), but you are not obligated to do so. If you
334-# do not wish to do so, delete this exception statement from your
335-# version. If you delete this exception statement from all source
336-# files in the program, then also delete it here.
337-"""Dummy implementation of sync_menu lib for win32 and darwin."""
338-
339-
340-class UbuntuOneSyncMenu(object):
341- """Integrate U1 with the Ubuntu Sync Menu."""
342- def __init__(self, *args, **kwargs):
343- """Match #args of linux syncmenu and do nothing."""
344-
345- def update_transfers(self, *args, **kwargs):
346- """Do nothing."""
347-
348- def sync_status_changed(self, *args, **kwargs):
349- """Do nothing."""
350
351=== removed file 'ubuntuone/platform/sync_menu/linux.py'
352--- ubuntuone/platform/sync_menu/linux.py 2018-03-08 19:39:13 +0000
353+++ ubuntuone/platform/sync_menu/linux.py 1970-01-01 00:00:00 +0000
354@@ -1,330 +0,0 @@
355-# -*- coding: utf-8 *-*
356-#
357-# Copyright 2012-2013 Canonical Ltd.
358-#
359-# This program is free software: you can redistribute it and/or modify it
360-# under the terms of the GNU General Public License version 3, as published
361-# by the Free Software Foundation.
362-#
363-# This program is distributed in the hope that it will be useful, but
364-# WITHOUT ANY WARRANTY; without even the implied warranties of
365-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
366-# PURPOSE. See the GNU General Public License for more details.
367-#
368-# You should have received a copy of the GNU General Public License along
369-# with this program. If not, see <http://www.gnu.org/licenses/>.
370-#
371-# In addition, as a special exception, the copyright holders give
372-# permission to link the code of portions of this program with the
373-# OpenSSL library under certain conditions as described in each
374-# individual source file, and distribute linked combinations
375-# including the two.
376-# You must obey the GNU General Public License in all respects
377-# for all of the code used other than OpenSSL. If you modify
378-# file(s) with this exception, you may extend this exception to your
379-# version of the file(s), but you are not obligated to do so. If you
380-# do not wish to do so, delete this exception statement from your
381-# version. If you delete this exception statement from all source
382-# files in the program, then also delete it here.
383-"""Use SyncMenu lib to integrate U1 with the Systray Sync Icon."""
384-
385-import gettext
386-import logging
387-import time
388-from twisted.python.util import OrderedDict
389-from operator import itemgetter
390-
391-try:
392- from gi.repository import GLib as glib
393- from gi.repository import (
394- Dbusmenu,
395- Gdk,
396- Gio,
397- SyncMenu,
398- )
399- use_syncmenu = True
400-except ImportError:
401- use_syncmenu = False
402-
403-from ubuntuone.clientdefs import GETTEXT_PACKAGE, NAME
404-from ubuntuone.platform.sync_menu.common import (
405- UbuntuOneSyncMenu as DummySyncMenu,
406-)
407-
408-
409-logger = logging.getLogger("ubuntuone.platform.SyncMenu")
410-
411-
412-def Q_(string):
413- return gettext.dgettext(GETTEXT_PACKAGE, string)
414-
415-
416-GET_HELP = Q_("Get Help on the Web")
417-GO_TO_WEB = Q_("Go to the main website")
418-MORE_STORAGE = Q_("Get More Space")
419-OPEN_U1 = Q_("Open")
420-OPEN_U1_FOLDER = Q_("Open the main folder")
421-SHARE_A_FILE = Q_("Share a File")
422-TRANSFERS = Q_("Current and Recent Transfers")
423-
424-DELAY_BETWEEN_UPDATES = 3
425-UBUNTUONE_LINK = u'https://one.ubuntu.com/'
426-DASHBOARD = UBUNTUONE_LINK + u'dashboard/'
427-HELP_LINK = UBUNTUONE_LINK + u'support/'
428-GET_STORAGE_LINK = UBUNTUONE_LINK + u'services/add-storage/'
429-CLIENT_COMMAND_LINE = 'ubuntuone-control-panel-qt'
430-CLIENT_DESKTOP_ID = 'ubuntuone-installer.desktop'
431-
432-
433-class UbuntuOneSyncMenuLinux(object):
434- """Integrate U1 with the Ubuntu Sync Menu."""
435-
436- def __init__(self, status, syncdaemon_service):
437- """Initialize menu."""
438- self._syncdaemon_service = syncdaemon_service
439- self._connected = True
440- self.timer = None
441- self._ignore_status_event = False
442- self.next_update = time.time()
443- self.root_menu = Dbusmenu.Menuitem()
444-
445- self.open_u1 = Dbusmenu.Menuitem()
446- self.open_u1.property_set(Dbusmenu.MENUITEM_PROP_LABEL, OPEN_U1)
447- self.open_u1_folder = Dbusmenu.Menuitem()
448- self.open_u1_folder.property_set(
449- Dbusmenu.MENUITEM_PROP_LABEL, OPEN_U1_FOLDER)
450- self.share_file = Dbusmenu.Menuitem()
451- self.share_file.property_set(
452- Dbusmenu.MENUITEM_PROP_LABEL, SHARE_A_FILE)
453-
454- self.go_to_web = Dbusmenu.Menuitem()
455- self.go_to_web.property_set(
456- Dbusmenu.MENUITEM_PROP_LABEL, GO_TO_WEB)
457-
458- self.transfers = TransfersMenu(status)
459- self.transfers.property_set(
460- Dbusmenu.MENUITEM_PROP_LABEL, TRANSFERS)
461-
462- self.more_storage = Dbusmenu.Menuitem()
463- self.more_storage.property_set(
464- Dbusmenu.MENUITEM_PROP_LABEL, MORE_STORAGE)
465-
466- self.get_help = Dbusmenu.Menuitem()
467- self.get_help.property_set(
468- Dbusmenu.MENUITEM_PROP_LABEL, GET_HELP)
469-
470- # Connect signals
471- self.open_u1.connect(
472- Dbusmenu.MENUITEM_SIGNAL_ITEM_ACTIVATED, self.open_control_panel)
473- self.open_u1_folder.connect(
474- Dbusmenu.MENUITEM_SIGNAL_ITEM_ACTIVATED,
475- self.open_ubuntu_one_folder)
476- self.share_file.connect(
477- Dbusmenu.MENUITEM_SIGNAL_ITEM_ACTIVATED, self.open_share_file_tab)
478- self.go_to_web.connect(
479- Dbusmenu.MENUITEM_SIGNAL_ITEM_ACTIVATED, self.open_go_to_web)
480- self.get_help.connect(
481- Dbusmenu.MENUITEM_SIGNAL_ITEM_ACTIVATED, self.open_web_help)
482- self.more_storage.connect(
483- Dbusmenu.MENUITEM_SIGNAL_ITEM_ACTIVATED,
484- self.open_get_more_storage)
485-
486- # Add items
487- self.root_menu.child_append(self.open_u1)
488- self.root_menu.child_append(self.open_u1_folder)
489- self.root_menu.child_append(self.share_file)
490- self.root_menu.child_append(self.go_to_web)
491- self.root_menu.child_append(self.transfers)
492- self.root_menu.child_append(self.more_storage)
493- self.root_menu.child_append(self.get_help)
494-
495- self.server = Dbusmenu.Server()
496- self.server.set_root(self.root_menu)
497- self.app = SyncMenu.App.new(CLIENT_DESKTOP_ID)
498- self.app.set_menu(self.server)
499- self.app.connect("notify::paused", self.change_sync_status)
500-
501- def sync_status_changed(self, status):
502- """Listen to the changes for the sync status."""
503- if status != self._connected:
504- self._connected = status
505- self._ignore_status_event = True
506- self.app.set_paused(not self._connected)
507-
508- def change_sync_status(self, *args):
509- """Triggered when the sync status is changed fromm the menu."""
510- if self._ignore_status_event:
511- self._ignore_status_event = False
512- elif self._connected:
513- self._syncdaemon_service.disconnect()
514- self._connected = False
515- else:
516- self._syncdaemon_service.connect()
517- self._connected = True
518-
519- def _get_launch_context(self, timestamp):
520- """Returns the launch context for the current display"""
521- dpy = Gdk.Display.get_default()
522-
523- if dpy:
524- context = dpy.get_app_launch_context()
525- context.set_timestamp(timestamp)
526- return context
527-
528- return None
529-
530- def _open_uri(self, uri, timestamp=0):
531- """Open an uri Using the default handler and the action timestamp"""
532- try:
533- Gio.AppInfo.launch_default_for_uri(
534- uri, self._get_launch_context(timestamp))
535- except glib.GError as e:
536- logger.warning('Failed to open the uri %s: %s.', uri, e)
537-
538- def _open_control_panel_by_command_line(self, timestamp, args=''):
539- """Open the control panel by command line"""
540- flags = Gio.AppInfoCreateFlags.SUPPORTS_STARTUP_NOTIFICATION
541- command_line = CLIENT_COMMAND_LINE
542- if len(args):
543- command_line += ' ' + args
544-
545- try:
546- app = Gio.AppInfo.create_from_commandline(
547- command_line, NAME, flags)
548-
549- if app:
550- app.launch([], self._get_launch_context(timestamp))
551- except glib.GError as e:
552- logger.warning('Failed to open the control panel: %s.' % e)
553-
554- def open_control_panel(self, menuitem=None, timestamp=0):
555- """Open the Control Panel."""
556- app = Gio.DesktopAppInfo.new(CLIENT_DESKTOP_ID)
557-
558- if app:
559- try:
560- app.launch([], self._get_launch_context(timestamp))
561- except glib.GError as e:
562- logger.warning('Failed to open the control panel: %s.' % e)
563- else:
564- self._open_control_panel_by_command_line(timestamp)
565-
566- def open_ubuntu_one_folder(self, menuitem=None, timestamp=0):
567- """Open the folder."""
568- self._open_uri(
569- "file://" + self._syncdaemon_service.get_rootdir(), timestamp)
570-
571- def open_share_file_tab(self, menuitem=None, timestamp=0):
572- """Open the Control Panel in the Share Tab."""
573- self._open_control_panel_by_command_line(
574- timestamp, "--switch-to share_links")
575-
576- def open_go_to_web(self, menuitem=None, timestamp=0):
577- """Open the Help Page"""
578- self._open_uri(DASHBOARD, timestamp)
579-
580- def open_web_help(self, menuitem=None, timestamp=0):
581- """Open the Help Page"""
582- self._open_uri(HELP_LINK, timestamp)
583-
584- def open_get_more_storage(self, menuitem=None, timestamp=0):
585- """Open the Help Page"""
586- self._open_uri(GET_STORAGE_LINK, timestamp)
587-
588- def _timeout(self, result):
589- """The aggregating timer has expired, so update the UI."""
590- self.next_update = int(time.time()) + DELAY_BETWEEN_UPDATES
591- self.transfers.update_progress()
592-
593- def update_transfers(self):
594- """Set up a timer if there isn't one ticking and update the ui.
595-
596- NOOP. Left behind for API compatibility, will be removed later when
597- all interaction with old syncmeny and desktop GUIs go away.
598- """
599-
600-
601-class TransfersMenu(Dbusmenu.Menuitem if use_syncmenu else object):
602- """Menu that handles the recent and current transfers."""
603-
604- def __init__(self, status_frontend):
605- super(TransfersMenu, self).__init__()
606- self.status_frontend = status_frontend
607- self.uploading = {}
608- self.previous_transfers = []
609- self._transfers_items = {}
610- self._uploading_items = {}
611- self.separator = None
612-
613- def update_progress(self):
614- """Update the list of recent transfers and current transfers."""
615- recent_transfers = self.status_frontend.recent_transfers()
616- current_transfers = self.status_frontend.files_uploading()
617- current_transfers.sort(key=itemgetter(2))
618- current_transfers.reverse()
619- uploading_data = OrderedDict()
620- for filename, size, written in current_transfers:
621- uploading_data[filename] = (size, written)
622-
623- temp_transfers = {}
624- if recent_transfers != self.previous_transfers:
625- logger.debug("Update recent transfers with: %r", recent_transfers)
626- for item_transfer in self._transfers_items:
627- self.child_delete(self._transfers_items[item_transfer])
628- for item in recent_transfers:
629- recent_file = Dbusmenu.Menuitem()
630- recent_file.property_set(
631- Dbusmenu.MENUITEM_PROP_LABEL, item.replace('_', '__'))
632- self.child_add_position(recent_file, 0)
633- temp_transfers[item] = recent_file
634- self._transfers_items = temp_transfers
635-
636- if self.separator is None:
637- self.separator = Dbusmenu.Menuitem()
638- self.separator.property_set(
639- Dbusmenu.MENUITEM_PROP_TYPE, Dbusmenu.CLIENT_TYPES_SEPARATOR)
640- self.child_append(self.separator)
641-
642- items_added = 0
643- remove = []
644- for item in self._uploading_items:
645- if item in uploading_data.keys():
646- size, written = uploading_data[item]
647- percentage = written * 100 / size
648- upload_item = self._uploading_items[item]
649- upload_item.property_set_int(
650- SyncMenu.PROGRESS_MENUITEM_PROP_PERCENT_DONE,
651- percentage)
652- logger.debug(
653- "Current transfer %s progress update: %r",
654- item, percentage)
655- items_added += 1
656- else:
657- self.child_delete(self._uploading_items[item])
658- remove.append(item)
659- for item in remove:
660- self._uploading_items.pop(item)
661- if items_added < 5:
662- for item in uploading_data.keys():
663- if item not in self._uploading_items and items_added < 5:
664- size, written = uploading_data[item]
665- percentage = written * 100 / size
666- uploading_file = Dbusmenu.Menuitem()
667- uploading_file.property_set(
668- Dbusmenu.MENUITEM_PROP_LABEL, item.replace('_', '__'))
669- uploading_file.property_set(
670- Dbusmenu.MENUITEM_PROP_TYPE,
671- SyncMenu.PROGRESS_MENUITEM_TYPE)
672- uploading_file.property_set_int(
673- SyncMenu.PROGRESS_MENUITEM_PROP_PERCENT_DONE,
674- percentage)
675- logger.debug("Current transfer %s created", item)
676- self.child_append(uploading_file)
677- self._uploading_items[item] = uploading_file
678- items_added += 1
679-
680-
681-if use_syncmenu:
682- UbuntuOneSyncMenu = UbuntuOneSyncMenuLinux
683-else:
684- UbuntuOneSyncMenu = DummySyncMenu
685
686=== modified file 'ubuntuone/platform/tests/ipc/test_external_interface.py'
687--- ubuntuone/platform/tests/ipc/test_external_interface.py 2016-09-17 01:06:23 +0000
688+++ ubuntuone/platform/tests/ipc/test_external_interface.py 2018-04-24 23:14:39 +0000
689@@ -1,6 +1,7 @@
690 # -*- coding: utf-8 -*-
691 #
692 # Copyright 2011-2012 Canonical Ltd.
693+# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
694 #
695 # This program is free software: you can redistribute it and/or modify it
696 # under the terms of the GNU General Public License version 3, as published
697@@ -40,10 +41,6 @@
698 StatusTestCase,
699 SyncDaemonTestCase,
700 )
701-from ubuntuone.syncdaemon import (
702- RECENT_TRANSFERS,
703- UPLOADING,
704-)
705
706 STR = 'something'
707 STR_STR_DICT = {'foo': 'bar'}
708@@ -68,7 +65,7 @@
709 ('ContentQueueChanged', ()),
710 ('MetaQueueChanged', ()),
711 ('RequestQueueAdded', (STR, STR, STR_STR_DICT)),
712- ('RequestQueueRemoved', (STR, STR, STR_STR_DICT)),
713+ ('RequestQueueRemoved', (STR, STR, STR_STR_DICT)),
714 ]
715
716 @defer.inlineCallbacks
717@@ -136,16 +133,6 @@
718 self.assert_remote_method(
719 'waiting_metadata', in_signature=None, out_signature='a(sa{ss})')
720
721- @defer.inlineCallbacks
722- def test_sync_menu(self):
723- """Test sync_menu."""
724- result = {RECENT_TRANSFERS: [], UPLOADING: []}
725- method = 'sync_menu'
726- yield self.assert_method_called(self.service.status,
727- method, result)
728- self.assert_remote_method(
729- method, in_signature=None, out_signature='a{sv}')
730-
731
732 class EventsTests(EventsTestCase):
733 """Basic tests for the Events exposed object."""
734
735=== removed directory 'ubuntuone/platform/tests/sync_menu'
736=== removed file 'ubuntuone/platform/tests/sync_menu/__init__.py'
737--- ubuntuone/platform/tests/sync_menu/__init__.py 2012-09-18 16:22:15 +0000
738+++ ubuntuone/platform/tests/sync_menu/__init__.py 1970-01-01 00:00:00 +0000
739@@ -1,27 +0,0 @@
740-# Copyright 2012 Canonical Ltd.
741-#
742-# This program is free software: you can redistribute it and/or modify it
743-# under the terms of the GNU General Public License version 3, as published
744-# by the Free Software Foundation.
745-#
746-# This program is distributed in the hope that it will be useful, but
747-# WITHOUT ANY WARRANTY; without even the implied warranties of
748-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
749-# PURPOSE. See the GNU General Public License for more details.
750-#
751-# You should have received a copy of the GNU General Public License along
752-# with this program. If not, see <http://www.gnu.org/licenses/>.
753-#
754-# In addition, as a special exception, the copyright holders give
755-# permission to link the code of portions of this program with the
756-# OpenSSL library under certain conditions as described in each
757-# individual source file, and distribute linked combinations
758-# including the two.
759-# You must obey the GNU General Public License in all respects
760-# for all of the code used other than OpenSSL. If you modify
761-# file(s) with this exception, you may extend this exception to your
762-# version of the file(s), but you are not obligated to do so. If you
763-# do not wish to do so, delete this exception statement from your
764-# version. If you delete this exception statement from all source
765-# files in the program, then also delete it here.
766-"""SyncMenu test code."""
767
768=== removed file 'ubuntuone/platform/tests/sync_menu/test_common.py'
769--- ubuntuone/platform/tests/sync_menu/test_common.py 2012-10-15 21:20:54 +0000
770+++ ubuntuone/platform/tests/sync_menu/test_common.py 1970-01-01 00:00:00 +0000
771@@ -1,54 +0,0 @@
772-# -*- coding: utf-8 *-*
773-#
774-# Copyright 2012 Canonical Ltd.
775-#
776-# This program is free software: you can redistribute it and/or modify it
777-# under the terms of the GNU General Public License version 3, as published
778-# by the Free Software Foundation.
779-#
780-# This program is distributed in the hope that it will be useful, but
781-# WITHOUT ANY WARRANTY; without even the implied warranties of
782-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
783-# PURPOSE. See the GNU General Public License for more details.
784-#
785-# You should have received a copy of the GNU General Public License along
786-# with this program. If not, see <http://www.gnu.org/licenses/>.
787-#
788-# In addition, as a special exception, the copyright holders give
789-# permission to link the code of portions of this program with the
790-# OpenSSL library under certain conditions as described in each
791-# individual source file, and distribute linked combinations
792-# including the two.
793-# You must obey the GNU General Public License in all respects
794-# for all of the code used other than OpenSSL. If you modify
795-# file(s) with this exception, you may extend this exception to your
796-# version of the file(s), but you are not obligated to do so. If you
797-# do not wish to do so, delete this exception statement from your
798-# version. If you delete this exception statement from all source
799-# files in the program, then also delete it here.
800-"""Test the common dummy Sync Menu implementation for win32/darwin."""
801-
802-from collections import Callable
803-
804-from twisted.trial.unittest import TestCase
805-
806-from ubuntuone.platform.sync_menu import common
807-
808-
809-class SyncMenuDummyTestCase(TestCase):
810- """Test the SyncMenu."""
811-
812- def test_dummy_support(self):
813- """Can we create a Dummy with the same #args as the real obj."""
814- dummy = common.UbuntuOneSyncMenu(1, 2)
815- self.assertIsInstance(dummy, common.UbuntuOneSyncMenu)
816-
817- def test_dummy_has_update_transfers(self):
818- """Check that the dummy has the proper methods required by the API."""
819- dummy = common.UbuntuOneSyncMenu(1, 2)
820- self.assertIsInstance(dummy.update_transfers, Callable)
821-
822- def test_dummy_has_sync_status_changed(self):
823- """Check that the dummy has the proper methods required by the API."""
824- dummy = common.UbuntuOneSyncMenu(1, 2)
825- self.assertIsInstance(dummy.sync_status_changed, Callable)
826
827=== removed file 'ubuntuone/platform/tests/sync_menu/test_linux.py'
828--- ubuntuone/platform/tests/sync_menu/test_linux.py 2016-09-17 01:06:23 +0000
829+++ ubuntuone/platform/tests/sync_menu/test_linux.py 1970-01-01 00:00:00 +0000
830@@ -1,586 +0,0 @@
831-# -*- coding: utf-8 *-*
832-#
833-# Copyright 2012 Canonical Ltd.
834-#
835-# This program is free software: you can redistribute it and/or modify it
836-# under the terms of the GNU General Public License version 3, as published
837-# by the Free Software Foundation.
838-#
839-# This program is distributed in the hope that it will be useful, but
840-# WITHOUT ANY WARRANTY; without even the implied warranties of
841-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
842-# PURPOSE. See the GNU General Public License for more details.
843-#
844-# You should have received a copy of the GNU General Public License along
845-# with this program. If not, see <http://www.gnu.org/licenses/>.
846-#
847-# In addition, as a special exception, the copyright holders give
848-# permission to link the code of portions of this program with the
849-# OpenSSL library under certain conditions as described in each
850-# individual source file, and distribute linked combinations
851-# including the two.
852-# You must obey the GNU General Public License in all respects
853-# for all of the code used other than OpenSSL. If you modify
854-# file(s) with this exception, you may extend this exception to your
855-# version of the file(s), but you are not obligated to do so. If you
856-# do not wish to do so, delete this exception statement from your
857-# version. If you delete this exception statement from all source
858-# files in the program, then also delete it here.
859-"""Test the Sync Menu."""
860-
861-import time
862-from collections import Callable
863-
864-from twisted.internet import defer
865-from twisted.trial.unittest import TestCase
866-
867-from ubuntuone.platform import sync_menu
868-from ubuntuone.platform.sync_menu import linux
869-
870-
871-def fake_call_later(*args):
872- """Fake reactor.callLater."""
873-
874-
875-class FakeStatusFrontend(object):
876- """Fake StatusFrontend."""
877-
878- def __init__(self):
879- self.recent_transfers_data = []
880- self.uploading_data = []
881-
882- def recent_transfers(self):
883- """Return the fake recent transfers files."""
884- return self.recent_transfers_data
885-
886- def files_uploading(self):
887- """Return the fake files being upload."""
888- return self.uploading_data
889-
890-
891-class FakeAppLaunchContext(object):
892- def set_timestamp(self, timestamp):
893- self.timestamp = timestamp
894-
895-
896-class FakeGdkDisplay(object):
897- """Fake Gdk.Display"""
898- def get_app_launch_context(self):
899- return FakeAppLaunchContext()
900-
901-
902-class FakeNullGdk(object):
903- """Fake Gdk.Display with no default"""
904- @staticmethod
905- def get_default():
906- return None
907-
908-
909-class FakeAppInfo(object):
910- """Fake Gio.AppInfo"""
911- instance = None
912- name = ""
913- desktop_id = ""
914- command_line = ""
915- opened_uri = ""
916- launched = True
917- context = None
918- files = []
919- flags = 0
920-
921- def __new__(cls, *args, **kwargs):
922- cls.instance = super(FakeAppInfo, cls).__new__(cls, *args, **kwargs)
923- return cls.instance
924-
925- def __init__(self, command_line="", name="", flags=0):
926- self.command_line = command_line
927- self.name = name
928- self.flags = flags
929-
930- @classmethod
931- def launch_default_for_uri(cls, uri, context):
932- cls.opened_uri = uri
933- cls.context = context
934-
935- @classmethod
936- def create_from_commandline(cls, command_line, name, flags):
937- cls.instance.__init__(command_line, name, flags)
938- return cls.instance
939-
940- def launch(self, files, context):
941- self.launched = True
942- self.files = files
943- self.context = context
944-
945-
946-class FakeDesktopAppInfo(FakeAppInfo):
947- """Fake Gio.DestkopAppInfo"""
948- def __init__(self, desktop_id=""):
949- super(FakeDesktopAppInfo, self).__init__()
950- self.desktop_id = desktop_id
951-
952- @classmethod
953- def new(cls, desktop_id):
954- cls.instance.__init__(desktop_id)
955- return cls.instance
956-
957-
958-class FakeSyncdaemonService(object):
959- """Fake SyncdaemonService."""
960-
961- def __init__(self):
962- self.connect_called = False
963- self.disconnect_called = False
964- self.fake_root_path = "/home/user/Magicicada"
965-
966- def connect(self):
967- """Set connect to True."""
968- self.connect_called = True
969-
970- def disconnect(self):
971- """Set connect to True."""
972- self.disconnect_called = True
973-
974- def get_rootdir(self):
975- """Return a fake ubuntu one folder path."""
976- return self.fake_root_path
977-
978-
979-class FakeSyncMenuApp(object):
980- """Fake SyncMenu."""
981-
982- data = {}
983-
984- @classmethod
985- def new(cls, *args):
986- return FakeSyncMenuApp()
987-
988- @classmethod
989- def clean(cls):
990- """Clear the values stored in data."""
991- FakeSyncMenuApp.data = {}
992-
993- def set_menu(self, server):
994- """Set the menu for SyncMenu App."""
995- self.data['server'] = server
996-
997- def connect(self, signal, callback):
998- """Fake connect."""
999- self.data['connect'] = (signal, callback)
1000-
1001- def set_paused(self, status):
1002- """Set the pause state."""
1003- self.data['paused'] = status
1004-
1005-
1006-class SyncMenuDummyTestCase(TestCase):
1007- """Test the SyncMenu."""
1008-
1009- def test_dummy_support(self):
1010- """Check that the Dummy object can be created properly."""
1011- dummy = linux.DummySyncMenu('random', 'args')
1012- self.assertIsInstance(dummy, linux.DummySyncMenu)
1013-
1014- def test_dummy_has_update_transfers(self):
1015- """Check that the dummy has the proper methods required by the API."""
1016- dummy = linux.DummySyncMenu('random', 'args')
1017- self.assertIsInstance(dummy.update_transfers, Callable)
1018- self.assertIsInstance(dummy.sync_status_changed, Callable)
1019-
1020-
1021-class SyncMenuTestCase(TestCase):
1022- """Test the SyncMenu."""
1023-
1024- skip = None if linux.use_syncmenu else "SyncMenu not installed."
1025-
1026- @defer.inlineCallbacks
1027- def setUp(self):
1028- yield super(SyncMenuTestCase, self).setUp()
1029- self.patch(linux.SyncMenu, "App", FakeSyncMenuApp)
1030- self.patch(linux.Gdk.Display, "get_default", FakeGdkDisplay)
1031- FakeSyncMenuApp.clean()
1032- self.syncdaemon_service = FakeSyncdaemonService()
1033- self.status_frontend = FakeStatusFrontend()
1034- self._paused = False
1035- self.sync_menu = sync_menu.UbuntuOneSyncMenu(
1036- self.status_frontend, self.syncdaemon_service)
1037-
1038- def test_init(self):
1039- """Check that the menu is properly initialized."""
1040- self.assertIsInstance(
1041- FakeSyncMenuApp.data['server'], linux.Dbusmenu.Server)
1042- self.assertEqual(
1043- self.sync_menu.open_u1.get_parent(), self.sync_menu.root_menu)
1044- self.assertEqual(
1045- self.sync_menu.go_to_web.get_parent(), self.sync_menu.root_menu)
1046- self.assertEqual(
1047- self.sync_menu.more_storage.get_parent(), self.sync_menu.root_menu)
1048- self.assertEqual(
1049- self.sync_menu.get_help.get_parent(), self.sync_menu.root_menu)
1050- self.assertEqual(
1051- self.sync_menu.transfers.get_parent(), self.sync_menu.root_menu)
1052- self.assertEqual(
1053- self.sync_menu.open_u1_folder.get_parent(),
1054- self.sync_menu.root_menu)
1055- self.assertEqual(
1056- self.sync_menu.share_file.get_parent(), self.sync_menu.root_menu)
1057-
1058- def get_prop(item):
1059- return item.property_get(linux.Dbusmenu.MENUITEM_PROP_LABEL)
1060-
1061- self.assertEqual(
1062- get_prop(self.sync_menu.open_u1), linux.OPEN_U1)
1063- self.assertEqual(
1064- get_prop(self.sync_menu.open_u1_folder), linux.OPEN_U1_FOLDER)
1065- self.assertEqual(
1066- get_prop(self.sync_menu.share_file), linux.SHARE_A_FILE)
1067- self.assertEqual(
1068- get_prop(self.sync_menu.go_to_web), linux.GO_TO_WEB)
1069- self.assertEqual(
1070- get_prop(self.sync_menu.transfers), linux.TRANSFERS)
1071- self.assertEqual(
1072- get_prop(self.sync_menu.more_storage), linux.MORE_STORAGE)
1073- self.assertEqual(
1074- get_prop(self.sync_menu.get_help), linux.GET_HELP)
1075-
1076- self.sync_menu.transfers.update_progress()
1077- self.assertIsInstance(
1078- self.sync_menu.transfers.separator, linux.Dbusmenu.Menuitem)
1079-
1080- def test_get_launch_context_with_display(self):
1081- """Check that the proper context is returned."""
1082- timestamp = time.time()
1083- context = self.sync_menu._get_launch_context(timestamp)
1084- self.assertEqual(timestamp, context.timestamp)
1085-
1086- def test_get_launch_context_with_no_display(self):
1087- """Check that the proper context is returned."""
1088- self.patch(linux.Gdk, "Display", FakeNullGdk)
1089- context = self.sync_menu._get_launch_context(time.time())
1090- self.assertEqual(context, None)
1091-
1092- def test_open_control_panel_by_command_line(self):
1093- """Check that the proper action is executed."""
1094- appinfo = FakeAppInfo()
1095- self.patch(linux.Gio, "AppInfo", appinfo)
1096- timestamp = time.time()
1097- self.sync_menu._open_control_panel_by_command_line(timestamp)
1098-
1099- self.assertEqual(appinfo.command_line, linux.CLIENT_COMMAND_LINE)
1100- self.assertEqual(appinfo.context.timestamp, timestamp)
1101-
1102- def test_open_control_panel_by_command_line_with_arg(self):
1103- """Check that the proper action is executed."""
1104- appinfo = FakeAppInfo()
1105- self.patch(linux.Gio, "AppInfo", appinfo)
1106- timestamp = time.time()
1107- arg = "--test-arg"
1108- self.sync_menu._open_control_panel_by_command_line(timestamp, arg)
1109-
1110- self.assertEqual(
1111- appinfo.command_line, "%s %s" % (linux.CLIENT_COMMAND_LINE, arg))
1112- self.assertEqual(appinfo.context.timestamp, timestamp)
1113-
1114- def test_open_uri(self):
1115- """Check that the proper action is executed."""
1116- appinfo = FakeAppInfo()
1117- self.patch(linux.Gio, "AppInfo", appinfo)
1118- timestamp = time.time()
1119-
1120- self.sync_menu._open_uri(linux.UBUNTUONE_LINK, timestamp)
1121- self.assertEqual(appinfo.opened_uri, linux.UBUNTUONE_LINK)
1122- self.assertEqual(appinfo.context.timestamp, timestamp)
1123-
1124- def test_open_u1(self):
1125- """Check that the proper action is executed."""
1126- appinfo = FakeDesktopAppInfo()
1127- timestamp = time.time()
1128- self.patch(linux.Gio, "DesktopAppInfo", appinfo)
1129-
1130- self.sync_menu.open_control_panel(timestamp=timestamp)
1131- self.assertEqual(appinfo.desktop_id, linux.CLIENT_DESKTOP_ID)
1132- self.assertTrue(appinfo.launched)
1133- self.assertEqual(appinfo.files, [])
1134- self.assertEqual(appinfo.context.timestamp, timestamp)
1135-
1136- def test_open_share_tab(self):
1137- """Check that the proper action is executed."""
1138- timestamp = time.time()
1139- data = []
1140-
1141- self.patch(
1142- self.sync_menu, "_open_control_panel_by_command_line",
1143- lambda t, a: data.append((t, a)))
1144- self.sync_menu.open_share_file_tab(timestamp=timestamp)
1145- self.assertEqual(data, [(timestamp, "--switch-to share_links")])
1146-
1147- def test_go_to_web(self):
1148- """Check that the proper action is executed."""
1149- timestamp = time.time()
1150- data = []
1151-
1152- self.patch(
1153- self.sync_menu, "_open_uri", lambda u, t: data.append((t, u)))
1154- self.sync_menu.open_go_to_web(timestamp=timestamp)
1155- self.assertEqual(data, [(timestamp, linux.DASHBOARD)])
1156-
1157- def test_open_ubuntu_one_folder(self):
1158- """Check that the proper action is executed."""
1159- timestamp = time.time()
1160- data = []
1161-
1162- self.patch(
1163- self.sync_menu, "_open_uri", lambda u, t: data.append((t, u)))
1164- self.sync_menu.open_ubuntu_one_folder(timestamp=timestamp)
1165- self.assertEqual(
1166- data,
1167- [(timestamp, "file://" + self.syncdaemon_service.fake_root_path)])
1168-
1169- def test_get_help(self):
1170- """Check that the proper action is executed."""
1171- timestamp = time.time()
1172- data = []
1173-
1174- self.patch(
1175- self.sync_menu, "_open_uri", lambda u, t: data.append((t, u)))
1176- self.sync_menu.open_web_help(timestamp=timestamp)
1177- self.assertEqual(data, [(timestamp, linux.HELP_LINK)])
1178-
1179- def test_more_storage(self):
1180- """Check that the proper action is executed."""
1181- timestamp = time.time()
1182- data = []
1183-
1184- self.patch(
1185- self.sync_menu, "_open_uri", lambda u, t: data.append((t, u)))
1186- self.sync_menu.open_get_more_storage(timestamp=timestamp)
1187- self.assertEqual(data, [(timestamp, linux.GET_STORAGE_LINK)])
1188-
1189- def test_empty_transfers(self):
1190- """Check that the Transfers menu is empty."""
1191- self.assertEqual(self.sync_menu.transfers.get_children(), [])
1192-
1193- def test_only_recent(self):
1194- """Check that only recent transfers items are loaded."""
1195- data = ['file1', 'file2', 'file3']
1196- self.status_frontend.recent_transfers_data = data
1197- self.sync_menu.transfers.update_progress()
1198- children = self.sync_menu.transfers.get_children()
1199- self.assertEqual(len(children), 4)
1200- data.reverse()
1201- for itemM, itemD in zip(children, data):
1202- self.assertEqual(
1203- itemM.property_get(linux.Dbusmenu.MENUITEM_PROP_LABEL), itemD)
1204-
1205- def test_only_progress(self):
1206- """Check that only progress items are loaded."""
1207- data = [
1208- ('file1', 3000, 400),
1209- ('file2', 2000, 100),
1210- ('file3', 5000, 4600)]
1211- uploading_data = {}
1212- for filename, size, written in data:
1213- uploading_data[filename] = (size, written)
1214- self.status_frontend.uploading_data = data
1215- self.sync_menu.transfers.update_progress()
1216- children = self.sync_menu.transfers.get_children()
1217- self.assertEqual(len(children), 4)
1218- data.reverse()
1219- for item in children:
1220- text = item.property_get(linux.Dbusmenu.MENUITEM_PROP_LABEL)
1221- if text is None:
1222- continue
1223- self.assertIn(text, uploading_data)
1224- size, written = uploading_data[text]
1225- percentage = written * 100 / size
1226- self.assertEqual(item.property_get_int(
1227- linux.SyncMenu.PROGRESS_MENUITEM_PROP_PERCENT_DONE),
1228- percentage)
1229-
1230- def test_full_transfers(self):
1231- """Check that the transfers menu contains the maximum transfers."""
1232- # The api of recent transfers always returns a maximum of 5 items
1233- data_recent = ['file1', 'file2', 'file3', 'file4', 'file5']
1234- self.status_frontend.recent_transfers_data = \
1235- data_recent
1236- self.sync_menu.transfers.update_progress()
1237- children = self.sync_menu.transfers.get_children()
1238- self.assertEqual(len(children), 6)
1239- data_recent.reverse()
1240- for itemM, itemD in zip(children, data_recent):
1241- self.assertEqual(itemM.property_get(
1242- linux.Dbusmenu.MENUITEM_PROP_LABEL), itemD)
1243-
1244- data_current = [
1245- ('file0', 1200, 600),
1246- ('file1', 3000, 400),
1247- ('file2', 2000, 100),
1248- ('file3', 2500, 150),
1249- ('file4', 1000, 600),
1250- ('file5', 5000, 4600)]
1251- uploading_data = {}
1252- for filename, size, written in data_current:
1253- uploading_data[filename] = (size, written)
1254- self.status_frontend.uploading_data = data_current
1255- self.sync_menu.transfers.update_progress()
1256- children = self.sync_menu.transfers.get_children()
1257- # The menu should only show 5 current transfers.
1258- self.assertEqual(len(children), 11)
1259- data_current.reverse()
1260- for item in children[6:]:
1261- text = item.property_get(linux.Dbusmenu.MENUITEM_PROP_LABEL)
1262- self.assertIn(text, uploading_data)
1263- size, written = uploading_data[text]
1264- percentage = written * 100 / size
1265- self.assertEqual(item.property_get_int(
1266- linux.SyncMenu.PROGRESS_MENUITEM_PROP_PERCENT_DONE),
1267- percentage)
1268-
1269- def test_mnemonics_labels(self):
1270- """Check that the transfers menu sanitizes the underscores."""
1271- data_recent = ['file_1', 'file__2']
1272- self.status_frontend.recent_transfers_data = \
1273- data_recent
1274- self.sync_menu.transfers.update_progress()
1275- children = self.sync_menu.transfers.get_children()
1276- data_recent.reverse()
1277- for itemM, itemD in zip(children, data_recent):
1278- self.assertEqual(itemM.property_get(
1279- linux.Dbusmenu.MENUITEM_PROP_LABEL), itemD.replace('_', '__'))
1280-
1281- def test_update_transfers(self):
1282- """Check that everything is ok when updating the transfers value."""
1283- data_current = [
1284- ('file0', 1200, 600),
1285- ('file1', 3000, 400),
1286- ('file4', 1000, 600),
1287- ('file5', 5000, 4600)]
1288- uploading_data = {}
1289- for filename, size, written in data_current:
1290- uploading_data[filename] = (size, written)
1291- self.status_frontend.uploading_data = data_current
1292- self.sync_menu.transfers.update_progress()
1293- children = self.sync_menu.transfers.get_children()
1294- # The menu should only show 5 current transfers.
1295- self.assertEqual(len(children), 5)
1296- data_current.reverse()
1297- for item in children:
1298- text = item.property_get(linux.Dbusmenu.MENUITEM_PROP_LABEL)
1299- if text is None:
1300- continue
1301- self.assertIn(text, uploading_data)
1302- size, written = uploading_data[text]
1303- percentage = written * 100 / size
1304- self.assertEqual(item.property_get_int(
1305- linux.SyncMenu.PROGRESS_MENUITEM_PROP_PERCENT_DONE),
1306- percentage)
1307-
1308- data_recent = ['file5']
1309- self.status_frontend.recent_transfers_data = data_recent
1310- self.sync_menu.transfers.update_progress()
1311- children = self.sync_menu.transfers.get_children()
1312- self.assertEqual(len(children), 6)
1313- data_recent.reverse()
1314- for itemM, itemD in zip(children, data_recent):
1315- self.assertEqual(itemM.property_get(
1316- linux.Dbusmenu.MENUITEM_PROP_LABEL), itemD)
1317-
1318- data_current = [
1319- ('file0', 1200, 700),
1320- ('file1', 3000, 600),
1321- ('file4', 1000, 800)]
1322- uploading_data = {}
1323- for filename, size, written in data_current:
1324- uploading_data[filename] = (size, written)
1325- self.status_frontend.uploading_data = data_current
1326- self.sync_menu.transfers.update_progress()
1327- children = self.sync_menu.transfers.get_children()
1328- # The menu should only show 5 current transfers.
1329- self.assertEqual(len(children), 5)
1330- data_current.reverse()
1331- for item in children[6:]:
1332- text = item.property_get(linux.Dbusmenu.MENUITEM_PROP_LABEL)
1333- self.assertIn(text, uploading_data)
1334- size, written = uploading_data[text]
1335- percentage = written * 100 / size
1336- self.assertEqual(item.property_get_int(
1337- linux.SyncMenu.PROGRESS_MENUITEM_PROP_PERCENT_DONE),
1338- percentage)
1339-
1340- def test_transfers_order(self):
1341- """Check that the proper transfers are shown first."""
1342- data_current = [
1343- ('file0', 1200, 610),
1344- ('file1', 3000, 400),
1345- ('file2', 2000, 100),
1346- ('file3', 2500, 150),
1347- ('file4', 2500, 950),
1348- ('file5', 3500, 550),
1349- ('file6', 1000, 600),
1350- ('file7', 5000, 4600)]
1351- expected = [
1352- ('file7', 5000, 4600),
1353- ('file4', 2500, 950),
1354- ('file0', 1200, 610),
1355- ('file6', 1000, 600),
1356- ('file5', 3500, 550)]
1357- self.status_frontend.uploading_data = data_current
1358- self.sync_menu.transfers.update_progress()
1359- children = self.sync_menu.transfers.get_children()
1360- # The menu should only show 5 current transfers and a separator item.
1361- self.assertEqual(len(children), 6)
1362- i = 0
1363- for item in children:
1364- text = item.property_get(linux.Dbusmenu.MENUITEM_PROP_LABEL)
1365- if text is None:
1366- continue
1367- percentage = item.property_get_int(
1368- linux.SyncMenu.PROGRESS_MENUITEM_PROP_PERCENT_DONE)
1369- name, size, written = expected[i]
1370- i += 1
1371- percentage_expected = written * 100 / size
1372- self.assertEqual(text, name)
1373- self.assertEqual(percentage, percentage_expected)
1374-
1375- def test_update_transfers_delay(self):
1376- """Check that the timer is being handle properly."""
1377- self.sync_menu.next_update = time.time()
1378- self.sync_menu.update_transfers()
1379- self.sync_menu.timer = None
1380- self.sync_menu.next_update = time.time() * 2
1381- self.sync_menu.update_transfers()
1382- self.assertEqual(self.sync_menu.timer.delay, 3)
1383-
1384- def test_status_change_from_menu(self):
1385- """Check the behavior when the status is changed from the menu."""
1386- self.sync_menu.change_sync_status()
1387- self.assertFalse(self.sync_menu._connected)
1388- self.assertFalse(self.sync_menu._ignore_status_event)
1389- self.assertFalse(self.sync_menu._syncdaemon_service.connect_called)
1390- self.assertTrue(self.sync_menu._syncdaemon_service.disconnect_called)
1391-
1392- self.sync_menu._syncdaemon_service.disconnect_called = False
1393- self.sync_menu.change_sync_status()
1394- self.assertTrue(self.sync_menu._connected)
1395- self.assertFalse(self.sync_menu._ignore_status_event)
1396- self.assertTrue(self.sync_menu._syncdaemon_service.connect_called)
1397- self.assertFalse(self.sync_menu._syncdaemon_service.disconnect_called)
1398-
1399- def test_ignore_status(self):
1400- """Check that neither connect or disconnect are called."""
1401- self.sync_menu._ignore_status_event = True
1402- self.assertTrue(self.sync_menu._ignore_status_event)
1403- self.sync_menu.change_sync_status()
1404- self.assertTrue(self.sync_menu._connected)
1405- self.assertFalse(self.sync_menu._ignore_status_event)
1406- self.assertFalse(self.sync_menu._syncdaemon_service.connect_called)
1407- self.assertFalse(self.sync_menu._syncdaemon_service.disconnect_called)
1408-
1409- def test_sync_status_changed(self):
1410- """Check sync_status_changed behavior."""
1411- self.sync_menu.sync_status_changed(True)
1412- self.assertNotIn('paused', self.sync_menu.app.data)
1413- self.sync_menu.sync_status_changed(False)
1414- self.assertFalse(self.sync_menu._connected)
1415- self.assertTrue(self.sync_menu._ignore_status_event)
1416- self.assertTrue(self.sync_menu.app.data['paused'])
1417
1418=== modified file 'ubuntuone/platform/tests/test_tools.py'
1419--- ubuntuone/platform/tests/test_tools.py 2016-09-17 01:06:23 +0000
1420+++ ubuntuone/platform/tests/test_tools.py 2018-04-24 23:14:39 +0000
1421@@ -1,6 +1,7 @@
1422 # -*- coding: utf-8 -*-
1423 #
1424 # Copyright 2009-2012 Canonical Ltd.
1425+# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
1426 #
1427 # This program is free software: you can redistribute it and/or modify it
1428 # under the terms of the GNU General Public License version 3, as published
1429@@ -44,8 +45,6 @@
1430 interaction_interfaces,
1431 states,
1432 volume_manager,
1433- RECENT_TRANSFERS,
1434- UPLOADING,
1435 )
1436 from ubuntuone.platform import tools
1437 from ubuntuone.platform.tests import IPCTestCase
1438@@ -253,13 +252,6 @@
1439 self.assertEqual('share_id', result['volume_id'])
1440 self.assertEqual(False, self.main.vm.shares['share_id'].accepted)
1441
1442- @defer.inlineCallbacks
1443- def test_sync_menu(self):
1444- """Test accept_share method."""
1445- result = yield self.tool.sync_menu()
1446- self.assertIn(RECENT_TRANSFERS, result)
1447- self.assertIn(UPLOADING, result)
1448-
1449
1450 class TestWaitForSignals(TestToolsBase):
1451 """Test case for the wait_for_signals method from SyncDaemonTool."""
1452@@ -496,8 +488,8 @@
1453 """Test SyncDaemonTool.waiting_metadata."""
1454 # inject the fake data
1455 self.action_q.queue.waiting.extend([
1456- FakeCommand("node_a_foo", "node_a_bar", path='path'),
1457- FakeCommand("node_b_foo", "node_b_bar")])
1458+ FakeCommand("node_a_foo", "node_a_bar", path='path'),
1459+ FakeCommand("node_b_foo", "node_b_bar")])
1460 result = yield self.tool.waiting_metadata()
1461
1462 self.assertEqual(2, len(result))
1463@@ -521,8 +513,8 @@
1464
1465 # inject the fake data
1466 self.action_q.queue.waiting.extend([
1467- FakeContentCommand("", "node_id", path='/some/path'),
1468- FakeContentCommand("", "node_id_1", path='/other/path')])
1469+ FakeContentCommand("", "node_id", path='/some/path'),
1470+ FakeContentCommand("", "node_id_1", path='/other/path')])
1471
1472 result = yield self.tool.waiting_content()
1473
1474
1475=== modified file 'ubuntuone/platform/tools/__init__.py'
1476--- ubuntuone/platform/tools/__init__.py 2018-03-08 19:39:13 +0000
1477+++ ubuntuone/platform/tools/__init__.py 2018-04-24 23:14:39 +0000
1478@@ -1,6 +1,7 @@
1479 # -*- coding: utf-8 -*-
1480 #
1481 # Copyright 2009-2012 Canonical Ltd.
1482+# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
1483 #
1484 # This program is free software: you can redistribute it and/or modify it
1485 # under the terms of the GNU General Public License version 3, as published
1486@@ -269,13 +270,6 @@
1487
1488 @defer.inlineCallbacks
1489 @log_call(logger.debug)
1490- def sync_menu(self):
1491- """Return a deferred that will be fired with the sync menu data."""
1492- results = yield self.proxy.call_method('status', 'sync_menu')
1493- defer.returnValue(results)
1494-
1495- @defer.inlineCallbacks
1496- @log_call(logger.debug)
1497 def accept_share(self, share_id):
1498 """Accept the share with id: share_id."""
1499 d = self.wait_for_signals(
1500
1501=== modified file 'ubuntuone/syncdaemon/__init__.py'
1502--- ubuntuone/syncdaemon/__init__.py 2016-05-30 13:03:37 +0000
1503+++ ubuntuone/syncdaemon/__init__.py 2018-04-24 23:14:39 +0000
1504@@ -1,5 +1,5 @@
1505 # Copyright 2009-2012 Canonical Ltd.
1506-# Copyright 2015-2016 Chicharreros (https://launchpad.net/~chicharreros)
1507+# Copyright 2015-2018 Chicharreros (https://launchpad.net/~chicharreros)
1508 #
1509 # This program is free software: you can redistribute it and/or modify it
1510 # under the terms of the GNU General Public License version 3, as published
1511@@ -31,9 +31,3 @@
1512 REQUIRED_CAPS = frozenset(
1513 ["no-content", "account-info", "resumable-uploads", "fix462230", "volumes",
1514 "generations"])
1515-
1516-
1517-# Sync Menu data constants
1518-RECENT_TRANSFERS = 'recent-transfers'
1519-UPLOADING = 'uploading'
1520-DOWNLOADING = 'downloading'
1521
1522=== modified file 'ubuntuone/syncdaemon/interaction_interfaces.py'
1523--- ubuntuone/syncdaemon/interaction_interfaces.py 2018-04-14 23:34:20 +0000
1524+++ ubuntuone/syncdaemon/interaction_interfaces.py 2018-04-24 23:14:39 +0000
1525@@ -304,10 +304,6 @@
1526 waiting_content.append(data)
1527 return waiting_content
1528
1529- def sync_menu(self):
1530- """Return the info necessary to construct the menu."""
1531- return self.main.status_listener.menu_data()
1532-
1533
1534 class SyncdaemonFileSystem(SyncdaemonObject):
1535 """An interface to the FileSystem Manager."""

Subscribers

People subscribed via source and target branches

to all changes: