Exemplo n.º 1
0
    def test_draw_screen(self):
        lines = [((x[0], None, "%s\n" % x[0]),) for x in TaurusConsole.palette]
        canvas = TestCanvas(lines)

        obj = GUIScreen()
        obj.register_palette(TaurusConsole.palette)

        obj.start()
        for _ in range(1, 10):
            obj.draw_screen((1, 1), canvas)
            time.sleep(0.5)

        old_font_size = obj.font['size']
        obj.root.event_generate("<Control-4>")
        obj.root.event_generate("<Control-MouseWheel>", delta=120)
        if old_font_size > 0:
            self.assertGreater(obj.font['size'], old_font_size)
        else:
            self.assertLess(obj.font['size'], old_font_size)
        obj.root.event_generate("<Control-5>")
        obj.root.event_generate("<Control-MouseWheel>", delta=-120)

        self.assertEqual(obj.font['size'], old_font_size)

        obj.stop()
Exemplo n.º 2
0
 def _get_screen(self):
     screen_type = self._get_screen_type()
     if screen_type == "console":
         return ConsoleScreen()
     elif screen_type == "gui":
         return GUIScreen()
     else:
         cols = self.settings.get('dummy-cols', self.screen_size[0])
         rows = self.settings.get('dummy-rows', self.screen_size[1])
         return DummyScreen(cols, rows)
Exemplo n.º 3
0
    def test_draw_screen(self):
        lines = [((x[0], None, "%s\n" % x[0]), )
                 for x in TaurusConsole.palette]
        canvas = TestCanvas(lines)

        obj = Screen()
        """
        :type: bzt.modules.screen.GUIScreen
        """
        obj.register_palette(TaurusConsole.palette)

        obj.start()

        for _ in range(1, 10):
            obj.draw_screen((1, 1), canvas)
            time.sleep(0.5)

        if hasattr(obj, 'font'):
            old_font_size = 10
            obj.font['size'] = old_font_size
            self.assertGreater(old_font_size, 0)

            if is_linux():
                obj.root.event_generate("<Control-4>")
            else:
                obj.root.event_generate("<Control-MouseWheel>", delta=120)

            self.assertGreater(obj.font['size'], old_font_size)

            if is_linux():
                obj.root.event_generate("<Control-5>")
            else:
                obj.root.event_generate("<Control-MouseWheel>", delta=-120)

            self.assertEqual(obj.font['size'], old_font_size)

        obj.stop()
Exemplo n.º 4
0
 def test_window_closed(self):
     lines = [((x[0], None, "%s\n" % x[0]), )
              for x in TaurusConsole.palette]
     canvas = TestCanvas(lines)
     obj = Screen()
     obj.register_palette(TaurusConsole.palette)
     obj.start()
     for _ in range(5):
         obj.draw_screen((1, 1), canvas)
         time.sleep(0.1)
     # closing the window
     obj.closed_window()
     # first call to draw_screen should raise ManualShutdown
     self.assertRaises(ManualShutdown, obj.draw_screen, (1, 1), canvas)
     # consecutive calls to draw_screen shouldn't raise
     obj.draw_screen((1, 1), canvas)
     obj.draw_screen((1, 1), canvas)
Exemplo n.º 5
0
 def test_window_closed(self):
     lines = [((x[0], None, "%s\n" % x[0]),) for x in TaurusConsole.palette]
     canvas = TestCanvas(lines)
     obj = Screen()
     obj.register_palette(TaurusConsole.palette)
     obj.start()
     for _ in range(5):
         obj.draw_screen((1, 1), canvas)
         time.sleep(0.1)
     # closing the window
     obj.closed_window()
     # first call to draw_screen should raise ManualShutdown
     self.assertRaises(ManualShutdown, obj.draw_screen, (1, 1), canvas)
     # consecutive calls to draw_screen shouldn't raise
     obj.draw_screen((1, 1), canvas)
     obj.draw_screen((1, 1), canvas)