diff --git a/tools/test_webui.py b/tools/test_webui.py index 6c29c14..55a8bbb 100644 --- a/tools/test_webui.py +++ b/tools/test_webui.py @@ -411,5 +411,31 @@ class TestKeyWhenPoweredOff(unittest.TestCase): self.assertEqual(resp.status_code, 409) +class TestPowerBar(unittest.TestCase): + def setUp(self): + _, http = make_app() + self.body = http.get("/").get_data(as_text=True) + + def test_has_power_buttons(self): + for action in ("on", "off", "reset"): + self.assertIn(f'data-power="{action}"', self.body) + + def test_power_bar_is_above_the_screen(self): + """The user asked for it on top.""" + self.assertLess(self.body.index('data-power="on"'), + self.body.index('id="screen"')) + + def test_power_off_asks_for_confirmation(self): + """Off kills the emulator; a stray click should not do that silently.""" + self.assertIn("confirm(", self.body) + + def test_shows_the_powered_state(self): + self.assertIn("powerstate", self.body) + + def test_dims_the_screen_when_off(self): + """A dark screen is the signal that the machine is off.""" + self.assertIn("screen-off", self.body) + + if __name__ == "__main__": unittest.main() diff --git a/tools/webui.py b/tools/webui.py index f1d4d04..c4cf730 100644 --- a/tools/webui.py +++ b/tools/webui.py @@ -284,9 +284,24 @@ def render_index(scale: int) -> str: .side {{ width:76px; }} .hint {{ color:#6e7681; font-size:12px; text-align:center; max-width:430px; }} #status {{ font-size:12px; color:#6e7681; }} + .powerbar {{ display:flex; gap:8px; align-items:center; align-self:stretch; }} + .pwr {{ padding:6px 14px; font:inherit; color:#c9d1d9; background:#2b3138; + border:1px solid #3a424b; border-radius:6px; cursor:pointer; }} + .pwr:hover:not(:disabled) {{ background:#343b44; }} + .pwr:disabled {{ opacity:0.5; cursor:default; }} + #powerstate {{ font-size:12px; color:#6e7681; margin-left:auto; }} + #powerstate.on {{ color:#3fb950; }} + /* Powered off is a dark panel, not a frozen last frame. */ + .screen-off {{ background:#0b0d10 !important; }}