    def test_widget_labels(self):
        """
        Check various widgets and labels interact correctly.
        """
        # Create a dummy screen.
        screen = MagicMock(spec=Screen, colours=8, unicode_aware=False)
        scene = Scene([], duration=-1)
        canvas = Canvas(screen, 10, 40, 0, 0)

        # Create the form we want to test.
        self.clicked = False

        def click():
            self.clicked = True

        form = Frame(canvas, canvas.height, canvas.width, has_border=True)
        layout = Layout([80, 20], fill_frame=True)
        form.add_layout(layout)
        layout.add_widget(Button("one", None, label="Buttons"))
        layout.add_widget(Button("two", click))
        listbox = ListBox(1, [("12345678901234567890", 1)], label="List")
        layout.add_widget(listbox)
        text = Text(label="Text")
        layout.add_widget(text)
        form.fix()
        scene.add_effect(form)
        form.reset()

        # Check widgets are displayed correctly
        for effect in scene.effects:
            effect.update(0)
        self.assert_canvas_equals(
            canvas,
            "+--------------------------------------+\n" +
            "|Buttons < one >                       |\n" +
            "|        < two >                       O\n" +
            "|List    12345678901234567890          |\n" +
            "|Text                                  |\n" +
            "|                                      |\n" +
            "|                                      |\n" +
            "|                                      |\n" +
            "|                                      |\n" +
            "+--------------------------------------+\n")

        # check specfic bug with Listbox overflow on selection
        self.process_mouse(form, [(20, 3, MouseEvent.LEFT_CLICK)])
        for effect in scene.effects:
            effect.update(1)
        self.assertEqual(canvas.get_from(28, 3), (ord("0"), 7, 1, 6))
        self.assertEqual(canvas.get_from(29, 3), (ord(" "), 7, 1, 6))
        self.assertEqual(canvas.get_from(30, 3), (ord(" "), 7, 1, 6))
        self.assertEqual(canvas.get_from(31, 3), (ord(" "), 7, 2, 4))

        # Check that clicking just outside the button has no effect.
        self.process_mouse(form, [(8, 2, MouseEvent.LEFT_CLICK)])
        self.process_mouse(form, [(16, 2, MouseEvent.LEFT_CLICK)])
        self.assertFalse(self.clicked)

        # Check that clicking just inside the button works.
        self.process_mouse(form, [(9, 2, MouseEvent.LEFT_CLICK)])
        self.assertTrue(self.clicked)
        self.clicked = False
        self.process_mouse(form, [(15, 2, MouseEvent.LEFT_CLICK)])
        self.assertTrue(self.clicked)

        # Check that pressing space on a button works
        self.clicked = False
        self.process_keys(form, [" "])
        self.assertTrue(self.clicked)
Check various widgets and labels interact correctly.
tests/test_widgets.py