Merge lp:~alecu/ubuntuone-control-panel/more-devices-tab into lp:ubuntuone-control-panel

Proposed by Alejandro J. Cura
Status: Merged
Approved by: Natalia Bidart
Approved revision: 168
Merged at revision: 161
Proposed branch: lp:~alecu/ubuntuone-control-panel/more-devices-tab
Merge into: lp:ubuntuone-control-panel
Diff against target: 672 lines (+403/-111)
11 files modified
data/qt/controlpanel.ui (+4/-10)
data/qt/device.ui (+50/-0)
data/qt/devices.ui (+76/-100)
data/qt/images.qrc (+2/-0)
ubuntuone/controlpanel/gui/qt/controlpanel.py (+34/-0)
ubuntuone/controlpanel/gui/qt/device.py (+58/-0)
ubuntuone/controlpanel/gui/qt/devices.py (+23/-0)
ubuntuone/controlpanel/gui/qt/tests/__init__.py (+25/-0)
ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py (+10/-1)
ubuntuone/controlpanel/gui/qt/tests/test_device.py (+81/-0)
ubuntuone/controlpanel/gui/qt/tests/test_devices.py (+40/-0)
To merge this branch: bzr merge lp:~alecu/ubuntuone-control-panel/more-devices-tab
Reviewer Review Type Date Requested Status
Natalia Bidart (community) Approve
Review via email: mp+63292@code.launchpad.net

Commit message

Show connected computers and phones on the "devices" tab

Description of the change

Show connected computers and phones on the "devices" tab

To post a comment you must log in.
Revision history for this message
Alejandro J. Cura (alecu) wrote :

We'll delay merging this branch till after the windows control panel has settled on a webservice client library (either twisted web client, or qt-net web client)

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

This branch needs some refactoring that is reported in bug #798410 and bug #798413.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'data/computer.png'
2Binary files data/computer.png 1970-01-01 00:00:00 +0000 and data/computer.png 2011-06-02 20:04:32 +0000 differ
3=== added file 'data/phone.png'
4Binary files data/phone.png 1970-01-01 00:00:00 +0000 and data/phone.png 2011-06-02 20:04:32 +0000 differ
5=== modified file 'data/qt/controlpanel.ui'
6--- data/qt/controlpanel.ui 2011-06-02 04:03:02 +0000
7+++ data/qt/controlpanel.ui 2011-06-02 20:04:32 +0000
8@@ -162,9 +162,9 @@
9 </widget>
10 </item>
11 <item>
12- <widget class="QPushButton" name="twitter_button">
13+ <widget class="QToolButton" name="twitter_button">
14 <property name="styleSheet">
15- <string notr="true"/>
16+ <string notr="true">border: 0;</string>
17 </property>
18 <property name="text">
19 <string/>
20@@ -179,15 +179,12 @@
21 <height>32</height>
22 </size>
23 </property>
24- <property name="flat">
25- <bool>true</bool>
26- </property>
27 </widget>
28 </item>
29 <item>
30- <widget class="QPushButton" name="facebook_button">
31+ <widget class="QToolButton" name="facebook_button">
32 <property name="styleSheet">
33- <string notr="true"/>
34+ <string notr="true">border: 0;</string>
35 </property>
36 <property name="text">
37 <string/>
38@@ -202,9 +199,6 @@
39 <height>32</height>
40 </size>
41 </property>
42- <property name="flat">
43- <bool>true</bool>
44- </property>
45 </widget>
46 </item>
47 </layout>
48
49=== added file 'data/qt/device.ui'
50--- data/qt/device.ui 1970-01-01 00:00:00 +0000
51+++ data/qt/device.ui 2011-06-02 20:04:32 +0000
52@@ -0,0 +1,50 @@
53+<?xml version="1.0" encoding="UTF-8"?>
54+<ui version="4.0">
55+ <class>Form</class>
56+ <widget class="QWidget" name="Form">
57+ <property name="geometry">
58+ <rect>
59+ <x>0</x>
60+ <y>0</y>
61+ <width>400</width>
62+ <height>63</height>
63+ </rect>
64+ </property>
65+ <property name="windowTitle">
66+ <string>Form</string>
67+ </property>
68+ <layout class="QHBoxLayout" name="horizontalLayout">
69+ <item>
70+ <widget class="QLabel" name="device_icon_label">
71+ <property name="pixmap">
72+ <pixmap resource="images.qrc">:/computer.png</pixmap>
73+ </property>
74+ </widget>
75+ </item>
76+ <item>
77+ <widget class="QLabel" name="device_name_label">
78+ <property name="text">
79+ <string>Another device</string>
80+ </property>
81+ </widget>
82+ </item>
83+ <item>
84+ <spacer name="horizontalSpacer">
85+ <property name="orientation">
86+ <enum>Qt::Horizontal</enum>
87+ </property>
88+ <property name="sizeHint" stdset="0">
89+ <size>
90+ <width>217</width>
91+ <height>20</height>
92+ </size>
93+ </property>
94+ </spacer>
95+ </item>
96+ </layout>
97+ </widget>
98+ <resources>
99+ <include location="images.qrc"/>
100+ </resources>
101+ <connections/>
102+</ui>
103
104=== modified file 'data/qt/devices.ui'
105--- data/qt/devices.ui 2011-05-23 16:13:27 +0000
106+++ data/qt/devices.ui 2011-06-02 20:04:32 +0000
107@@ -42,105 +42,7 @@
108 </rect>
109 </property>
110 <layout class="QGridLayout" name="gridLayout_2">
111- <item row="0" column="0">
112- <layout class="QGridLayout" name="devices_grid_layout">
113- <item row="0" column="0">
114- <widget class="QLabel" name="device_icon_label">
115- <property name="text">
116- <string>(laptop icon, big)</string>
117- </property>
118- </widget>
119- </item>
120- <item row="0" column="1">
121- <widget class="QLabel" name="device_name_label">
122- <property name="text">
123- <string>Nessita's laptop</string>
124- </property>
125- </widget>
126- </item>
127- <item row="0" column="2">
128- <widget class="QPushButton" name="delete_device_button">
129- <property name="text">
130- <string>Delete device</string>
131- </property>
132- </widget>
133- </item>
134- <item row="1" column="0" colspan="3">
135- <layout class="QHBoxLayout" name="horizontalLayout">
136- <item>
137- <widget class="QLabel" name="other_devices_label">
138- <property name="text">
139- <string>Other devices connected to my cloud</string>
140- </property>
141- </widget>
142- </item>
143- <item>
144- <spacer name="horizontalSpacer">
145- <property name="orientation">
146- <enum>Qt::Horizontal</enum>
147- </property>
148- <property name="sizeHint" stdset="0">
149- <size>
150- <width>40</width>
151- <height>20</height>
152- </size>
153- </property>
154- </spacer>
155- </item>
156- <item>
157- <widget class="QPushButton" name="manage_devices_button">
158- <property name="text">
159- <string>Go to the web page to manage your other devices</string>
160- </property>
161- </widget>
162- </item>
163- </layout>
164- </item>
165- <item row="2" column="0">
166- <widget class="QLabel" name="sample_icon_1">
167- <property name="text">
168- <string>(laptop icon, smaller)</string>
169- </property>
170- </widget>
171- </item>
172- <item row="2" column="1">
173- <widget class="QLabel" name="sample_name_1">
174- <property name="text">
175- <string>Nessita's other laptop</string>
176- </property>
177- </widget>
178- </item>
179- <item row="3" column="0">
180- <widget class="QLabel" name="sample_icon_2">
181- <property name="text">
182- <string>(smartphone icon)</string>
183- </property>
184- </widget>
185- </item>
186- <item row="3" column="1">
187- <widget class="QLabel" name="sample_name_2">
188- <property name="text">
189- <string>Samsung Nexus S</string>
190- </property>
191- </widget>
192- </item>
193- <item row="4" column="0">
194- <widget class="QLabel" name="sample_icon_3">
195- <property name="text">
196- <string>(smartphone icon)</string>
197- </property>
198- </widget>
199- </item>
200- <item row="4" column="1">
201- <widget class="QLabel" name="sample_name_3">
202- <property name="text">
203- <string>iPhone 3GS</string>
204- </property>
205- </widget>
206- </item>
207- </layout>
208- </item>
209- <item row="1" column="0">
210+ <item row="8" column="0">
211 <spacer name="verticalSpacer">
212 <property name="orientation">
213 <enum>Qt::Vertical</enum>
214@@ -153,12 +55,86 @@
215 </property>
216 </spacer>
217 </item>
218+ <item row="6" column="0">
219+ <layout class="QHBoxLayout" name="horizontalLayout">
220+ <item>
221+ <widget class="QLabel" name="other_devices_label">
222+ <property name="text">
223+ <string>Other devices connected to my cloud</string>
224+ </property>
225+ </widget>
226+ </item>
227+ <item>
228+ <spacer name="horizontalSpacer">
229+ <property name="orientation">
230+ <enum>Qt::Horizontal</enum>
231+ </property>
232+ <property name="sizeHint" stdset="0">
233+ <size>
234+ <width>40</width>
235+ <height>20</height>
236+ </size>
237+ </property>
238+ </spacer>
239+ </item>
240+ <item>
241+ <widget class="QPushButton" name="manage_devices_button">
242+ <property name="text">
243+ <string>Go to the web page to manage your other devices</string>
244+ </property>
245+ </widget>
246+ </item>
247+ </layout>
248+ </item>
249+ <item row="1" column="0">
250+ <layout class="QHBoxLayout" name="horizontalLayout_2">
251+ <item>
252+ <widget class="QLabel" name="device_icon_label">
253+ <property name="pixmap">
254+ <pixmap resource="images.qrc">:/computer.png</pixmap>
255+ </property>
256+ </widget>
257+ </item>
258+ <item>
259+ <widget class="QLabel" name="device_name_label">
260+ <property name="text">
261+ <string>This device</string>
262+ </property>
263+ </widget>
264+ </item>
265+ <item>
266+ <spacer name="horizontalSpacer_2">
267+ <property name="orientation">
268+ <enum>Qt::Horizontal</enum>
269+ </property>
270+ <property name="sizeHint" stdset="0">
271+ <size>
272+ <width>40</width>
273+ <height>20</height>
274+ </size>
275+ </property>
276+ </spacer>
277+ </item>
278+ <item>
279+ <widget class="QPushButton" name="delete_device_button">
280+ <property name="text">
281+ <string>Delete device</string>
282+ </property>
283+ </widget>
284+ </item>
285+ </layout>
286+ </item>
287+ <item row="7" column="0">
288+ <layout class="QVBoxLayout" name="devices_list_verticallayout"/>
289+ </item>
290 </layout>
291 </widget>
292 </widget>
293 </item>
294 </layout>
295 </widget>
296- <resources/>
297+ <resources>
298+ <include location="images.qrc"/>
299+ </resources>
300 <connections/>
301 </ui>
302
303=== modified file 'data/qt/images.qrc'
304--- data/qt/images.qrc 2011-05-26 22:18:04 +0000
305+++ data/qt/images.qrc 2011-06-02 20:04:32 +0000
306@@ -1,5 +1,7 @@
307 <RCC>
308 <qresource prefix="/">
309+ <file>../computer.png</file>
310+ <file>../phone.png</file>
311 <file>../twitter.png</file>
312 <file>../facebook.png</file>
313 </qresource>
314
315=== modified file 'ubuntuone/controlpanel/gui/qt/controlpanel.py'
316--- ubuntuone/controlpanel/gui/qt/controlpanel.py 2011-06-02 13:14:51 +0000
317+++ ubuntuone/controlpanel/gui/qt/controlpanel.py 2011-06-02 20:04:32 +0000
318@@ -25,6 +25,26 @@
319 from ubuntuone.controlpanel.logger import setup_logging, log_call
320 from ubuntuone.controlpanel.gui.qt.ui import controlpanel_ui
321
322+SAMPLE_DEVICES_INFO = [
323+ {
324+ "type": "Computer",
325+ "name": "toshiba laptop",
326+ "is_local": True,
327+ "configurable": False,
328+ },
329+ {
330+ "type": "Computer",
331+ "name": "desktop i5",
332+ "is_local": False,
333+ "configurable": False,
334+ },
335+ {
336+ "type": "Phone",
337+ "name": "nokia 1100",
338+ "is_local": False,
339+ "configurable": False,
340+ },
341+]
342
343 logger = setup_logging('qt.controlpanel')
344
345@@ -42,12 +62,26 @@
346
347 logger.debug('%s: started.', self.__class__.__name__)
348 self.get_account_info()
349+ self.get_devices_info()
350
351 def get_account_info(self):
352 """Get and update the account info from the webservice."""
353 d = self.backend.account_info()
354 d.addCallback(self.got_account_info)
355
356+ def get_devices_info(self):
357+ """Get and update the list of devices."""
358+ # TODO: get the info from the backend
359+ # this should be changed when have a working dbus replacement on win32
360+ #d = self.backend.devices_info()
361+ #d.addCallback(self.got_devices_info)
362+ self.got_devices_info(SAMPLE_DEVICES_INFO)
363+
364+ @log_call(logger.debug)
365+ def got_devices_info(self, devices_info):
366+ """Set the account info in all tabs."""
367+ self.ui.devices_tab.update_devices_info(devices_info)
368+
369 @log_call(logger.debug)
370 def got_account_info(self, account_info):
371 """Set the account info in all tabs."""
372
373=== added file 'ubuntuone/controlpanel/gui/qt/device.py'
374--- ubuntuone/controlpanel/gui/qt/device.py 1970-01-01 00:00:00 +0000
375+++ ubuntuone/controlpanel/gui/qt/device.py 2011-06-02 20:04:32 +0000
376@@ -0,0 +1,58 @@
377+# -*- coding: utf-8 -*-
378+
379+# Author: Alejandro J. Cura <alecu@canonical.com>
380+#
381+# Copyright 2011 Canonical Ltd.
382+#
383+# This program is free software: you can redistribute it and/or modify it
384+# under the terms of the GNU General Public License version 3, as published
385+# by the Free Software Foundation.
386+#
387+# This program is distributed in the hope that it will be useful, but
388+# WITHOUT ANY WARRANTY; without even the implied warranties of
389+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
390+# PURPOSE. See the GNU General Public License for more details.
391+#
392+# You should have received a copy of the GNU General Public License along
393+# with this program. If not, see <http://www.gnu.org/licenses/>.
394+
395+"""The user interface for the control panel for Ubuntu One."""
396+
397+from PyQt4 import QtGui
398+
399+from ubuntuone.controlpanel.gui.qt.ui import device_ui
400+
401+COMPUTER_ICON = "computer"
402+PHONE_ICON = "phone"
403+DEFAULT_ICON = COMPUTER_ICON
404+
405+COMPUTER_TYPE = "Computer"
406+PHONE_TYPE = "Phone"
407+
408+DEVICE_TYPE_TO_ICON_MAP = {
409+ COMPUTER_TYPE: COMPUTER_ICON,
410+ PHONE_TYPE: PHONE_ICON,
411+}
412+
413+
414+def icon_name_from_type(device_type):
415+ """Get the icon name for the device."""
416+ icon_name = DEVICE_TYPE_TO_ICON_MAP.get(device_type, DEFAULT_ICON)
417+ return ":/%s.png" % icon_name
418+
419+
420+class DeviceWidget(QtGui.QWidget):
421+ """The widget for each device in the control panel."""
422+
423+ def __init__(self, *args):
424+ """Initialize the UI of the widget."""
425+ QtGui.QWidget.__init__(self, *args)
426+ self.ui = device_ui.Ui_Form()
427+ self.ui.setupUi(self)
428+
429+ def update_device_info(self, device_info):
430+ """Update the device info."""
431+ self.ui.device_name_label.setText(device_info["name"])
432+ pixmap_name = icon_name_from_type(device_info["type"])
433+ pixmap = QtGui.QPixmap(pixmap_name)
434+ self.ui.device_icon_label.setPixmap(pixmap)
435
436=== modified file 'ubuntuone/controlpanel/gui/qt/devices.py'
437--- ubuntuone/controlpanel/gui/qt/devices.py 2011-05-24 14:20:18 +0000
438+++ ubuntuone/controlpanel/gui/qt/devices.py 2011-06-02 20:04:32 +0000
439@@ -21,6 +21,7 @@
440 from PyQt4 import QtGui
441
442 from ubuntuone.controlpanel.gui.qt.ui import devices_ui
443+from ubuntuone.controlpanel.gui.qt.device import DeviceWidget
444
445
446 class DevicesPanel(QtGui.QWidget):
447@@ -31,3 +32,25 @@
448 QtGui.QWidget.__init__(self, *args)
449 self.ui = devices_ui.Ui_Form()
450 self.ui.setupUi(self)
451+
452+ def update_local_device(self, device_info):
453+ """Update the info for the local device."""
454+ self.ui.device_name_label.setText(device_info["name"])
455+
456+ def create_remote_device(self, device_info):
457+ """Add a remote device to the list."""
458+ device_widget = DeviceWidget()
459+ device_widget.update_device_info(device_info)
460+ self.ui.devices_list_verticallayout.addWidget(device_widget)
461+
462+ def update_device_info(self, device_info):
463+ """Update one device."""
464+ if device_info["is_local"]:
465+ self.update_local_device(device_info)
466+ else:
467+ self.create_remote_device(device_info)
468+
469+ def update_devices_info(self, devices_info):
470+ """Update the list of devices in this panel."""
471+ for device_info in devices_info:
472+ self.update_device_info(device_info)
473
474=== modified file 'ubuntuone/controlpanel/gui/qt/tests/__init__.py'
475--- ubuntuone/controlpanel/gui/qt/tests/__init__.py 2011-06-02 04:03:02 +0000
476+++ ubuntuone/controlpanel/gui/qt/tests/__init__.py 2011-06-02 20:04:32 +0000
477@@ -34,6 +34,31 @@
478 "email": SAMPLE_EMAIL,
479 "type": SAMPLE_PLAN,
480 }
481+
482+SAMPLE_COMPUTER_INFO = {
483+ "type": "Computer",
484+ "name": "desktop i5",
485+ "is_local": False,
486+ "configurable": False,
487+}
488+
489+SAMPLE_PHONE_INFO = {
490+ "type": "Phone",
491+ "name": "nokia 1100",
492+ "is_local": False,
493+ "configurable": False,
494+}
495+
496+SAMPLE_DEVICES_INFO = [
497+ {
498+ "type": "Computer",
499+ "name": "toshiba laptop",
500+ "is_local": True,
501+ "configurable": False,
502+ },
503+ SAMPLE_COMPUTER_INFO,
504+ SAMPLE_PHONE_INFO,
505+]
506 NO_OP = lambda *args: None
507
508
509
510=== modified file 'ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py'
511--- ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py 2011-06-02 13:14:51 +0000
512+++ ubuntuone/controlpanel/gui/qt/tests/test_controlpanel.py 2011-06-02 20:04:32 +0000
513@@ -20,7 +20,7 @@
514
515 from ubuntuone.controlpanel.gui.qt import controlpanel as gui
516 from ubuntuone.controlpanel.gui.qt.tests import (BaseTestCase, NO_OP,
517- SAMPLE_ACCOUNT_INFO)
518+ SAMPLE_ACCOUNT_INFO, SAMPLE_DEVICES_INFO)
519
520
521 class ControlPanelTestCase(BaseTestCase):
522@@ -33,6 +33,7 @@
523 def setUp(self):
524 """Initialize this test instance."""
525 self.patch(gui.ControlPanel, "get_account_info", NO_OP)
526+ self.patch(gui.ControlPanel, "get_devices_info", NO_OP)
527 super(ControlPanelTestCase, self).setUp()
528
529 def test_backend(self):
530@@ -55,3 +56,11 @@
531 self.ui.got_account_info(SAMPLE_ACCOUNT_INFO)
532 expected = ((SAMPLE_ACCOUNT_INFO,), {})
533 self.assertEqual(self._called, expected)
534+
535+ def test_got_devices_info_updates_devices(self):
536+ """Test the got_device_info method."""
537+ self.patch(self.ui.ui.devices_tab, "update_devices_info",
538+ self._set_called)
539+ self.ui.got_devices_info(SAMPLE_DEVICES_INFO)
540+ expected = ((SAMPLE_DEVICES_INFO,), {})
541+ self.assertEqual(self._called, expected)
542
543=== added file 'ubuntuone/controlpanel/gui/qt/tests/test_device.py'
544--- ubuntuone/controlpanel/gui/qt/tests/test_device.py 1970-01-01 00:00:00 +0000
545+++ ubuntuone/controlpanel/gui/qt/tests/test_device.py 2011-06-02 20:04:32 +0000
546@@ -0,0 +1,81 @@
547+# -*- coding: utf-8 -*-
548+
549+# Author: Alejandro J. Cura <alecu@canonical.com>
550+#
551+# Copyright 2011 Canonical Ltd.
552+#
553+# This program is free software: you can redistribute it and/or modify it
554+# under the terms of the GNU General Public License version 3, as published
555+# by the Free Software Foundation.
556+#
557+# This program is distributed in the hope that it will be useful, but
558+# WITHOUT ANY WARRANTY; without even the implied warranties of
559+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
560+# PURPOSE. See the GNU General Public License for more details.
561+#
562+# You should have received a copy of the GNU General Public License along
563+# with this program. If not, see <http://www.gnu.org/licenses/>.
564+
565+"""Tests for each device widget."""
566+
567+from PyQt4 import QtGui, QtCore
568+
569+from ubuntuone.controlpanel.gui.qt import device as gui
570+from ubuntuone.controlpanel.gui.qt.tests import (BaseTestCase,
571+ SAMPLE_COMPUTER_INFO, SAMPLE_PHONE_INFO)
572+
573+
574+class DeviceWidgetTestCase(BaseTestCase):
575+ """Test the qt control panel."""
576+
577+ innerclass_ui = gui.device_ui
578+ innerclass_name = "Ui_Form"
579+ class_ui = gui.DeviceWidget
580+
581+ def test_update_device_info(self):
582+ """The widget is updated with the info."""
583+ info = SAMPLE_COMPUTER_INFO
584+ expected_name = info["name"]
585+ self.ui.update_device_info(info)
586+ self.assertEqual(self.ui.ui.device_name_label.text(), expected_name)
587+
588+ # pylint: disable=C0103
589+ def assertIconMatchesType(self, device_type, base_icon_name):
590+ """A given device type yields the right icon."""
591+ icon_name = ":/%s.png" % base_icon_name
592+ self.assertEqual(gui.icon_name_from_type(device_type), icon_name)
593+
594+ def test_icon_name_from_type(self):
595+ """Get the right icon name for a device type."""
596+ self.assertIconMatchesType(gui.COMPUTER_TYPE, gui.COMPUTER_ICON)
597+ self.assertIconMatchesType(gui.PHONE_TYPE, gui.PHONE_ICON)
598+ self.assertIconMatchesType("other random type", gui.COMPUTER_ICON)
599+
600+ def get_pixmap_data(self, pixmap):
601+ """Get the raw data of a QPixmap."""
602+ byte_array = QtCore.QByteArray()
603+ array_buffer = QtCore.QBuffer(byte_array)
604+ pixmap.save(array_buffer, "PNG")
605+ return byte_array
606+
607+ def assertEqualPixmaps(self, pixmap1, pixmap2):
608+ """Compare two Qt pixmaps."""
609+ d1 = self.get_pixmap_data(pixmap1)
610+ d2 = self.get_pixmap_data(pixmap2)
611+ self.assertEqual(d1, d2)
612+
613+ def _test_update_device_info_sets_right_icon(self, info):
614+ """The widget is updated with the right icon."""
615+ self.ui.update_device_info(info)
616+ pixmap_name = gui.icon_name_from_type(info["type"])
617+ expected_pixmap = QtGui.QPixmap(pixmap_name)
618+ label_pixmap = self.ui.ui.device_icon_label.pixmap()
619+ self.assertEqualPixmaps(label_pixmap, expected_pixmap)
620+
621+ def test_update_device_info_sets_computer_icon(self):
622+ """The computer icon is set."""
623+ self._test_update_device_info_sets_right_icon(SAMPLE_COMPUTER_INFO)
624+
625+ def test_update_device_info_sets_phone_icon(self):
626+ """The phone icon is set."""
627+ self._test_update_device_info_sets_right_icon(SAMPLE_PHONE_INFO)
628
629=== added file 'ubuntuone/controlpanel/gui/qt/tests/test_devices.py'
630--- ubuntuone/controlpanel/gui/qt/tests/test_devices.py 1970-01-01 00:00:00 +0000
631+++ ubuntuone/controlpanel/gui/qt/tests/test_devices.py 2011-06-02 20:04:32 +0000
632@@ -0,0 +1,40 @@
633+# -*- coding: utf-8 -*-
634+
635+# Author: Alejandro J. Cura <alecu@canonical.com>
636+#
637+# Copyright 2011 Canonical Ltd.
638+#
639+# This program is free software: you can redistribute it and/or modify it
640+# under the terms of the GNU General Public License version 3, as published
641+# by the Free Software Foundation.
642+#
643+# This program is distributed in the hope that it will be useful, but
644+# WITHOUT ANY WARRANTY; without even the implied warranties of
645+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
646+# PURPOSE. See the GNU General Public License for more details.
647+#
648+# You should have received a copy of the GNU General Public License along
649+# with this program. If not, see <http://www.gnu.org/licenses/>.
650+
651+"""Tests for the devices tab."""
652+
653+from ubuntuone.controlpanel.gui.qt import devices as gui
654+from ubuntuone.controlpanel.gui.qt.tests import (BaseTestCase,
655+ SAMPLE_DEVICES_INFO)
656+
657+
658+class DevicesPanelTestCase(BaseTestCase):
659+ """Test the qt control panel."""
660+
661+ innerclass_ui = gui.devices_ui
662+ innerclass_name = "Ui_Form"
663+ class_ui = gui.DevicesPanel
664+
665+ def test_update_devices_info(self):
666+ """The widget is updated with the info."""
667+ container = self.ui.ui.devices_list_verticallayout
668+ self.assertEqual(container.count(), 0)
669+ self.ui.update_devices_info(SAMPLE_DEVICES_INFO)
670+ expected_name = SAMPLE_DEVICES_INFO[0]["name"]
671+ self.assertEqual(self.ui.ui.device_name_label.text(), expected_name)
672+ self.assertEqual(container.count(), len(SAMPLE_DEVICES_INFO) - 1)

Subscribers

People subscribed via source and target branches