Example #1
0
    def test_enable(self):
        '''calling with --enable'''

        open (os.path.join(OSLib.inst.handler_dir, 'h.py'), 'w').write(
            sandbox.h_availability_py)
        
        # disable mint driver and verify that in --list
        sys.argv = ['ui-test', '--list']
        ui = sandbox.TestUI()
        ui.backend().set_enabled('kmod:mint', False)
        self.assertEqual(ui.run(), 0)

        # enable it using the CLI
        sys.argv = ['ui-test', '--enable', 'kmod:mint']
        ui = sandbox.TestUI()
        self.assertEqual(ui.run(), 0)

        self.stop_capture()

        mint_disabled = False
        for l in self.stdout.strip().splitlines():
            if l.startswith('kmod:mint'):
                if ui.string_disabled in l:
                    mint_disabled = True
                break
        self.assert_(mint_disabled)

        for h in ui.backend().available():
            self.assert_(jockey.ui.bool(ui.backend().handler_info(h)['enabled']))
Example #2
0
    def test_enable(self):
        '''calling with --enable'''

        open(os.path.join(OSLib.inst.handler_dir, 'h.py'),
             'w').write(sandbox.h_availability_py)

        # disable mint driver and verify that in --list
        sys.argv = ['ui-test', '--list']
        ui = sandbox.TestUI()
        ui.backend().set_enabled('kmod:mint', False)
        self.assertEqual(ui.run(), 0)

        # enable it using the CLI
        sys.argv = ['ui-test', '--enable', 'kmod:mint']
        ui = sandbox.TestUI()
        self.assertEqual(ui.run(), 0)

        self.stop_capture()

        mint_disabled = False
        for l in self.stdout.strip().splitlines():
            if l.startswith('kmod:mint'):
                if ui.string_disabled in l:
                    mint_disabled = True
                break
        self.assert_(mint_disabled)

        for h in ui.backend().available():
            self.assert_(
                jockey.ui.bool(ui.backend().handler_info(h)['enabled']))
Example #3
0
    def test_check_composite_avail(self):
        '''calling with --check-composite and available driver'''

        sys.argv = ['ui-test', '--check-composite']
        ui = sandbox.TestUI()

        class XorgComp(XorgDriverHandler):
            def __init__(self, ui):
                XorgDriverHandler.__init__(self, ui, 'vanilla3d',
                                           'mesa-vanilla', 'v3d', 'vanilla')

            def enables_composite(self):
                return True

        h = XorgComp(ui.backend())
        h_id = h.id()
        self.failIf(h.enabled())
        ui.backend().handlers[h_id] = h

        ui.confirm_response = True
        self.assertEqual(ui.run(), 0)

        self.stop_capture()
        self.assert_(jockey.ui.bool(
            ui.backend().handler_info(h_id)['enabled']))
Example #4
0
    def test_check_composite_enabled(self):
        '''calling with --check-composite and already enabled driver'''

        sys.argv = ['ui-test', '--check-composite']
        ui = sandbox.TestUI()

        class XorgComp(XorgDriverHandler):
            def __init__(self, ui):
                XorgDriverHandler.__init__(self, ui, 'vanilla3d',
                                           'mesa-vanilla', 'v3d', 'vanilla')

            def enables_composite(self):
                return True

            def enabled(self):
                return True

        h = XorgComp(ui)
        ui.backend().handlers[h.id()] = h

        # note: do not set confirm_response here, shouldn't ask
        self.assertEqual(ui.run(), 1)

        self.stop_capture()
        self.assert_('already supports' in self.stderr, self.stderr)
Example #5
0
    def test_enable_invalid(self):
        '''calling with --enable on a nonexisting handler'''

        sys.argv = ['ui-test', '--enable', 'kmod:unknown']
        ui = sandbox.TestUI()
        self.assertNotEqual(ui.run(), 0)
        self.stop_capture()
        self.assert_(ui.string_unknown_driver in self.stderr)
        self.assert_('--list' in self.stderr)
Example #6
0
    def test_enable_invalid(self):
        '''calling with --enable on a nonexisting handler'''

        sys.argv = ['ui-test', '--enable', 'kmod:unknown']
        ui = sandbox.TestUI()
        self.assertNotEqual(ui.run(), 0)
        self.stop_capture()
        self.assert_(ui.string_unknown_driver in self.stderr)
        self.assert_('--list' in self.stderr)
Example #7
0
    def test_update(self):
        '''calling with --update'''

        sys.argv = ['ui-test', '--update']
        ui = sandbox.TestUI()
        ui.backend().driver_dbs.append(sandbox.TestDriverDB())
        self.assertEqual(ui.run(), 0)

        self.stop_capture()

        handlers = ui.backend().available()
        self.assert_('kmod:vanilla3d' in handlers)  # from LocalKMod
        self.assert_('kmod:spam' in handlers)  # from TestDriverDB
Example #8
0
    def test_update(self):
        '''calling with --update'''

        sys.argv = ['ui-test', '--update']
        ui = sandbox.TestUI()
        ui.backend().driver_dbs.append(sandbox.TestDriverDB())
        self.assertEqual(ui.run(), 0)

        self.stop_capture()

        handlers = ui.backend().available()
        self.assert_('kmod:vanilla3d' in handlers) # from LocalKMod
        self.assert_('kmod:spam' in handlers) # from TestDriverDB
Example #9
0
    def test_check_auto_install(self):
        '''calling with --auto-install'''

        open(os.path.join(OSLib.inst.handler_dir, 'h.py'),
             'w').write(sandbox.h_auto_install_mod)

        ui = sandbox.TestUI()
        for h in ui.backend().available():
            if ui.backend().handler_info(h)['enabled']:
                ui.backend().set_enabled(h, False)
        self.assertEqual(ui.run(), 0)
        self.stop_capture()

        sys.argv = ['ui-test', '--auto-install']
        ui = sandbox.TestUI()
        self.assertEqual(ui.run(), 0)

        for h in ui.backend().available():
            enabled = jockey.ui.bool(ui.backend().handler_info(h)['enabled'])
            if h == 'kmod:vanilla':
                self.assert_(enabled)
            else:
                self.assert_(not enabled, '%s shouldn\'t be enabled' % h)
Example #10
0
    def test_disable_confirm_cancel(self):
        '''calling with --disable --confirm cancelling'''

        open (os.path.join(OSLib.inst.handler_dir, 'h.py'), 'w').write(
            sandbox.h_availability_py)

        sys.argv = ['ui-test', '--confirm', '--disable', 'kmod:mint']
        ui = sandbox.TestUI()
        ui.confirm_response = False
        self.assertEqual(ui.run(), 1)
        self.stop_capture()

        for h in ui.backend().available():
            self.assert_(jockey.ui.bool(ui.backend().handler_info(h)['enabled']))
Example #11
0
    def test_disable(self):
        '''calling with --disable'''

        open(os.path.join(OSLib.inst.handler_dir, 'h.py'),
             'w').write(sandbox.h_availability_py)

        sys.argv = ['ui-test', '--disable', 'kmod:mint']
        ui = sandbox.TestUI()
        self.assertEqual(ui.run(), 0)
        self.stop_capture()

        for h in ui.backend().available():
            en = jockey.ui.bool(ui.backend().handler_info(h)['enabled'])
            self.assertEqual(en, h != 'kmod:mint')
Example #12
0
    def test_disable(self):
        '''calling with --disable'''

        open (os.path.join(OSLib.inst.handler_dir, 'h.py'), 'w').write(
            sandbox.h_availability_py)

        sys.argv = ['ui-test', '--disable', 'kmod:mint']
        ui = sandbox.TestUI()
        self.assertEqual(ui.run(), 0)
        self.stop_capture()

        for h in ui.backend().available():
            en = jockey.ui.bool(ui.backend().handler_info(h)['enabled'])
            self.assertEqual(en, h != 'kmod:mint')
Example #13
0
    def test_check_auto_install(self):
        '''calling with --auto-install'''

        open (os.path.join(OSLib.inst.handler_dir, 'h.py'), 'w').write(
            sandbox.h_auto_install_mod)

        ui = sandbox.TestUI()
        for h in ui.backend().available():
            if ui.backend().handler_info(h)['enabled']:
                ui.backend().set_enabled(h, False)
        self.assertEqual(ui.run(), 0)
        self.stop_capture()

        sys.argv = ['ui-test', '--auto-install']
        ui = sandbox.TestUI()
        self.assertEqual(ui.run(), 0)

        for h in ui.backend().available():
            enabled = jockey.ui.bool(ui.backend().handler_info(h)['enabled'])
            if h == 'kmod:vanilla':
                self.assert_(enabled)
            else:
                self.assert_(not enabled, '%s shouldn\'t be enabled' % h)
Example #14
0
    def test_disable_nochange(self):
        '''calling with --disable on a non-changeable handler'''

        open (os.path.join(OSLib.inst.handler_dir, 'h.py'), 'w').write(
            'import jockey.handlers' + sandbox.h_nochangemod)

        sys.argv = ['ui-test', '--disable', 'kmod:vanilla']
        ui = sandbox.TestUI()
        self.assertNotEqual(ui.run(), 0)
        self.stop_capture()

        for h in ui.backend().available():
            self.assert_(jockey.ui.bool(ui.backend().handler_info(h)['enabled']))

        self.assert_('I must live' in self.stderr)
Example #15
0
    def test_check_composite_noavail(self):
        '''calling with --check-composite and no available driver'''

        sys.argv = ['ui-test', '--check-composite']
        ui = sandbox.TestUI()

        h = XorgDriverHandler(ui, 'vanilla3d', 'mesa-vanilla', 'v3d',
                              'vanilla')
        self.failIf(h.enabled())
        ui.backend().handlers[h.id()] = h

        self.assertEqual(ui.run(), 1)
        self.stop_capture()

        self.assert_('no available' in self.stderr)
Example #16
0
    def test_check_composite_noavail(self):
        '''calling with --check-composite and no available driver'''

        sys.argv = ['ui-test', '--check-composite']
        ui = sandbox.TestUI()

        h = XorgDriverHandler(ui, 'vanilla3d', 'mesa-vanilla', 'v3d',
            'vanilla')
        self.failIf(h.enabled())
        ui.backend().handlers[h.id()] = h

        self.assertEqual(ui.run(), 1)
        self.stop_capture()

        self.assert_('no available' in self.stderr)
Example #17
0
    def test_disable_confirm_cancel(self):
        '''calling with --disable --confirm cancelling'''

        open(os.path.join(OSLib.inst.handler_dir, 'h.py'),
             'w').write(sandbox.h_availability_py)

        sys.argv = ['ui-test', '--confirm', '--disable', 'kmod:mint']
        ui = sandbox.TestUI()
        ui.confirm_response = False
        self.assertEqual(ui.run(), 1)
        self.stop_capture()

        for h in ui.backend().available():
            self.assert_(
                jockey.ui.bool(ui.backend().handler_info(h)['enabled']))
Example #18
0
    def test_disable_nochange(self):
        '''calling with --disable on a non-changeable handler'''

        open(os.path.join(OSLib.inst.handler_dir, 'h.py'),
             'w').write('import jockey.handlers' + sandbox.h_nochangemod)

        sys.argv = ['ui-test', '--disable', 'kmod:vanilla']
        ui = sandbox.TestUI()
        self.assertNotEqual(ui.run(), 0)
        self.stop_capture()

        for h in ui.backend().available():
            self.assert_(
                jockey.ui.bool(ui.backend().handler_info(h)['enabled']))

        self.assert_('I must live' in self.stderr)
Example #19
0
    def test_check_composite_enabled(self):
        '''calling with --check-composite and already enabled driver'''

        sys.argv = ['ui-test', '--check-composite']
        ui = sandbox.TestUI()

        class XorgComp(XorgDriverHandler):
            def __init__(self, ui):
                XorgDriverHandler.__init__(self, ui, 'vanilla3d',
                    'mesa-vanilla', 'v3d', 'vanilla')
            def enables_composite(self):
                return True
            def enabled(self):
                return True

        h = XorgComp(ui)
        ui.backend().handlers[h.id()] = h

        # note: do not set confirm_response here, shouldn't ask
        self.assertEqual(ui.run(), 1)

        self.stop_capture()
        self.assert_('already supports' in self.stderr, self.stderr)
Example #20
0
    def test_check_composite_avail(self):
        '''calling with --check-composite and available driver'''

        sys.argv = ['ui-test', '--check-composite']
        ui = sandbox.TestUI()

        class XorgComp(XorgDriverHandler):
            def __init__(self, ui):
                XorgDriverHandler.__init__(self, ui, 'vanilla3d',
                    'mesa-vanilla', 'v3d', 'vanilla')
            def enables_composite(self):
                return True

        h = XorgComp(ui.backend())
        h_id = h.id()
        self.failIf(h.enabled())
        ui.backend().handlers[h_id] = h

        ui.confirm_response = True
        self.assertEqual(ui.run(), 0)

        self.stop_capture()
        self.assert_(jockey.ui.bool(ui.backend().handler_info(h_id)['enabled']))
Example #21
0
    def test_check(self):
        '''calling with --check'''

        try:
            # new free and nonfree drivers which are already enabled -> no notification
            sys.argv = ['ui-test', '--check']
            ui = sandbox.TestUI()
            self.assertEqual(ui.run(), 1)
            self.stop_capture()

            self.assertRaises(IndexError, ui.pop_error)
            self.assertRaises(IndexError, ui.pop_notification)
            self.failIf(ui.main_loop_active)

            self.assert_(os.path.exists(OSLib.inst.check_cache))
            os.unlink(OSLib.inst.check_cache)

            # new free and nonfree drivers which are not enabled -> nonfree notification
            ui = sandbox.TestUI()
            for h in ui.backend().available():
                ui.backend().set_enabled(h, False)
            self.assertEqual(ui.run(), 0)

            self.assertRaises(IndexError, ui.pop_error)
            self.assertEqual('Restricted drivers available',
                             ui.pop_notification()[0])

            # the next run does not report anything new
            self.assertEqual(ui.run(), 1)
            self.assertRaises(IndexError, ui.pop_error)
            self.assertRaises(IndexError, ui.pop_notification)
            self.assert_(ui.main_loop_active)
            os.unlink(OSLib.inst.check_cache)

            # non-announced handlers do not cause notifications
            ui = sandbox.TestUI()
            for h in ui.backend().available():
                ui.backend().handlers[h].announce = False
            self.assertEqual(ui.run(), 1)

            self.assertRaises(IndexError, ui.pop_error)
            self.assertRaises(IndexError, ui.pop_notification)
            self.failIf(ui.main_loop_active)
            os.unlink(OSLib.inst.check_cache)

            # new free drivers which are not enabled -> free notification
            sys.argv = ['ui-test', '--check', '-m', 'free']
            ui = sandbox.TestUI()
            self.assertEqual(ui.run(), 0)

            self.assertRaises(IndexError, ui.pop_error)
            self.assertEqual('New drivers available', ui.pop_notification()[0])
            self.assert_(ui.main_loop_active)

            # enable the free drivers again and load them -> no notification
            ui.main_loop_active = False
            for h in ui.backend().available('free'):
                ui.backend().set_enabled(h, True)
                assert jockey.ui.bool(ui.backend().handler_info(h)['used'])
            self.assertEqual(ui.run(), 1)
            self.assertRaises(IndexError, ui.pop_error)
            self.assertRaises(IndexError, ui.pop_notification)
            self.failIf(ui.main_loop_active)

            # enable the non-free drivers again, too and load them ->
            # notification about usage
            sys.argv = ['ui-test', '--check', '-m', 'nonfree']
            ui = sandbox.TestUI()
            for h in ui.backend().available('nonfree'):
                ui.backend().set_enabled(h, True)
                self.assert_(
                    jockey.ui.bool(ui.backend().handler_info(h)['used']))
            self.assertEqual(ui.run(), 1)
            self.assertRaises(IndexError, ui.pop_error)
            self.assertEqual('New restricted drivers in use',
                             ui.pop_notification()[0])
            self.assert_(ui.main_loop_active)

            # the next run does not report anything new
            ui.main_loop_active = False
            self.assertEqual(ui.run(), 1)
            self.assertRaises(IndexError, ui.pop_error)
            self.assertRaises(IndexError, ui.pop_notification)
            self.failIf(ui.main_loop_active)
        finally:
            try:
                os.unlink(OSLib.inst.check_cache)
            except OSError:
                pass
Example #22
0
    def test_check(self):
        '''calling with --check'''

        try:
            # new free and nonfree drivers which are already enabled -> no notification
            sys.argv = ['ui-test', '--check']
            ui = sandbox.TestUI()
            self.assertEqual(ui.run(), 1)
            self.stop_capture()

            self.assertRaises(IndexError, ui.pop_error)
            self.assertRaises(IndexError, ui.pop_notification)
            self.failIf(ui.main_loop_active)

            self.assert_(os.path.exists(OSLib.inst.check_cache))
            os.unlink(OSLib.inst.check_cache)

            # new free and nonfree drivers which are not enabled -> nonfree notification
            ui = sandbox.TestUI()
            for h in ui.backend().available():
                ui.backend().set_enabled(h, False)
            self.assertEqual(ui.run(), 0)

            self.assertRaises(IndexError, ui.pop_error)
            self.assertEqual('Restricted drivers available', ui.pop_notification()[0])
            
            # the next run does not report anything new
            self.assertEqual(ui.run(), 1)
            self.assertRaises(IndexError, ui.pop_error)
            self.assertRaises(IndexError, ui.pop_notification)
            self.assert_(ui.main_loop_active)
            os.unlink(OSLib.inst.check_cache)

            # non-announced handlers do not cause notifications
            ui = sandbox.TestUI()
            for h in ui.backend().available():
                ui.backend().handlers[h].announce = False
            self.assertEqual(ui.run(), 1)

            self.assertRaises(IndexError, ui.pop_error)
            self.assertRaises(IndexError, ui.pop_notification)
            self.failIf(ui.main_loop_active)
            os.unlink(OSLib.inst.check_cache)

            # new free drivers which are not enabled -> free notification
            sys.argv = ['ui-test', '--check', '-m', 'free']
            ui = sandbox.TestUI()
            self.assertEqual(ui.run(), 0)

            self.assertRaises(IndexError, ui.pop_error)
            self.assertEqual('New drivers available', ui.pop_notification()[0])
            self.assert_(ui.main_loop_active)

            # enable the free drivers again and load them -> no notification
            ui.main_loop_active = False
            for h in ui.backend().available('free'):
                ui.backend().set_enabled(h, True)
                assert jockey.ui.bool(ui.backend().handler_info(h)['used'])
            self.assertEqual(ui.run(), 1)
            self.assertRaises(IndexError, ui.pop_error)
            self.assertRaises(IndexError, ui.pop_notification)
            self.failIf(ui.main_loop_active)

            # enable the non-free drivers again, too and load them ->
            # notification about usage
            sys.argv = ['ui-test', '--check', '-m', 'nonfree']
            ui = sandbox.TestUI()
            for h in ui.backend().available('nonfree'):
                ui.backend().set_enabled(h, True)
                self.assert_(jockey.ui.bool(ui.backend().handler_info(h)['used']))
            self.assertEqual(ui.run(), 1)
            self.assertRaises(IndexError, ui.pop_error)
            self.assertEqual('New restricted drivers in use', ui.pop_notification()[0])
            self.assert_(ui.main_loop_active)

            # the next run does not report anything new
            ui.main_loop_active = False
            self.assertEqual(ui.run(), 1)
            self.assertRaises(IndexError, ui.pop_error)
            self.assertRaises(IndexError, ui.pop_notification)
            self.failIf(ui.main_loop_active)
        finally:
            try:
                os.unlink(OSLib.inst.check_cache)
            except OSError:
                pass