    def test_dropdown_list(self):
        """
        Check DropdownList widget works as expected.
        """
        def _click():
            self._clicked = True

        # Now set up the Frame ready for testing
        screen = MagicMock(spec=Screen, colours=8, unicode_aware=True)
        scene = Scene([], duration=-1)
        canvas = Canvas(screen, 10, 40, 0, 0)
        form = Frame(canvas, canvas.height, canvas.width)
        layout = Layout([100], fill_frame=True)
        form.add_layout(layout)
        layout.add_widget(DropdownList([("这是第一个选项", 1), ("Item 2", 3), ("Item 3", 5)], on_change=_click))
        form.fix()
        scene.add_effect(form)
        scene.reset()
        self._clicked = False

        # Check that the Frame is rendered correctly.
        for effect in scene.effects:
            effect.update(0)
        self.assert_canvas_equals(
            canvas,
            "┌──────────────────────────────────────┐\n" +
            "│[ 这这是是第第一一个个选选项项                     ]│\n" +
            "│                                      █\n" +
            "│                                      ░\n" +
            "│                                      ░\n" +
            "│                                      ░\n" +
            "│                                      ░\n" +
            "│                                      ░\n" +
            "│                                      │\n" +
            "└──────────────────────────────────────┘\n")

        # Check it opens as expected
        self.process_mouse(scene, [(7, 1, MouseEvent.LEFT_CLICK)])
        for effect in scene.effects:
            effect.update(1)
        self.assert_canvas_equals(
            canvas,
            "┌┌────────────────────────────────────┐┐\n" +
            "││ 这这是是第第一一个个选选项项                     ││\n" +
            "││────────────────────────────────────│█\n" +
            "││ 这这是是第第一一个个选选项项                     │░\n" +
            "││ Item 2                             │░\n" +
            "││ Item 3                             │░\n" +
            "│└────────────────────────────────────┘░\n" +
            "│                                      ░\n" +
            "│                                      │\n" +
            "└──────────────────────────────────────┘\n")

        # Check ESC works as expected
        self.process_keys(scene, [Screen.KEY_DOWN, Screen.KEY_ESCAPE])
        for effect in scene.effects:
            effect.update(2)
        self.assert_canvas_equals(
            canvas,
            "┌──────────────────────────────────────┐\n" +
            "│[ 这这是是第第一一个个选选项项                     ]│\n" +
            "│                                      █\n" +
            "│                                      ░\n" +
            "│                                      ░\n" +
            "│                                      ░\n" +
            "│                                      ░\n" +
            "│                                      ░\n" +
            "│                                      │\n" +
            "└──────────────────────────────────────┘\n")
        self.assertFalse(self._clicked)

        # Check key selection works as expected
        self.process_keys(scene, [" ", Screen.KEY_DOWN])
        for effect in scene.effects:
            effect.update(3)
        self.assert_canvas_equals(
            canvas,
            "┌┌────────────────────────────────────┐┐\n" +
            "││ Item 2                             ││\n" +
            "││────────────────────────────────────│█\n" +
            "││ 这这是是第第一一个个选选项项                     │░\n" +
            "││ Item 2                             │░\n" +
            "││ Item 3                             │░\n" +
            "│└────────────────────────────────────┘░\n" +
            "│                                      ░\n" +
            "│                                      │\n" +
            "└──────────────────────────────────────┘\n")

        # Check Enter works as expected
        self.process_keys(scene, [Screen.ctrl("m")])
        for effect in scene.effects:
            effect.update(4)
        self.assert_canvas_equals(
            canvas,
            "┌──────────────────────────────────────┐\n" +
            "│[ Item 2                             ]│\n" +
            "│                                      █\n" +
            "│                                      ░\n" +
            "│                                      ░\n" +
            "│                                      ░\n" +
            "│                                      ░\n" +
            "│                                      ░\n" +
            "│                                      │\n" +
            "└──────────────────────────────────────┘\n")
        self.assertTrue(self._clicked)
Check DropdownList widget works as expected.
tests/test_widgets.py