Skip to content

Commit d3cb716

Browse files
committed
Add BLE pairing screenshot tests and icon pos
Adjust BLE pairing icon placement in the main screen (use lv_obj_set_pos(103,72) instead of lv_obj_align) and add test coverage for the BLE pairing indicator. Tests include light and dark screenshot cases plus reference BMPs. Also update the emulator teardown to clear ble_pairing_icon, its flash timer and flash state so tests start from a clean state.
1 parent 0312805 commit d3cb716

5 files changed

Lines changed: 48 additions & 1 deletion

File tree

src/sp140/lvgl/lvgl_main_screen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ void setupMainScreen(bool darkMode) {
530530
lv_label_set_text(ble_pairing_icon, LV_SYMBOL_BLUETOOTH);
531531
lv_obj_set_style_text_font(ble_pairing_icon, &lv_font_montserrat_14, 0);
532532
lv_obj_set_style_text_color(ble_pairing_icon, LVGL_BLUE, 0);
533-
lv_obj_align(ble_pairing_icon, LV_ALIGN_RIGHT_MID, -20, 11);
533+
lv_obj_set_pos(ble_pairing_icon, 103, 72);
534534
lv_obj_add_flag(ble_pairing_icon, LV_OBJ_FLAG_HIDDEN); // Hide initially
535535

536536
// Create climb rate indicator horizontal divider lines in the far-right section

test/test_screenshots/emulator_display.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ void emulator_teardown() {
334334
cruise_icon_img = NULL;
335335
charging_icon_img = NULL;
336336
arm_fail_warning_icon_img = NULL;
337+
ble_pairing_icon = NULL;
337338
for (int i = 0; i < 13; i++) climb_rate_divider_lines[i] = NULL;
338339
for (int i = 0; i < 12; i++) climb_rate_fill_sections[i] = NULL;
339340
critical_border = NULL;
@@ -358,15 +359,19 @@ void emulator_teardown() {
358359
extern lv_timer_t* cruise_flash_timer;
359360
extern lv_timer_t* arm_fail_flash_timer;
360361
extern lv_timer_t* critical_border_flash_timer;
362+
extern lv_timer_t* ble_pairing_flash_timer;
361363
extern bool isFlashingCruiseIcon;
362364
extern bool isFlashingArmFailIcon;
363365
extern bool isFlashingCriticalBorder;
366+
extern bool isFlashingBLEPairingIcon;
364367
cruise_flash_timer = NULL;
365368
arm_fail_flash_timer = NULL;
366369
critical_border_flash_timer = NULL;
370+
ble_pairing_flash_timer = NULL;
367371
isFlashingCruiseIcon = false;
368372
isFlashingArmFailIcon = false;
369373
isFlashingCriticalBorder = false;
374+
isFlashingBLEPairingIcon = false;
370375

371376
memset(framebuffer, 0, sizeof(framebuffer));
372377
}
60.1 KB
Binary file not shown.
60.1 KB
Binary file not shown.

test/test_screenshots/test_screenshots.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,48 @@ TEST_F(ScreenshotTest, MainScreen_CriticalAlerts_Dark) {
554554
save_and_compare("main_critical_alerts_dark");
555555
}
556556

557+
// ============================================================
558+
// BLE pairing icon tests
559+
// ============================================================
560+
561+
TEST_F(ScreenshotTest, MainScreen_BLEPairing_Light) {
562+
auto dd = make_default_device_data(false);
563+
auto esc = make_esc_connected();
564+
auto bms = make_bms_connected();
565+
auto ubd = make_unified_battery(72.0f, 88.5f, 0.0f);
566+
567+
emulator_init_display(false);
568+
setupMainScreen(false);
569+
updateLvglMainScreen(dd, esc, bms, ubd, 0.0f, false, false, 0);
570+
571+
// Show BLE pairing icon (normally toggled by flash timer)
572+
if (ble_pairing_icon != NULL) {
573+
lv_obj_remove_flag(ble_pairing_icon, LV_OBJ_FLAG_HIDDEN);
574+
}
575+
576+
emulator_render_frame();
577+
save_and_compare("main_ble_pairing_light");
578+
}
579+
580+
TEST_F(ScreenshotTest, MainScreen_BLEPairing_Dark) {
581+
auto dd = make_default_device_data(true);
582+
auto esc = make_esc_connected();
583+
auto bms = make_bms_connected();
584+
auto ubd = make_unified_battery(72.0f, 88.5f, 0.0f);
585+
586+
emulator_init_display(true);
587+
setupMainScreen(true);
588+
updateLvglMainScreen(dd, esc, bms, ubd, 0.0f, false, false, 0);
589+
590+
// Show BLE pairing icon (normally toggled by flash timer)
591+
if (ble_pairing_icon != NULL) {
592+
lv_obj_remove_flag(ble_pairing_icon, LV_OBJ_FLAG_HIDDEN);
593+
}
594+
595+
emulator_render_frame();
596+
save_and_compare("main_ble_pairing_dark");
597+
}
598+
557599
// ============================================================
558600
// Splash screen tests (recreated from lvgl_core.cpp displayLvglSplash)
559601
// Uses VERSION_MAJOR/VERSION_MINOR from version.h so references

0 commit comments

Comments
 (0)