From d7b8ce86edaccb89452db51f4f69cf67643a0824 Mon Sep 17 00:00:00 2001 From: discountchubbs Date: Mon, 17 Nov 2025 20:21:33 -0800 Subject: [PATCH] compare vs what used to be done before InputDialog --- .../widgets/tests/test_input_dialog.py | 40 ++++++++++++++++++- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/system/ui/sunnypilot/widgets/tests/test_input_dialog.py b/system/ui/sunnypilot/widgets/tests/test_input_dialog.py index 149dd3739c..46a7979fd9 100644 --- a/system/ui/sunnypilot/widgets/tests/test_input_dialog.py +++ b/system/ui/sunnypilot/widgets/tests/test_input_dialog.py @@ -1,11 +1,15 @@ import os +import pytest from openpilot.common.params import Params from openpilot.system.ui.lib.application import gui_app +from openpilot.system.ui.widgets.keyboard import Keyboard from openpilot.system.ui.sunnypilot.widgets.input_dialog import InputDialogSP - os.environ['SDL_VIDEODRIVER'] = 'dummy' +if not os.environ.get('CI'): + pytest.skip("Test in CI environment, or comment out this flag to test locally", allow_module_level=True) + class TestInputDialog: def setup_method(self): @@ -13,10 +17,42 @@ class TestInputDialog: def test_input_dialog_int(self): gui_app.init_window("test window") - dialog = InputDialogSP("title", current_text="current_text", param="MapTargetVelocities") # some rando param, sorry sunny bc it's yours + dialog = InputDialogSP("title", current_text="current_text", param="MapTargetVelocities") dialog.show() dialog.keyboard._render_return_status = 1 gui_app._handle_modal_overlay() assert self.params.get("MapTargetVelocities") == "current_text" + + def test_before_input_dialog(self): + gui_app.init_window("test window") + current_apn = "gsmapn" + # This tests the pre InputDialogSP, where keyboard setup had to be done for every single dialog box you want to use. + self.keyboard = Keyboard() + self.keyboard.reset(min_text_size=0) + self.keyboard.set_title(("Enter APN"), ("networking")) + self.keyboard.set_text(current_apn) + + def pre_input_dialog_callback(result): + if result == 1: + apn = self.keyboard.text.strip() + self.params.put("GsmApn", apn) + + gui_app.set_modal_overlay(self.keyboard, pre_input_dialog_callback) + self.keyboard.set_text("new_apn") + self.keyboard._render_return_status = 1 + gui_app._handle_modal_overlay() + pre_input_dialog_result = self.params.get("GsmApn") + + assert pre_input_dialog_result == "new_apn" + + dialog = InputDialogSP(title="Enter APN", sub_title="networking", current_text=current_apn, param="GsmApn") + dialog.show() + dialog.keyboard.set_text("new_apn") + dialog.keyboard._render_return_status = 1 + gui_app._handle_modal_overlay() + input_dialog_result = self.params.get("GsmApn") + + assert input_dialog_result == "new_apn" + assert pre_input_dialog_result == input_dialog_result