~nataliabidart/ubuntu/oneiric/ubuntuone-control-panel/ubuntuone-control-panel-2.0.0

« back to all changes in this revision

Viewing changes to ubuntuone/controlpanel/gtk/tests/test_gui.py

  • Committer: Bazaar Package Importer
  • Author(s): Natalia Bidart (nessita), Natalia B. Bidart, Chris McGinlay
  • Date: 2011-02-28 15:38:15 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20110228153815-p21dfuark327vxei
Tags: 0.9.0-0ubuntu1
* New upstream release:
  [ Natalia B. Bidart <natalia.bidart@canonical.com> ]
    - General 'Account' tab cleanup (LP: #718629).
    - 'Get support' button has now a better location (LP: #706661).
    - Account frames have now the same width (LP: #715825).
    - Tooltip for support button is now set (LP: #715883).
  [ Chris McGinlay <chris@ascentsoftware.org.uk> ]
    - Implement tooltips for Connect/Disconnect and Account/Cloud/Devices
    (LP:715820).

* debian/control:
  - ubunutone-control-panel-gtk also depends on ubuntuone-client (>= 1.5.4).

Show diffs side-by-side

added added

removed removed

Lines of Context:
2052
2052
 
2053
2053
    klass = gui.FileSyncStatus
2054
2054
 
2055
 
    def assert_status_correct(self, status, action=None, callback=None):
 
2055
    def assert_status_correct(self, status, action=None,
 
2056
                              callback=None, tooltip=None):
2056
2057
        """The shown status is correct.
2057
2058
 
2058
2059
        * The ui's label shows 'status'.
2059
2060
        * If action is not None, the ui's button shows that 'action' as label
2060
2061
        and when clicking it, 'self._set_called' gets executed.
2061
2062
        * If action is None, the ui's button should be hidden.
 
2063
        * If a tooltip is required, then it exists with correct text.
2062
2064
 
2063
2065
        """
2064
2066
        self.assertTrue(self.ui.label.get_visible())
2080
2082
        else:
2081
2083
            self.assertFalse(self.ui.button.get_visible())
2082
2084
 
 
2085
        if tooltip is not None:
 
2086
            self.assertTrue(self.ui.button.get_has_tooltip())
 
2087
            self.assertEqual(self.ui.button.get_tooltip_text(), tooltip)
 
2088
        else:
 
2089
            self.assertFalse(self.ui.button.get_has_tooltip())
 
2090
 
2083
2091
    def test_is_a_box(self):
2084
2092
        """Inherits from gtk.Box."""
2085
2093
        self.assertIsInstance(self.ui, gui.gtk.Box)
2121
2129
        self.assert_backend_called('file_sync_status', ())
2122
2130
 
2123
2131
    def test_on_file_sync_status_disabled(self):
2124
 
        """The file sync is disabled."""
 
2132
        """The file sync is disabled.
 
2133
 
 
2134
        * The correct connection status is displayed.
 
2135
        * The button has a tooltip with correct text.
 
2136
 
 
2137
        """
2125
2138
        self.patch(self.ui, 'on_enable_clicked', self._set_called)
2126
2139
        self.ui.on_file_sync_status_disabled('msg')
2127
2140
 
2128
2141
        self.assert_status_correct(self.ui.FILE_SYNC_DISABLED,
2129
 
                                   action=self.ui.ENABLE)
 
2142
                                   action=self.ui.ENABLE,
 
2143
                                   tooltip=self.ui.ENABLE_TOOLTIP)
2130
2144
 
2131
2145
    def test_on_file_sync_status_starting(self):
2132
 
        """The file sync status is starting."""
 
2146
        """The file sync status is starting.
 
2147
 
 
2148
        * The correct connection status is displayed.
 
2149
        * The button has a tooltip with correct text.
 
2150
 
 
2151
        """
2133
2152
        self.patch(self.ui, 'on_stop_clicked', self._set_called)
2134
2153
        self.ui.on_file_sync_status_starting('msg')
2135
2154
 
2136
2155
        self.assert_status_correct(self.ui.FILE_SYNC_STARTING,
2137
 
                                   action=self.ui.STOP)
 
2156
                                   action=self.ui.STOP,
 
2157
                                   tooltip=self.ui.STOP_TOOLTIP)
2138
2158
 
2139
2159
    def test_on_file_sync_status_stopped(self):
2140
 
        """The file sync is stopped."""
 
2160
        """The file sync is stopped.
 
2161
 
 
2162
        * The correct connection status is displayed.
 
2163
        * The button has a tooltip with correct text.
 
2164
 
 
2165
        """
2141
2166
        self.patch(self.ui, 'on_start_clicked', self._set_called)
2142
2167
        self.ui.on_file_sync_status_stopped('msg')
2143
2168
 
2144
2169
        self.assert_status_correct(self.ui.FILE_SYNC_STOPPED,
2145
 
                                   action=self.ui.START)
 
2170
                                   action=self.ui.START,
 
2171
                                   tooltip=self.ui.START_TOOLTIP)
2146
2172
 
2147
2173
    def test_on_file_sync_status_disconnected(self):
2148
 
        """The file sync status is disconnected."""
 
2174
        """The file sync status is disconnected.
 
2175
 
 
2176
        * The correct connection status is displayed.
 
2177
        * The button has a tooltip with correct text.
 
2178
 
 
2179
        """
2149
2180
        self.patch(self.ui, 'on_connect_clicked', self._set_called)
2150
2181
        self.ui.on_file_sync_status_disconnected('msg')
2151
2182
 
2152
2183
        self.assert_status_correct(self.ui.FILE_SYNC_DISCONNECTED,
2153
 
                                   action=self.ui.CONNECT)
 
2184
                                   action=self.ui.CONNECT,
 
2185
                                   tooltip=self.ui.CONNECT_TOOLTIP)
2154
2186
 
2155
2187
    def test_on_file_sync_status_syncing(self):
2156
 
        """The file sync status is syncing."""
 
2188
        """The file sync status is syncing.
 
2189
 
 
2190
        * The correct connection status is displayed.
 
2191
        * The button has a tooltip with correct text.
 
2192
 
 
2193
        """
2157
2194
        self.patch(self.ui, 'on_disconnect_clicked', self._set_called)
2158
2195
        self.ui.on_file_sync_status_syncing('msg')
2159
2196
 
2160
2197
        self.assert_status_correct(self.ui.FILE_SYNC_SYNCING,
2161
 
                                   action=self.ui.DISCONNECT)
 
2198
                                   action=self.ui.DISCONNECT,
 
2199
                                   tooltip=self.ui.DISCONNECT_TOOLTIP)
2162
2200
 
2163
2201
    def test_on_file_sync_status_idle(self):
2164
 
        """The file sync status is idle."""
 
2202
        """The file sync status is idle.
 
2203
 
 
2204
        * The correct connection status is displayed.
 
2205
        * The button has a tooltip with correct text.
 
2206
 
 
2207
        """
2165
2208
        self.patch(self.ui, 'on_disconnect_clicked', self._set_called)
2166
2209
        self.ui.on_file_sync_status_idle('msg')
2167
2210
 
2168
2211
        self.assert_status_correct(self.ui.FILE_SYNC_IDLE,
2169
 
                                   action=self.ui.DISCONNECT)
 
2212
                                   action=self.ui.DISCONNECT,
 
2213
                                   tooltip=self.ui.DISCONNECT_TOOLTIP)
2170
2214
 
2171
2215
    def test_on_file_sync_status_error(self):
2172
2216
        """The file sync status couldn't be retrieved."""
2174
2218
        self.ui.on_file_sync_status_error({'error_msg': 'error msg'})
2175
2219
 
2176
2220
        msg = gui.WARNING_MARKUP % self.ui.FILE_SYNC_ERROR
2177
 
        self.assert_status_correct(msg, action=self.ui.RESTART)
 
2221
        self.assert_status_correct(msg,
 
2222
                                   action=self.ui.RESTART,
 
2223
                                   tooltip=self.ui.RESTART_TOOLTIP)
2178
2224
 
2179
2225
    def test_on_files_start_error(self):
2180
2226
        """The files service could not be started."""
2396
2442
 
2397
2443
        self.assertEqual(self._called, ((self.ui,), {}))
2398
2444
 
2399
 
    def test_dashboard_button_name(self):
 
2445
    def test_button_names(self):
2400
2446
        """The dashboard_button widget has the proper name."""
2401
 
        self.assertEqual(self.ui.dashboard_button.get_name(),
2402
 
                         self.ui.DASHBOARD_BUTTON_NAME)
2403
 
 
2404
 
    def test_devices_button_name(self):
2405
 
        """The devices_button widget has the proper name."""
2406
 
        self.assertEqual(self.ui.devices_button.get_name(),
2407
 
                         self.ui.DEVICES_BUTTON_NAME)
 
2447
        for tab in (u'dashboard', u'services'):
 
2448
            actual = getattr(self.ui, '%s_button' % tab).get_name()
 
2449
            expected = getattr(self.ui, '%s_BUTTON_NAME' % tab.upper())
 
2450
            self.assertEqual(actual, expected)
 
2451
 
 
2452
    def test_devices_button_tooltip(self):
 
2453
        """The devices button widget has the proper tooltip."""
 
2454
        for tab in self.ui.tabs:
 
2455
            has_tooltip = getattr(self.ui, '%s_button' % tab).get_has_tooltip()
 
2456
            self.assertTrue(has_tooltip,
 
2457
                            '%s_button should have a tooltip set' % tab)
 
2458
 
 
2459
            actual = getattr(self.ui, '%s_button' % tab).get_tooltip_text()
 
2460
            expected = getattr(self.ui, '%s_BUTTON_TOOLTIP' % tab.upper())
 
2461
            self.assertEqual(actual, expected)