13
12
for obj in ('ubiquity.misc.drop_privileges',
14
13
'ubiquity.misc.regain_privileges',
15
14
'ubiquity.misc.execute',
15
'ubiquity.misc.dmimodel',
16
16
'ubiquity.frontend.base.drop_privileges',
17
17
'ubiquity.frontend.gtk_ui.Wizard.customize_installer',
18
18
'ubiquity.nm.wireless_hardware_present',
19
19
'ubiquity.nm.NetworkManager.start',
20
20
'ubiquity.nm.NetworkManager.get_state',
21
'ubiquity.misc.add_connection_watch',
22
21
'ubiquity.misc.has_connection',
23
22
'ubiquity.upower.setup_power_watch',
24
'dbus.mainloop.glib.DBusGMainLoop'):
23
'dbus.mainloop.glib.DBusGMainLoop',
24
'gi.repository.UbiquityWebcam.Webcam.available',
25
'ubiquity.i18n.reset_locale',
25
27
patcher = mock.patch(obj)
28
patched_obj = patcher.start()
27
29
self.addCleanup(patcher.stop)
28
30
if obj in ('ubiquity.misc.wireless_hardware_present',
29
31
'ubiquity.misc.has_connection'):
30
patcher.return_value = False
32
patched_obj.return_value = False
33
elif obj == 'gi.repository.UbiquityWebcam.Webcam.available':
34
patched_obj.return_value = True
35
elif obj == 'ubiquity.i18n.reset_locale':
36
patched_obj.return_value = 'en_US.UTF-8'
32
38
def test_question_dialog(self):
33
39
from ubiquity.frontend import gtk_ui
42
48
options=(u'♥', u'£'))
43
49
self.assertEqual(ret, u'♥')
51
# TODO: I'm not entirely sure this makes sense, but the numbers are
52
# currently rather unstable and seem to depend quite a lot on the theme.
53
# This may have something to do with pixmaps not being set up properly
54
# when testing against a build tree.
55
@unittest.skipIf('UBIQUITY_TEST_INSTALLED' in os.environ,
56
'only testable against a build tree')
45
57
def test_pages_fit_on_a_netbook(self):
46
from gi.repository import Gtk, GObject
47
58
from ubiquity.frontend import gtk_ui
48
ui = gtk_ui.Wizard('test-ubiquity')
51
GObject.timeout_add(250, Gtk.main_quit)
53
alloc = ui.live_installer.get_allocation()
55
self.assertLessEqual(alloc.width, 640)
56
self.assertLessEqual(alloc.height, 500)
59
with test_support.EnvironmentVarGuard() as env:
60
env['UBIQUITY_MIGRATION_ASSISTANT'] = '1'
61
ui = gtk_ui.Wizard('test-ubiquity')
64
ui.set_page(page.module.NAME)
67
if 'UBIQUITY_TEST_SHOW_ALL_PAGES' in os.environ:
68
print(page.module.NAME)
71
alloc = ui.live_installer.get_allocation()
72
self.assertLessEqual(alloc.width, 640)
73
self.assertLessEqual(alloc.height, 500)
74
if page.module.NAME == 'partman':
75
ui.allow_change_step(False)
58
77
def test_interface_translated(self):
61
80
from gi.repository import Gtk
62
81
ui = gtk_ui.Wizard('test-ubiquity')
63
82
missing_translations = []
64
with mock.patch_object(ui, 'translate_widget') as translate_widget:
83
with mock.patch.object(ui, 'translate_widget') as translate_widget:
65
84
def side_effect(widget, lang=None, prefix=None):
66
85
label = isinstance(widget, Gtk.Label)
67
86
button = isinstance(widget, Gtk.Button)