Exemplo n.º 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')
Exemplo n.º 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')
Exemplo n.º 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'])
Exemplo n.º 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'])
Exemplo n.º 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')
Exemplo n.º 6
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')