~ralsina/ubuntuone-control-panel/unique-3-0

« back to all changes in this revision

Viewing changes to ubuntuone/controlpanel/gui/qt/tests/test_devices.py

  • Committer: Tarmac
  • Author(s): Roberto Alsina, Natalia B. Bidart, Diego Sarmentero, Rodney Dawes, Manuel de la Pena
  • Date: 2012-03-21 12:08:57 UTC
  • mfrom: (253.1.1 stable-3-0-update-2.99.91)
  • Revision ID: tarmac-20120321120857-59wljazelpl4nemj
- Updating from trunk up to revno 292:

[ Manuel de la Pena <manuel.delapena@canonical.com> ]
  - Added the app name from ubuntu one to be used in the webclient
    so that it is shown in the sso ui (LP: #952880).

[ Natalia B. Bidart <natalia.bidart@canonical.com> ]
  - Added the "License" page to the wizard (part of LP: #933697).
    So far is not visible from a regular run, will be enabled for
    windows only in another branch.
  - Added 'Computer to cloud' page to the wizard
    (part of LP: #933697).
  - Tweaked the title of the aforementioned page (LP: #888521).
  - Added 'Cloud to computer' page to the initial wizard
    (part of LP: #933697).
  - Added a confirmation dialog to quit the wizard
    (part of LP: #933697).
  - Implemented a method to list the user's default folders in
    every platform (part of LP: #933697).
  - Apply new specification for tabbing navigation and tabbing style
    (LP: #942020).
  - Make the "Explore" buttons for folders be disabled (style-wise)
    when the folder is not synched (LP: #949035).
  - Removed first line from the man page for the qt control panel
    so is detected as such and installed (LP: #948970).

[ Roberto Alsina <roberto.alsina@canonical.com> ]
  - Added several tweaks to the UI stylesheet to avoid 'movements'
    when focusing a button, and to remove the ugly border from the
    twitter and facebook buttons.
  - Enable platform-specific styling (LP: #953318).
  - Truncate the argument list at argv[0] before passing to argparse
    (LP: #956143).
  - Arranged Tab ordering in folders tab according to guidelines
    (LP: #950073).
  - Fixed tests so they work under non-english locales (LP: #951716).
  - Enabled Qt translation engine so standard dialogs are translated
    (LP: #951651).
  - Switched to the native file chooser on Linux (LP: #947711).
  - Fixed --alert and --switch-to tabname and updated --help and
    manpage accordingly (LP: #940465).

[ Rodney Dawes <rodney.dawes@canonical.com> ]
  - Don't hard-code the font sizes (LP: #942025, LP: #953062).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# -*- coding: utf-8 -*-
2
 
 
3
 
# Author: Alejandro J. Cura <alecu@canonical.com>
4
2
#
5
 
# Copyright 2011 Canonical Ltd.
 
3
# Copyright 2011-2012 Canonical Ltd.
6
4
#
7
5
# This program is free software: you can redistribute it and/or modify it
8
6
# under the terms of the GNU General Public License version 3, as published
63
61
    def test_no_devices_at_startup(self):
64
62
        """The UI is reset at startup."""
65
63
        self.assertEqual(self.ui.ui.list_devices.count(), 0)
66
 
        self.assertEqual(self.ui.ui.local_device_box.count(), 0)
67
64
 
68
65
    def test_process_info(self):
69
66
        """The widget is updated with the info."""
71
68
 
72
69
        local, remote = SAMPLE_DEVICES_INFO[0], SAMPLE_DEVICES_INFO[1:]
73
70
 
74
 
        self.assertEqual(self.ui.ui.local_device_box.count(), 1)
75
 
        local_device = self.ui.ui.local_device_box.itemAt(0).widget()
76
 
        self.assertEqual(local_device.ui.device_name_label.text(),
77
 
                         local['name'])
 
71
        local_device = self.ui.ui.local_device
 
72
        self.assertEqual(unicode(local_device.text()), local['name'])
78
73
        self.assertEqual(local_device.id, local['device_id'])
79
74
 
80
75
        self.assertEqual(self.ui.ui.list_devices.count(),
82
77
        for i, remote_device in enumerate(remote):
83
78
            item = self.ui.ui.list_devices.item(i)
84
79
            device = self.ui.ui.list_devices.itemWidget(item)
85
 
            self.assertEqual(device.text(), remote_device['name'])
86
 
 
87
 
    def test_remove_device_and_check_layout_state(self):
88
 
        """Test if the widget is properly removed."""
89
 
        self.ui.process_info(SAMPLE_DEVICES_INFO)
90
 
        self.ui.show()
91
 
 
92
 
        self.assertEqual(self.ui.ui.local_device_box.count(), 1)
93
 
        local_device = self.ui.ui.local_device_box.itemAt(0).widget()
94
 
        self.executed = False
95
 
 
96
 
        def delete_later(reference=None):
97
 
            """Fake delete later."""
98
 
            self.executed = True
99
 
        self.patch(local_device, "deleteLater", delete_later)
100
 
        self.ui.clear_device_info(self.ui.ui.local_device_box)
101
 
        self.ui.process_info(SAMPLE_DEVICES_INFO)
102
 
        self.assertEqual(self.ui.ui.local_device_box.count(), 1)
103
 
        local_device2 = self.ui.ui.local_device_box.itemAt(0).widget()
104
 
        self.assertNotEqual(local_device, local_device2)
105
 
        self.assertTrue(self.executed)
106
 
        self.assertFalse(local_device.isVisible())
 
80
            self.assertEqual(unicode(device.text()), remote_device['name'])
 
81
 
 
82
    def test_local_device(self):
 
83
        """Test if the local_device widget is properly packed."""
 
84
        self.ui.process_info(SAMPLE_DEVICES_INFO)
 
85
 
 
86
        local_device = self.ui.ui.local_device_layout.itemAt(0).widget()
 
87
        self.assertIs(local_device, self.ui.ui.local_device)
107
88
 
108
89
    def test_process_info_twice(self):
109
90
        """The widget is updated with the info."""
115
96
        self.assert_uri_hook_called(self.ui.ui.manage_devices_button,
116
97
                                    gui.EDIT_DEVICES_LINK)
117
98
 
118
 
    def test_remove_device_widget_after_removal(self):
119
 
        """When a device widget was deleted, remove it from the UI."""
 
99
    def test_local_device_removed_clears_the_widget(self):
 
100
        """When the local device was deleted, clear it."""
120
101
        self.ui.process_info(SAMPLE_DEVICES_INFO)
121
102
 
122
 
        local_device = self.ui.ui.local_device_box.itemAt(0).widget()
123
 
        local_device.removed.emit()
 
103
        self.ui.ui.local_device.removed.emit()
124
104
 
125
 
        self.assertTrue(self.ui.ui.local_device_box.itemAt(0) is None)
 
105
        self.assertEqual(unicode(self.ui.ui.local_device.text()), '')
 
106
        self.assertEqual(self.ui.ui.local_device.id, None)
126
107
 
127
108
    def test_local_device_removed_signal(self):
128
109
        """When the local device is removed, emit localDeviceRemoved signal."""
129
110
        self.ui.localDeviceRemoved.connect(self._set_called)
130
111
        self.ui.process_info(SAMPLE_DEVICES_INFO)
131
112
 
132
 
        local_device = self.ui.ui.local_device_box.itemAt(0).widget()
133
 
        local_device.removed.emit()
 
113
        self.ui.ui.local_device.removed.emit()
134
114
 
135
115
        self.assertEqual(self._called, ((), {}))