Skip to content

Commit

Permalink
test(draw_label) Add render test for text selection and recolor prece…
Browse files Browse the repository at this point in the history
…dence
  • Loading branch information
C47D committed Oct 23, 2024
1 parent 642988d commit e173d0b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions tests/src/test_cases/draw/test_draw_label.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,26 @@ void test_label_decor(void)
TEST_ASSERT_EQUAL_SCREENSHOT("draw/label_decor.png");
}

void test_label_selection_and_recolor(void)
{
lv_text_decor_t decor = LV_TEXT_DECOR_NONE;
lv_color_t color = lv_palette_main(LV_PALETTE_BLUE);
lv_color_t sel_bg_color = lv_palette_lighten(LV_PALETTE_RED, 4);
lv_color_t sel_color = lv_palette_darken(LV_PALETTE_RED, 4);

lv_obj_t * label = lv_label_create(lv_screen_active());
lv_label_set_recolor(label, true);
lv_label_set_text(label, "Hi, Testing the #00ff00 colored labels.#");
lv_obj_set_style_text_decor(label, decor, 0);
lv_obj_set_style_text_color(label, color, 0);
lv_obj_set_style_text_opa(label, LV_OPA_COVER, 0);
lv_obj_set_style_text_align(label, LV_TEXT_ALIGN_LEFT, 0);
lv_obj_set_style_bg_color(label, sel_bg_color, LV_PART_SELECTED);
lv_obj_set_style_text_color(label, sel_color, LV_PART_SELECTED);
lv_label_set_text_selection_start(label, 10);
lv_label_set_text_selection_end(label, 25);

TEST_ASSERT_EQUAL_SCREENSHOT("draw/label_selection_and_recolor.png");
}

#endif

0 comments on commit e173d0b

Please sign in to comment.