~nataliabidart/ubuntuone-control-panel/focus

« back to all changes in this revision

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

  • Committer: Natalia B. Bidart
  • Date: 2012-03-08 20:46:13 UTC
  • Revision ID: natalia.bidart@canonical.com-20120308204613-5ey17ooq2kgkvvb1
- Apply new specification for tabbing navigation and tabbing style
  (LP: #942020).

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
36
34
 
37
35
 
38
36
class DeviceWidgetTestCase(BaseTestCase):
39
 
    """Test the qt control panel."""
 
37
    """Test the DeviceWidget class."""
40
38
 
41
39
    innerclass_ui = gui.device_ui
42
40
    innerclass_name = "Ui_Form"
46
44
    logger = gui.logger
47
45
 
48
46
    def test_has_id(self):
49
 
        """The device as an id, None by default."""
 
47
        """The device as an id accepted as creation param."""
50
48
        self.assertEqual(self.ui.id, self.device_id)
51
49
 
 
50
    def test_id_can_be_none(self):
 
51
        """The device id is None by default."""
 
52
        ui = self.class_ui()
 
53
        self.assertEqual(ui.id, None)
 
54
 
 
55
    def test_setting_id_to_none_disables_remove_button(self):
 
56
        """If the id is set to None, the remove button is disabled."""
 
57
        self.ui.id = None
 
58
        self.assertFalse(self.ui.ui.remove_device_button.isEnabled())
 
59
 
 
60
    def test_setting_id_to_not_none_enables_remove_button(self):
 
61
        """If the id is set to not None, the remove button is enabled."""
 
62
        self.ui.id = 'not None'
 
63
        self.assertTrue(self.ui.ui.remove_device_button.isEnabled())
 
64
 
 
65
    def test_remove_button(self):
 
66
        """The remove button is visible."""
 
67
        self.assertTrue(self.ui.ui.remove_device_button.isVisible())
 
68
 
52
69
    def test_update_device_info(self):
53
70
        """The widget is updated with the info."""
54
71
        info = SAMPLE_COMPUTER_INFO
68
85
        self.assertIconMatchesType(gui.DEVICE_TYPE_PHONE, gui.PHONE_ICON)
69
86
        self.assertIconMatchesType("other random type", gui.COMPUTER_ICON)
70
87
 
71
 
    def _test_update_device_info_sets_right_icon(self, info):
 
88
    def assert_update_device_info_sets_right_icon(self, info):
72
89
        """The widget is updated with the right icon."""
73
90
        self.ui.update_device_info(info)
74
91
        pixmap_name = gui.icon_name_from_type(info["type"])
78
95
 
79
96
    def test_update_device_info_sets_computer_icon(self):
80
97
        """The computer icon is set."""
81
 
        self._test_update_device_info_sets_right_icon(SAMPLE_COMPUTER_INFO)
 
98
        self.assert_update_device_info_sets_right_icon(SAMPLE_COMPUTER_INFO)
82
99
 
83
100
    def test_update_device_info_sets_phone_icon(self):
84
101
        """The phone icon is set."""
85
 
        self._test_update_device_info_sets_right_icon(SAMPLE_PHONE_INFO)
86
 
 
87
 
    def test_get_device_for_list_widget(self):
88
 
        """The the item list values returned."""
89
 
        info = SAMPLE_COMPUTER_INFO
90
 
        item = gui.get_device_for_list_widget(info)
91
 
        self.assertEqual(item.text(), info["name"])
92
 
 
93
 
        info = SAMPLE_PHONE_INFO
94
 
        item = gui.get_device_for_list_widget(info)
95
 
        self.assertEqual(item.text(), info["name"])
 
102
        self.assert_update_device_info_sets_right_icon(SAMPLE_PHONE_INFO)
96
103
 
97
104
 
98
105
class RemoveDeviceTestCase(DeviceWidgetTestCase):
161
168
        yield self.ui.ui.remove_device_button.click()
162
169
 
163
170
        self.assertTrue(self.memento.check_exception(CrashyBackendException))
 
171
 
 
172
 
 
173
class RemoteDeviceWidgetTestCase(DeviceWidgetTestCase):
 
174
    """Test the RemoteDeviceWidget class."""
 
175
 
 
176
    class_ui = gui.RemoteDeviceWidget
 
177
 
 
178
    def test_remove_button(self):
 
179
        """The remove button is hidden."""
 
180
        self.assertFalse(self.ui.ui.remove_device_button.isVisible())