def test_question_dialog(self): from ubiquity.frontend import gtk_ui ui = gtk_ui.Wizard('test-ubiquity') with mock.patch('gi.repository.Gtk.Dialog.run') as run: run.return_value = 0 ret = ui.question_dialog(title='♥', msg='♥', options=('♥', '£')) self.assertEqual(ret, '£') run.return_value = 1 ret = ui.question_dialog(title='♥', msg='♥', options=('♥', '£')) self.assertEqual(ret, '♥')
def test_pages_fit_on_a_netbook(self): from ubiquity.frontend import gtk_ui with test_support.EnvironmentVarGuard() as env: env['UBIQUITY_MIGRATION_ASSISTANT'] = '1' ui = gtk_ui.Wizard('test-ubiquity') ui.translate_pages() for page in ui.pages: ui.set_page(page.module.NAME) ui.refresh() ui.refresh() if 'UBIQUITY_TEST_SHOW_ALL_PAGES' in os.environ: print(page.module.NAME) import time time.sleep(3) alloc = ui.live_installer.get_allocation() self.assertLessEqual(alloc.width, 640) self.assertLessEqual(alloc.height, 500) if page.module.NAME == 'partman': ui.allow_change_step(False)
def test_pages_fit_on_a_netbook(self): from ubiquity.frontend import gtk_ui ui = gtk_ui.Wizard('test-ubiquity') ui.translate_pages() for page in ui.pages: ui.set_page(page.module.NAME) ui.refresh() ui.refresh() if 'UBIQUITY_TEST_SHOW_ALL_PAGES' in os.environ: print(page.module.NAME) import time time.sleep(3) alloc = ui.live_installer.get_allocation() # width 640, because it is a common small 4:3 width # height 556, because e.g. HP Mini has 580 - 24px (indicators) # Anything smaller will need to use Alt+Ctrl+Pgd/Right # Scrollbars anyone? # self.assertLessEqual(alloc.width, 640, page.module.NAME) # fixme self.assertLessEqual(alloc.height, 556, page.module.NAME) if page.module.NAME == 'partman': ui.allow_change_step(False)
def test_interface_translated(self): import subprocess from gi.repository import Gtk from ubiquity.frontend import gtk_ui ui = gtk_ui.Wizard('test-ubiquity') missing_translations = [] with mock.patch.object(ui, 'translate_widget') as translate_widget: def side_effect(widget, lang=None, prefix=None): label = isinstance(widget, Gtk.Label) button = isinstance(widget, Gtk.Button) # We have some checkbuttons without labels. button = button and widget.get_label() # Stock buttons. button = button and not widget.get_use_stock() window = isinstance(widget, Gtk.Window) if not (label or button or window): return name = widget.get_name() if not ui.get_string(name, lang, prefix): missing_translations.append(name) translate_widget.side_effect = side_effect ui.translate_widgets() whitelist = [ # These are calculated and set as the partitioning options are # being calculated. 'reuse_partition_desc', 'reuse_partition', 'replace_partition_desc', 'replace_partition', 'resize_use_free_desc', 'resize_use_free', 'use_device_desc', 'use_device', 'part_ask_heading', 'custom_partitioning_desc', 'custom_partitioning', # Pulled straight from debconf when the installation medium is # already mounted. 'part_advanced_warning_message', # These are calculated and set inside info_loop in the user # setup page. 'password_strength', 'hostname_error_label', 'password_error_label', 'username_error_label', # Pulled straight from debconf into the UI on progress. 'install_progress_text', # Contains just the traceback. 'crash_detail_label', # Pages define a debconf template to look up and use as the # title. If it is not set or not found, the title is hidden. 'page_title', # To be calculated and set 'partition_lvm_status', # These are "placeholders" for debconfs impromptu notices 'ubi_question_dialog', 'question_label', # Calculated error string 'label_global_error', 'warning_password_label', 'label1', 'secureboot_label', # secure boot 'disable_secureboot', 'prepare_foss_disclaimer_license', 'label_free_space', 'label_required_space', 'label_download_updates', ] deb_host_arch = subprocess.Popen( ['dpkg-architecture', '-qDEB_HOST_ARCH'], stdout=subprocess.PIPE, universal_newlines=True).communicate()[0].strip() if deb_host_arch not in ('amd64', 'i386'): # grub-installer not available, but this template won't be # displayed anyway. whitelist.append('grub_device_label') missing_translations = set(missing_translations) - set(whitelist) missing_translations = list(missing_translations) if missing_translations: missing_translations = ', '.join(missing_translations) raise Exception('Missing translation for:\n%s' % missing_translations)