|
18 | 18 | LookHandler,
|
19 | 19 | SingleRangedAttackHandler,
|
20 | 20 | AreaRangedAttackHandler,
|
| 21 | + PopupMessage, |
21 | 22 | )
|
22 | 23 |
|
23 | 24 | from actions import (
|
@@ -102,6 +103,40 @@ def test_ev_quit(self):
|
102 | 103 | with self.assertRaises(SystemExit):
|
103 | 104 | eh.ev_quit(event=event)
|
104 | 105 |
|
| 106 | +class Test_PopupMessage(unittest.TestCase): |
| 107 | + def test_init(self): |
| 108 | + ''' |
| 109 | + test that the popup message can be initialized correctly |
| 110 | + ''' |
| 111 | + pop = PopupMessage(parent_handler=BaseEventHandler(), text="string") |
| 112 | + self.assertIsInstance(pop.parent, BaseEventHandler) |
| 113 | + self.assertEqual(pop.text, "string") |
| 114 | + |
| 115 | + def test_on_render(self): |
| 116 | + ''' |
| 117 | + verify that the parent is rendered as expected then an additional print is |
| 118 | + called with the correct parameters |
| 119 | + ''' |
| 120 | + pop = PopupMessage(parent_handler=BaseEventHandler(), text="string") |
| 121 | + console = Console(width=10, height=10, order='F') |
| 122 | + |
| 123 | + with patch('input_handlers.BaseEventHandler.on_render') as patch_on_render: |
| 124 | + with patch('tcod.console.Console.print') as patch_print: |
| 125 | + pop.on_render(console=console) |
| 126 | + |
| 127 | + patch_on_render.assert_called_once() |
| 128 | + patch_print.assert_called_with(5, 5, "string", fg=color.white, bg=color.black, alignment=tcod.CENTER) |
| 129 | + |
| 130 | + def test_ev_keydown(self): |
| 131 | + ''' |
| 132 | + verify that sending a keydown will return the parent |
| 133 | + ''' |
| 134 | + pop = PopupMessage(parent_handler=BaseEventHandler(), text="string") |
| 135 | + event = tcod.event.KeyDown( |
| 136 | + scancode=tcod.event.Scancode.UP, sym=tcod.event.K_UP, mod=tcod.event.Modifier.NONE |
| 137 | + ) |
| 138 | + ret = pop.ev_keydown(event=event) |
| 139 | + self.assertIsInstance(ret, BaseEventHandler) |
105 | 140 |
|
106 | 141 | class Test_EventHandler(unittest.TestCase):
|
107 | 142 | def test_init(self):
|
|
0 commit comments