重构显示逻辑为 MVP 架构,进行显示模块的解耦
This commit is contained in:
47
tests/test_p1_menu_layout.c
Normal file
47
tests/test_p1_menu_layout.c
Normal file
@@ -0,0 +1,47 @@
|
||||
#include "test_common.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "../src/Drv/lcd/lcd.h"
|
||||
#include "../src/Drv/menu/app/menu.h"
|
||||
#include "../src/Drv/menu/view/menu_layout.h"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
tagMenuItem root;
|
||||
tagMenuItem child;
|
||||
MenuLayoutConfig config = {
|
||||
LCD_SIZE_X,
|
||||
LCD_SIZE_Y,
|
||||
MENU_YMIN,
|
||||
MENU_YMAX_FROM_LCD(LCD_SIZE_Y),
|
||||
LINE_HEIGHT,
|
||||
MENU_WITDTH,
|
||||
MENU_XADD,
|
||||
MENU_YADD};
|
||||
|
||||
memset(&root, 0, sizeof(root));
|
||||
memset(&child, 0, sizeof(child));
|
||||
|
||||
memcpy(root.byName, "Root", 5);
|
||||
memcpy(child.byName, "Child", 6);
|
||||
root.byClass = 0;
|
||||
child.byClass = 1;
|
||||
|
||||
root.ptLower = &child;
|
||||
root.ptBehind = &root;
|
||||
root.ptBefore = &root;
|
||||
child.ptHigher = &root;
|
||||
child.ptBehind = &child;
|
||||
child.ptBefore = &child;
|
||||
|
||||
ASSERT_EQ_INT(3, MenuLayout_Utf8LenCal((uint8_t *)"ABC"));
|
||||
ASSERT_EQ_INT(2, MenuLayout_Utf8LenCal((uint8_t *)"你"));
|
||||
|
||||
MenuLayout_PositionCal(&root, 1, &config);
|
||||
ASSERT_TRUE(root.wEPosX > root.wSPosX);
|
||||
ASSERT_TRUE(root.wEPosY > root.wSPosY);
|
||||
ASSERT_TRUE(root.wEPosY <= LCD_SIZE_Y);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user