Exemple #1
0
    def test_search_driver_enable(self):
        '''D-BUS API: Search for a driver which gets enabled'''

        ui = sandbox.TestUI()
        self.stop_capture()

        ui.backend().handlers['kmod:vanilla3d'].package = 'mesa-vanilla'

        # don't enable the driver
        result = ui.search_driver(
            'modalias:pci:v00001001d00003D0sv0sd0bc03sc0i0')
        self.assertEqual(set(ui.get_displayed_handlers()),
                         set(['kmod:vanilla3d', 'kmod:vanilla']))
        self.assertEqual(result, (False, []))
        self.assertEqual(
            ui.backend().handler_info('kmod:vanilla3d')['enabled'], 'False')

        # enable it now
        ui.ui_main_loop = lambda: ui.set_handler_enable(
            'kmod:vanilla3d', 'enable', False, False
        )  # fake main loop to enable kmod:vanilla3d
        result = ui.search_driver(
            'modalias:pci:v00001001d00003D0sv0sd0bc03sc0i0')
        self.assertEqual(set(ui.get_displayed_handlers()),
                         set(['kmod:vanilla3d', 'kmod:vanilla']))
        self.assertEqual(
            result,
            (True, sandbox.fake_pkginfo['default']['mesa-vanilla']['files']))
        self.assertEqual(
            ui.backend().handler_info('kmod:vanilla3d')['enabled'], 'True')
Exemple #2
0
    def test_search_driver_enable(self):
        '''D-BUS API: Search for a driver which gets enabled'''

        ui = sandbox.TestUI()
        self.stop_capture()

        ui.backend().handlers['kmod:vanilla3d'].package = 'mesa-vanilla'

        # don't enable the driver
        result = ui.search_driver('modalias:pci:v00001001d00003D0sv0sd0bc03sc0i0')
        self.assertEqual(set(ui.get_displayed_handlers()),
            set(['kmod:vanilla3d', 'kmod:vanilla']))
        self.assertEqual(result, (False, []))
        self.assertEqual(ui.backend().handler_info('kmod:vanilla3d')['enabled'],
            'False')

        # enable it now
        ui.ui_main_loop = lambda: ui.set_handler_enable('kmod:vanilla3d',
            'enable', False, False) # fake main loop to enable kmod:vanilla3d
        result = ui.search_driver('modalias:pci:v00001001d00003D0sv0sd0bc03sc0i0')
        self.assertEqual(set(ui.get_displayed_handlers()),
            set(['kmod:vanilla3d', 'kmod:vanilla']))
        self.assertEqual(result, (True, sandbox.fake_pkginfo['default']['mesa-vanilla']['files']))
        self.assertEqual(ui.backend().handler_info('kmod:vanilla3d')['enabled'],
            'True')
Exemple #3
0
    def test_search_driver_errors(self):
        '''D-BUS API: Search for drivers which cannot be enabled'''

        ui = sandbox.TestUI()
        self.stop_capture()

        # does not exist
        self.assertEqual(ui.search_driver('unknown:foo'), (False, []))
        self.assertEqual(ui.get_displayed_handlers(), [])

        # kmod:vanilla, already enabled
        self.assertEqual(ui.search_driver(
            'modalias:pci:v00001001d0sv0sd0bc03sc00i00'), (False, []))
        self.assertEqual(ui.get_displayed_handlers(), ['kmod:vanilla'])
Exemple #4
0
    def test_search_driver_errors(self):
        '''D-BUS API: Search for drivers which cannot be enabled'''

        ui = sandbox.TestUI()
        self.stop_capture()

        # does not exist
        self.assertEqual(ui.search_driver('unknown:foo'), (False, []))
        self.assertEqual(ui.get_displayed_handlers(), [])

        # kmod:vanilla, already enabled
        self.assertEqual(
            ui.search_driver('modalias:pci:v00001001d0sv0sd0bc03sc00i00'),
            (False, []))
        self.assertEqual(ui.get_displayed_handlers(), ['kmod:vanilla'])
Exemple #5
0
    def test_search_driver_disabled(self):
        '''D-BUS API: Search for a noninstalled driver'''

        # search_driver() should not display available==True handlers
        open(os.path.join(OSLib.inst.handler_dir, 'kmod_avail.py'),
             'w').write(sandbox.h_availability_py)
        ui = sandbox.TestUI()

        self.assert_('kmod:spam' not in ui.backend().available())

        sandbox.start_driverdb_server()
        try:
            ui.backend().add_driverdb('XMLRPCDriverDB',
                                      ['http://localhost:8080'])
            # first match is kmod:mint:UbuOne in our fake db
            result = ui.search_driver('pci:9876/FEDC')
        finally:
            sandbox.stop_driverdb_server()

        self.stop_capture()
        self.assertEqual(result, (False, []))
        self.assertEqual(ui.get_displayed_handlers(), ['kmod:spam'])

        info = ui.backend().handler_info('kmod:spam')
        self.assertEqual(info['enabled'], 'True')
Exemple #6
0
    def test_mode_any(self):
        '''calling with --mode any'''

        sys.argv = ['ui-test', '--list', '--mode', 'any']
        ui = sandbox.TestUI()
        self.assertEqual(sandbox.TestUI().run(), 0)
        displayed = set(ui.get_displayed_handlers())

        self.stop_capture()

        self.assertEqual(len(self.stdout.strip().splitlines()), 5)
        self.assert_('free module with available hardware, graphics card' in self.stdout)
        self.assert_('kmod:mint ' in self.stdout)
        self.assert_('kmod:vanilla ' in self.stdout)
        self.assert_('kmod:vanilla3d ' in self.stdout)
        self.assert_('kmod:firmwifi ' in self.stdout)

        self.assertEqual(displayed, set(['kmod:mint', 'kmod:vanilla',
            'kmod:vanilla3d', 'kmod:firmwifi', 'kmod:foodmi']))

        # mint is not enabled by default
        self.failIf('Restricted' in ui.main_window_title())
        (h, s) = ui.main_window_text()
        self.assert_('No proprietary drivers are in use' in h)
        self.assert_('cannot fix or improve' in s)

        # enable mint
        ui.backend().set_enabled('kmod:mint', True)
        (h, s) = ui.main_window_text()
        self.assert_('Proprietary drivers are being used' in h)
        self.assert_('cannot fix or improve' in s)
Exemple #7
0
    def test_mode_nonfree(self):
        '''calling with --mode nonfree'''

        sys.argv = ['ui-test', '--list', '--mode', 'nonfree']
        ui = sandbox.TestUI()
        self.assertEqual(sandbox.TestUI().run(), 0)
        displayed = set(ui.get_displayed_handlers())
        self.stop_capture()

        self.assertEqual(displayed, set(['kmod:mint', 'kmod:vanilla3d']))

        self.assertEqual(len(self.stdout.strip().splitlines()), 2)
        self.assert_('kmod:vanilla3d ' in self.stdout)
        self.assert_('kmod:mint ' in self.stdout)

        self.assert_('Restricted' in ui.main_window_title())

        (h, s) = ui.main_window_text()
        self.assert_('No proprietary drivers are in use' in h, h)
        self.assert_('cannot fix or improve' in s)
Exemple #8
0
    def test_mode_nonfree(self):
        '''calling with --mode nonfree'''

        sys.argv = ['ui-test', '--list', '--mode', 'nonfree']
        ui = sandbox.TestUI()
        self.assertEqual(sandbox.TestUI().run(), 0)
        displayed = set(ui.get_displayed_handlers())
        self.stop_capture()

        self.assertEqual(displayed, set(['kmod:mint', 'kmod:vanilla3d']))

        self.assertEqual(len(self.stdout.strip().splitlines()), 2)
        self.assert_('kmod:vanilla3d ' in self.stdout)
        self.assert_('kmod:mint ' in self.stdout)

        self.assert_('Restricted' in ui.main_window_title())

        (h, s) = ui.main_window_text()
        self.assert_('No proprietary drivers are in use' in h, h)
        self.assert_('cannot fix or improve' in s)
Exemple #9
0
    def test_mode_free(self):
        '''calling with --mode free'''

        sys.argv = ['ui-test', '--list', '--mode', 'free']
        ui = sandbox.TestUI()
        self.assertEqual(sandbox.TestUI().run(), 0)
        displayed = set(ui.get_displayed_handlers())
        self.stop_capture()

        self.assertEqual(displayed, set(['kmod:vanilla',
            'kmod:firmwifi', 'kmod:foodmi']))

        self.assertEqual(len(self.stdout.strip().splitlines()), 3)
        self.assert_('free module with available hardware, graphics card' in self.stdout)
        self.assert_('kmod:vanilla ' in self.stdout)
        self.assert_('kmod:firmwifi ' in self.stdout)
        self.assert_('kmod:foodmi ' in self.stdout)

        self.failIf('Restricted' in ui.main_window_title())

        (h, s) = ui.main_window_text()
        self.assert_('No proprietary drivers are in use' in h)
        self.assertEqual(s, '')
Exemple #10
0
    def test_mode_free(self):
        '''calling with --mode free'''

        sys.argv = ['ui-test', '--list', '--mode', 'free']
        ui = sandbox.TestUI()
        self.assertEqual(sandbox.TestUI().run(), 0)
        displayed = set(ui.get_displayed_handlers())
        self.stop_capture()

        self.assertEqual(displayed,
                         set(['kmod:vanilla', 'kmod:firmwifi', 'kmod:foodmi']))

        self.assertEqual(len(self.stdout.strip().splitlines()), 3)
        self.assert_('free module with available hardware, graphics card' in
                     self.stdout)
        self.assert_('kmod:vanilla ' in self.stdout)
        self.assert_('kmod:firmwifi ' in self.stdout)
        self.assert_('kmod:foodmi ' in self.stdout)

        self.failIf('Restricted' in ui.main_window_title())

        (h, s) = ui.main_window_text()
        self.assert_('No proprietary drivers are in use' in h)
        self.assertEqual(s, '')
Exemple #11
0
    def test_mode_any(self):
        '''calling with --mode any'''

        sys.argv = ['ui-test', '--list', '--mode', 'any']
        ui = sandbox.TestUI()
        self.assertEqual(sandbox.TestUI().run(), 0)
        displayed = set(ui.get_displayed_handlers())

        self.stop_capture()

        self.assertEqual(len(self.stdout.strip().splitlines()), 5)
        self.assert_('free module with available hardware, graphics card' in
                     self.stdout)
        self.assert_('kmod:mint ' in self.stdout)
        self.assert_('kmod:vanilla ' in self.stdout)
        self.assert_('kmod:vanilla3d ' in self.stdout)
        self.assert_('kmod:firmwifi ' in self.stdout)

        self.assertEqual(
            displayed,
            set([
                'kmod:mint', 'kmod:vanilla', 'kmod:vanilla3d', 'kmod:firmwifi',
                'kmod:foodmi'
            ]))

        # mint is not enabled by default
        self.failIf('Restricted' in ui.main_window_title())
        (h, s) = ui.main_window_text()
        self.assert_('No proprietary drivers are in use' in h)
        self.assert_('cannot fix or improve' in s)

        # enable mint
        ui.backend().set_enabled('kmod:mint', True)
        (h, s) = ui.main_window_text()
        self.assert_('Proprietary drivers are being used' in h)
        self.assert_('cannot fix or improve' in s)
Exemple #12
0
    def test_search_driver_disabled(self):
        '''D-BUS API: Search for a noninstalled driver'''

        # search_driver() should not display available==True handlers
        open (os.path.join(OSLib.inst.handler_dir, 'kmod_avail.py'), 'w').write(
            sandbox.h_availability_py)
        ui = sandbox.TestUI()

        self.assert_('kmod:spam' not in ui.backend().available())

        sandbox.start_driverdb_server()
        try:
            ui.backend().add_driverdb('XMLRPCDriverDB', ['http://localhost:8080'])
            # first match is kmod:mint:UbuOne in our fake db
            result = ui.search_driver('pci:9876/FEDC')
        finally:
            sandbox.stop_driverdb_server()

        self.stop_capture()
        self.assertEqual(result, (False, []))
        self.assertEqual(ui.get_displayed_handlers(), ['kmod:spam'])

        info = ui.backend().handler_info('kmod:spam')
        self.assertEqual(info['enabled'], 'True')