53
53
self.assertEqual('after', button.props.label)
56
class GtkUIFactoryTestCase(tests.TestCase):
59
ui_factory = ui.GtkUIFactory()
60
self.assertIs(None, ui_factory._progress_bar_widget)
62
def test_set_progress_bar_widget(self):
63
ui_factory = ui.GtkUIFactory()
64
progress_widget = ui.ProgressPanel()
65
ui_factory.set_progress_bar_widget(progress_widget)
66
self.assertIs(progress_widget, ui_factory._progress_bar_widget)
68
def test_get_boolean_true(self):
69
ui_factory = ui.GtkUIFactory()
70
MockMethod.bind(self, ui.PromptDialog, 'run', Gtk.ResponseType.YES)
71
boolean_value = ui_factory.get_boolean('test')
72
self.assertIs(True, ui.PromptDialog.run.called)
73
self.assertIs(True, boolean_value)
75
def test_get_boolean_false(self):
76
ui_factory = ui.GtkUIFactory()
77
MockMethod.bind(self, ui.PromptDialog, 'run', Gtk.ResponseType.NO)
78
boolean_value = ui_factory.get_boolean('test')
79
self.assertIs(True, ui.PromptDialog.run.called)
80
self.assertIs(False, boolean_value)
82
def test_show_message(self):
83
ui_factory = ui.GtkUIFactory()
84
MockMethod.bind(self, ui.InfoDialog, 'run', Gtk.ResponseType.CLOSE)
85
ui_factory.show_message('test')
86
self.assertIs(True, ui.InfoDialog.run.called)
88
def test_show_warning(self):
89
ui_factory = ui.GtkUIFactory()
90
MockMethod.bind(self, ui.WarningDialog, 'run', Gtk.ResponseType.CLOSE)
91
ui_factory.show_warning('test')
92
self.assertIs(True, ui.WarningDialog.run.called)
94
def test_get_password(self):
95
ui_factory = ui.GtkUIFactory()
96
MockMethod.bind(self, ui.PasswordDialog, 'run', Gtk.ResponseType.OK)
97
mock_property = MockProperty.bind(
98
self, ui.PasswordDialog, 'passwd', 'secret')
99
password = ui_factory.get_password('test')
100
self.assertIs(True, ui.PasswordDialog.run.called)
101
self.assertIs(True, mock_property.called)
102
self.assertEqual('secret', password)
104
def test_progress_all_finished_with_widget(self):
105
ui_factory = ui.GtkUIFactory()
106
progress_widget = ui.ProgressPanel()
107
MockMethod.bind(self, progress_widget, 'finished')
108
ui_factory.set_progress_bar_widget(progress_widget)
109
self.assertIs(None, ui_factory._progress_all_finished())
110
self.assertIs(True, progress_widget.finished.called)
112
def test_progress_all_finished_without_widget(self):
113
ui_factory = ui.GtkUIFactory()
114
self.assertIs(None, ui_factory._progress_all_finished())
116
def test_progress_updated_with_widget(self):
117
ui_factory = ui.GtkUIFactory()
118
progress_widget = ui.ProgressPanel()
119
MockMethod.bind(self, progress_widget, 'update')
120
ui_factory.set_progress_bar_widget(progress_widget)
121
task = ProgressTask()
125
self.assertIs(None, ui_factory._progress_updated(task))
126
self.assertIs(True, progress_widget.update.called)
128
('test', 1, 2), progress_widget.update.args)
130
def test_progress_updated_without_widget(self):
131
ui_factory = ui.GtkUIFactory()
132
MockMethod.bind(self, ui.ProgressBarWindow, 'update')
133
task = ProgressTask()
137
self.assertIs(None, ui_factory._progress_updated(task))
138
self.assertIsInstance(
139
ui_factory._progress_bar_widget, ui.ProgressBarWindow)
140
self.assertIs(True, ui_factory._progress_bar_widget.update.called)
142
('test', 1, 2), ui_factory._progress_bar_widget.update.args)
144
def test_report_transport_activity_with_widget(self):
145
ui_factory = ui.GtkUIFactory()
146
progress_widget = ui.ProgressPanel()
147
MockMethod.bind(self, progress_widget, 'tick')
148
ui_factory.set_progress_bar_widget(progress_widget)
150
None, ui_factory.report_transport_activity(None, None, None))
151
self.assertIs(True, progress_widget.tick.called)
153
def test_report_transport_activity_without_widget(self):
154
ui_factory = ui.GtkUIFactory()
155
MockMethod.bind(self, ui.ProgressBarWindow, 'tick')
157
None, ui_factory.report_transport_activity(None, None, None))
158
self.assertIsInstance(
159
ui_factory._progress_bar_widget, ui.ProgressBarWindow)
160
self.assertIs(True, ui.ProgressBarWindow.tick.called)
163
56
class PromptDialogTestCase(tests.TestCase):
165
58
def test_init(self):
341
234
widgets = pb_window.get_children()
342
235
# The image's stock and icon_name properties are always None?
343
236
self.assertIsInstance(widgets[0], Gtk.Image)
239
class GtkUIFactoryTestCase(tests.TestCase):
241
def test__init(self):
242
ui_factory = ui.GtkUIFactory()
243
self.assertIs(None, ui_factory._progress_bar_widget)
245
def test_set_progress_bar_widget(self):
246
ui_factory = ui.GtkUIFactory()
247
progress_widget = ui.ProgressPanel()
248
ui_factory.set_progress_bar_widget(progress_widget)
249
self.assertIs(progress_widget, ui_factory._progress_bar_widget)
251
def test_get_boolean_true(self):
252
ui_factory = ui.GtkUIFactory()
253
MockMethod.bind(self, ui.PromptDialog, 'run', Gtk.ResponseType.YES)
254
boolean_value = ui_factory.get_boolean('test')
255
self.assertIs(True, ui.PromptDialog.run.called)
256
self.assertIs(True, boolean_value)
258
def test_get_boolean_false(self):
259
ui_factory = ui.GtkUIFactory()
260
MockMethod.bind(self, ui.PromptDialog, 'run', Gtk.ResponseType.NO)
261
boolean_value = ui_factory.get_boolean('test')
262
self.assertIs(True, ui.PromptDialog.run.called)
263
self.assertIs(False, boolean_value)
265
def test_show_message(self):
266
ui_factory = ui.GtkUIFactory()
267
MockMethod.bind(self, ui.InfoDialog, 'run', Gtk.ResponseType.CLOSE)
268
ui_factory.show_message('test')
269
self.assertIs(True, ui.InfoDialog.run.called)
271
def test_show_warning(self):
272
ui_factory = ui.GtkUIFactory()
273
MockMethod.bind(self, ui.WarningDialog, 'run', Gtk.ResponseType.CLOSE)
274
ui_factory.show_warning('test')
275
self.assertIs(True, ui.WarningDialog.run.called)
277
def test_get_password(self):
278
ui_factory = ui.GtkUIFactory()
279
MockMethod.bind(self, ui.PasswordDialog, 'run', Gtk.ResponseType.OK)
280
mock_property = MockProperty.bind(
281
self, ui.PasswordDialog, 'passwd', 'secret')
282
password = ui_factory.get_password('test')
283
self.assertIs(True, ui.PasswordDialog.run.called)
284
self.assertIs(True, mock_property.called)
285
self.assertEqual('secret', password)
287
def test_progress_all_finished_with_widget(self):
288
ui_factory = ui.GtkUIFactory()
289
progress_widget = ui.ProgressPanel()
290
MockMethod.bind(self, progress_widget, 'finished')
291
ui_factory.set_progress_bar_widget(progress_widget)
292
self.assertIs(None, ui_factory._progress_all_finished())
293
self.assertIs(True, progress_widget.finished.called)
295
def test_progress_all_finished_without_widget(self):
296
ui_factory = ui.GtkUIFactory()
297
self.assertIs(None, ui_factory._progress_all_finished())
299
def test_progress_updated_with_widget(self):
300
ui_factory = ui.GtkUIFactory()
301
progress_widget = ui.ProgressPanel()
302
MockMethod.bind(self, progress_widget, 'update')
303
ui_factory.set_progress_bar_widget(progress_widget)
304
task = ProgressTask()
308
self.assertIs(None, ui_factory._progress_updated(task))
309
self.assertIs(True, progress_widget.update.called)
311
('test', 1, 2), progress_widget.update.args)
313
def test_progress_updated_without_widget(self):
314
ui_factory = ui.GtkUIFactory()
315
MockMethod.bind(self, ui.ProgressBarWindow, 'update')
316
task = ProgressTask()
320
self.assertIs(None, ui_factory._progress_updated(task))
321
self.assertIsInstance(
322
ui_factory._progress_bar_widget, ui.ProgressBarWindow)
323
self.assertIs(True, ui_factory._progress_bar_widget.update.called)
325
('test', 1, 2), ui_factory._progress_bar_widget.update.args)
327
def test_report_transport_activity_with_widget(self):
328
ui_factory = ui.GtkUIFactory()
329
progress_widget = ui.ProgressPanel()
330
MockMethod.bind(self, progress_widget, 'tick')
331
ui_factory.set_progress_bar_widget(progress_widget)
333
None, ui_factory.report_transport_activity(None, None, None))
334
self.assertIs(True, progress_widget.tick.called)
336
def test_report_transport_activity_without_widget(self):
337
ui_factory = ui.GtkUIFactory()
338
MockMethod.bind(self, ui.ProgressBarWindow, 'tick')
340
None, ui_factory.report_transport_activity(None, None, None))
341
self.assertIsInstance(
342
ui_factory._progress_bar_widget, ui.ProgressBarWindow)
343
self.assertIs(True, ui.ProgressBarWindow.tick.called)