mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-30 02:58:26 +08:00
71 lines
2.4 KiB
C++
71 lines
2.4 KiB
C++
#include "tkc/mem.h"
|
|
#include "base/events.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
TEST(Events, pointer_event_rotate) {
|
|
system_info_t info;
|
|
info.lcd_w = 320;
|
|
info.lcd_h = 480;
|
|
pointer_event_t e;
|
|
|
|
e.x = 10;
|
|
e.y = 20;
|
|
info.lcd_orientation = LCD_ORIENTATION_0;
|
|
ASSERT_EQ(pointer_event_rotate(&e, &info), RET_OK);
|
|
ASSERT_EQ(e.x, 10);
|
|
ASSERT_EQ(e.y, 20);
|
|
|
|
e.x = 10;
|
|
e.y = 20;
|
|
info.lcd_orientation = LCD_ORIENTATION_90;
|
|
ASSERT_EQ(pointer_event_rotate(&e, &info), RET_OK);
|
|
ASSERT_EQ(e.y, 10);
|
|
ASSERT_EQ(e.x, 459);
|
|
|
|
e.x = 10;
|
|
e.y = 20;
|
|
info.lcd_orientation = LCD_ORIENTATION_180;
|
|
ASSERT_EQ(pointer_event_rotate(&e, &info), RET_OK);
|
|
ASSERT_EQ(e.y, 459);
|
|
ASSERT_EQ(e.x, 309);
|
|
|
|
e.x = 10;
|
|
e.y = 20;
|
|
info.lcd_orientation = LCD_ORIENTATION_270;
|
|
ASSERT_EQ(pointer_event_rotate(&e, &info), RET_OK);
|
|
ASSERT_EQ(e.y, 309);
|
|
ASSERT_EQ(e.x, 20);
|
|
}
|
|
|
|
TEST(Events, from_name) {
|
|
ASSERT_EQ(event_from_name("click"), EVT_CLICK);
|
|
ASSERT_EQ(event_from_name("long_press"), EVT_LONG_PRESS);
|
|
ASSERT_EQ(event_from_name("window_close"), EVT_WINDOW_CLOSE);
|
|
ASSERT_EQ(event_from_name("window_open"), EVT_WINDOW_OPEN);
|
|
ASSERT_EQ(event_from_name("window_will_open"), EVT_WINDOW_WILL_OPEN);
|
|
ASSERT_EQ(event_from_name("pointer_up"), EVT_POINTER_UP);
|
|
ASSERT_EQ(event_from_name("pointer_down"), EVT_POINTER_DOWN);
|
|
ASSERT_EQ(event_from_name("pointer_move"), EVT_POINTER_MOVE);
|
|
ASSERT_EQ(event_from_name("key_down"), EVT_KEY_DOWN);
|
|
ASSERT_EQ(event_from_name("key_up"), EVT_KEY_UP);
|
|
ASSERT_EQ(event_from_name("key_long_press"), EVT_KEY_LONG_PRESS);
|
|
ASSERT_EQ(event_from_name("global_key_down"), EVT_KEY_DOWN);
|
|
ASSERT_EQ(event_from_name("global_key_up"), EVT_KEY_UP);
|
|
ASSERT_EQ(event_from_name("global_key_long_press"), EVT_KEY_LONG_PRESS);
|
|
ASSERT_EQ(event_from_name("key_down_before_children"), EVT_KEY_DOWN_BEFORE_CHILDREN);
|
|
ASSERT_EQ(event_from_name("key_up_before_children"), EVT_KEY_UP_BEFORE_CHILDREN);
|
|
}
|
|
|
|
TEST(Events, from_custom_name) {
|
|
int32_t custom1_evt_type = EVT_USER_START + 1;
|
|
const char* custom1_evt_name = "custom1";
|
|
|
|
ASSERT_EQ(event_from_name(custom1_evt_name), EVT_NONE);
|
|
|
|
ASSERT_EQ(event_register_custom_name(custom1_evt_type, custom1_evt_name), RET_OK);
|
|
ASSERT_EQ(event_from_name(custom1_evt_name), custom1_evt_type);
|
|
ASSERT_EQ(event_unregister_custom_name(custom1_evt_name), RET_OK);
|
|
|
|
ASSERT_EQ(event_from_name(custom1_evt_name), EVT_NONE);
|
|
}
|