acid-drop- Hacking the planet from a LilyGo T-Deck using custom firmware |
git clone git://git.acid.vegas/acid-drop.git |
Log | Files | Refs | Archive | README | LICENSE |
test_style.c (2472B)
1 #if LV_BUILD_TEST 2 #include "../lvgl.h" 3 4 #include "unity/unity.h" 5 #include <unistd.h> 6 7 static void obj_set_height_helper(void * obj, int32_t height) 8 { 9 lv_obj_set_height((lv_obj_t *)obj, (lv_coord_t)height); 10 } 11 12 void test_gradient_vertical_misalignment(void) 13 { 14 lv_obj_t * obj = lv_obj_create(lv_scr_act()); 15 lv_obj_set_style_bg_grad_dir(obj, LV_GRAD_DIR_VER, 0); 16 lv_obj_set_style_bg_grad_color(obj, lv_color_hex(0xff0000), 0); 17 lv_obj_set_style_bg_color(obj, lv_color_hex(0x00ff00), 0); 18 19 lv_obj_set_size(obj, 300, 100); 20 21 lv_refr_now(NULL); 22 lv_obj_set_style_bg_grad_color(obj, lv_color_hex(0xffff00), 0); 23 lv_obj_set_style_bg_color(obj, lv_color_hex(0x00ffff), 0); 24 25 lv_anim_t a; 26 lv_anim_init(&a); 27 lv_anim_set_var(&a, obj); 28 lv_anim_set_exec_cb(&a, obj_set_height_helper); 29 lv_anim_set_time(&a, 3000); 30 lv_anim_set_playback_time(&a, 3000); 31 lv_anim_set_repeat_count(&a, 100); 32 lv_anim_set_values(&a, 0, 300); 33 lv_anim_start(&a); 34 35 uint32_t i; 36 for(i = 0; i < 1000; i++) { 37 lv_timer_handler(); 38 lv_tick_inc(100); 39 usleep(1000); 40 } 41 } 42 43 void test_custom_prop_ids(void) 44 { 45 uint8_t fake_flag = 0; 46 uint32_t initial_custom_props = lv_style_get_num_custom_props(); 47 uint32_t max_props_to_register = 64; 48 for(uint32_t i = 0; i < max_props_to_register; i++) { 49 lv_style_prop_t prop = lv_style_register_prop(fake_flag); 50 /* Should have a higher index than the last built-in prop */ 51 TEST_ASSERT_GREATER_THAN(_LV_STYLE_LAST_BUILT_IN_PROP, prop); 52 if(i == 0) { 53 /* Should be equal to the first expected index of a custom prop */ 54 TEST_ASSERT_EQUAL(_LV_STYLE_NUM_BUILT_IN_PROPS + initial_custom_props, prop); 55 } 56 /*We should find our flags*/ 57 TEST_ASSERT_EQUAL(fake_flag, _lv_style_prop_lookup_flags(prop)); 58 if(fake_flag == 0xff) 59 fake_flag = 0; 60 else 61 fake_flag++; 62 } 63 TEST_ASSERT_EQUAL(initial_custom_props + max_props_to_register, lv_style_get_num_custom_props()); 64 /* 65 * Check that the resizing algorithm works correctly, given that 64 props 66 * were registered + whatever's built-in. A failure here may just indicate 67 * that LVGL registers more built-in properties now and this needs adjustment. 68 */ 69 extern uint32_t _lv_style_custom_prop_flag_lookup_table_size; 70 TEST_ASSERT_EQUAL(_lv_style_custom_prop_flag_lookup_table_size, 96); 71 } 72 73 #endif