2053
2053
klass = gui.FileSyncStatus
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.
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.
2064
2066
self.assertTrue(self.ui.label.get_visible())
2121
2129
self.assert_backend_called('file_sync_status', ())
2123
2131
def test_on_file_sync_status_disabled(self):
2124
"""The file sync is disabled."""
2132
"""The file sync is disabled.
2134
* The correct connection status is displayed.
2135
* The button has a tooltip with correct text.
2125
2138
self.patch(self.ui, 'on_enable_clicked', self._set_called)
2126
2139
self.ui.on_file_sync_status_disabled('msg')
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)
2131
2145
def test_on_file_sync_status_starting(self):
2132
"""The file sync status is starting."""
2146
"""The file sync status is starting.
2148
* The correct connection status is displayed.
2149
* The button has a tooltip with correct text.
2133
2152
self.patch(self.ui, 'on_stop_clicked', self._set_called)
2134
2153
self.ui.on_file_sync_status_starting('msg')
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)
2139
2159
def test_on_file_sync_status_stopped(self):
2140
"""The file sync is stopped."""
2160
"""The file sync is stopped.
2162
* The correct connection status is displayed.
2163
* The button has a tooltip with correct text.
2141
2166
self.patch(self.ui, 'on_start_clicked', self._set_called)
2142
2167
self.ui.on_file_sync_status_stopped('msg')
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)
2147
2173
def test_on_file_sync_status_disconnected(self):
2148
"""The file sync status is disconnected."""
2174
"""The file sync status is disconnected.
2176
* The correct connection status is displayed.
2177
* The button has a tooltip with correct text.
2149
2180
self.patch(self.ui, 'on_connect_clicked', self._set_called)
2150
2181
self.ui.on_file_sync_status_disconnected('msg')
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)
2155
2187
def test_on_file_sync_status_syncing(self):
2156
"""The file sync status is syncing."""
2188
"""The file sync status is syncing.
2190
* The correct connection status is displayed.
2191
* The button has a tooltip with correct text.
2157
2194
self.patch(self.ui, 'on_disconnect_clicked', self._set_called)
2158
2195
self.ui.on_file_sync_status_syncing('msg')
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)
2163
2201
def test_on_file_sync_status_idle(self):
2164
"""The file sync status is idle."""
2202
"""The file sync status is idle.
2204
* The correct connection status is displayed.
2205
* The button has a tooltip with correct text.
2165
2208
self.patch(self.ui, 'on_disconnect_clicked', self._set_called)
2166
2209
self.ui.on_file_sync_status_idle('msg')
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)
2171
2215
def test_on_file_sync_status_error(self):
2172
2216
"""The file sync status couldn't be retrieved."""
2397
2443
self.assertEqual(self._called, ((self.ui,), {}))
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)
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)
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)
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)