2021-01-08 18:24:51 +00:00
|
|
|
#include "common.h"
|
|
|
|
|
2019-05-31 12:55:11 +00:00
|
|
|
#include <assert.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "control_msg.h"
|
|
|
|
|
|
|
|
static void test_serialize_inject_keycode(void) {
|
2022-01-14 21:17:30 +00:00
|
|
|
struct sc_control_msg msg = {
|
2022-01-26 20:31:30 +00:00
|
|
|
.type = SC_CONTROL_MSG_TYPE_INJECT_KEYCODE,
|
2019-05-31 12:55:11 +00:00
|
|
|
.inject_keycode = {
|
|
|
|
.action = AKEY_EVENT_ACTION_UP,
|
|
|
|
.keycode = AKEYCODE_ENTER,
|
2020-06-11 08:40:52 +00:00
|
|
|
.repeat = 5,
|
2019-05-31 12:55:11 +00:00
|
|
|
.metastate = AMETA_SHIFT_ON | AMETA_SHIFT_LEFT_ON,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-01-26 20:31:30 +00:00
|
|
|
unsigned char buf[SC_CONTROL_MSG_MAX_SIZE];
|
2022-01-14 21:17:30 +00:00
|
|
|
size_t size = sc_control_msg_serialize(&msg, buf);
|
2020-06-11 08:40:52 +00:00
|
|
|
assert(size == 14);
|
2019-05-31 12:55:11 +00:00
|
|
|
|
|
|
|
const unsigned char expected[] = {
|
2022-01-26 20:31:30 +00:00
|
|
|
SC_CONTROL_MSG_TYPE_INJECT_KEYCODE,
|
2019-05-31 12:55:11 +00:00
|
|
|
0x01, // AKEY_EVENT_ACTION_UP
|
|
|
|
0x00, 0x00, 0x00, 0x42, // AKEYCODE_ENTER
|
2020-06-11 08:40:52 +00:00
|
|
|
0x00, 0x00, 0x00, 0X05, // repeat
|
2019-05-31 12:55:11 +00:00
|
|
|
0x00, 0x00, 0x00, 0x41, // AMETA_SHIFT_ON | AMETA_SHIFT_LEFT_ON
|
|
|
|
};
|
|
|
|
assert(!memcmp(buf, expected, sizeof(expected)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_serialize_inject_text(void) {
|
2022-01-14 21:17:30 +00:00
|
|
|
struct sc_control_msg msg = {
|
2022-01-26 20:31:30 +00:00
|
|
|
.type = SC_CONTROL_MSG_TYPE_INJECT_TEXT,
|
2019-05-31 12:55:11 +00:00
|
|
|
.inject_text = {
|
|
|
|
.text = "hello, world!",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-01-26 20:31:30 +00:00
|
|
|
unsigned char buf[SC_CONTROL_MSG_MAX_SIZE];
|
2022-01-14 21:17:30 +00:00
|
|
|
size_t size = sc_control_msg_serialize(&msg, buf);
|
2020-06-04 19:42:09 +00:00
|
|
|
assert(size == 18);
|
2019-05-31 12:55:11 +00:00
|
|
|
|
|
|
|
const unsigned char expected[] = {
|
2022-01-26 20:31:30 +00:00
|
|
|
SC_CONTROL_MSG_TYPE_INJECT_TEXT,
|
2020-06-04 19:42:09 +00:00
|
|
|
0x00, 0x00, 0x00, 0x0d, // text length
|
2019-05-31 12:55:11 +00:00
|
|
|
'h', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd', '!', // text
|
|
|
|
};
|
|
|
|
assert(!memcmp(buf, expected, sizeof(expected)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_serialize_inject_text_long(void) {
|
2022-01-14 21:17:30 +00:00
|
|
|
struct sc_control_msg msg;
|
2022-01-26 20:31:30 +00:00
|
|
|
msg.type = SC_CONTROL_MSG_TYPE_INJECT_TEXT;
|
|
|
|
char text[SC_CONTROL_MSG_INJECT_TEXT_MAX_LENGTH + 1];
|
|
|
|
memset(text, 'a', SC_CONTROL_MSG_INJECT_TEXT_MAX_LENGTH);
|
|
|
|
text[SC_CONTROL_MSG_INJECT_TEXT_MAX_LENGTH] = '\0';
|
2019-05-31 12:55:11 +00:00
|
|
|
msg.inject_text.text = text;
|
|
|
|
|
2022-01-26 20:31:30 +00:00
|
|
|
unsigned char buf[SC_CONTROL_MSG_MAX_SIZE];
|
2022-01-14 21:17:30 +00:00
|
|
|
size_t size = sc_control_msg_serialize(&msg, buf);
|
2022-01-26 20:31:30 +00:00
|
|
|
assert(size == 5 + SC_CONTROL_MSG_INJECT_TEXT_MAX_LENGTH);
|
2019-05-31 12:55:11 +00:00
|
|
|
|
2022-01-26 20:31:30 +00:00
|
|
|
unsigned char expected[5 + SC_CONTROL_MSG_INJECT_TEXT_MAX_LENGTH];
|
|
|
|
expected[0] = SC_CONTROL_MSG_TYPE_INJECT_TEXT;
|
2020-06-04 19:42:09 +00:00
|
|
|
expected[1] = 0x00;
|
|
|
|
expected[2] = 0x00;
|
|
|
|
expected[3] = 0x01;
|
|
|
|
expected[4] = 0x2c; // text length (32 bits)
|
2022-01-26 20:31:30 +00:00
|
|
|
memset(&expected[5], 'a', SC_CONTROL_MSG_INJECT_TEXT_MAX_LENGTH);
|
2019-05-31 12:55:11 +00:00
|
|
|
|
|
|
|
assert(!memcmp(buf, expected, sizeof(expected)));
|
|
|
|
}
|
|
|
|
|
2019-09-15 14:16:17 +00:00
|
|
|
static void test_serialize_inject_touch_event(void) {
|
2022-01-14 21:17:30 +00:00
|
|
|
struct sc_control_msg msg = {
|
2022-01-26 20:31:30 +00:00
|
|
|
.type = SC_CONTROL_MSG_TYPE_INJECT_TOUCH_EVENT,
|
2019-09-15 14:16:17 +00:00
|
|
|
.inject_touch_event = {
|
|
|
|
.action = AMOTION_EVENT_ACTION_DOWN,
|
2021-11-20 11:15:15 +00:00
|
|
|
.pointer_id = UINT64_C(0x1234567887654321),
|
2019-09-15 14:16:17 +00:00
|
|
|
.position = {
|
|
|
|
.point = {
|
|
|
|
.x = 100,
|
|
|
|
.y = 200,
|
|
|
|
},
|
|
|
|
.screen_size = {
|
|
|
|
.width = 1080,
|
|
|
|
.height = 1920,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.pressure = 1.0f,
|
2023-01-29 21:14:05 +00:00
|
|
|
.action_button = AMOTION_EVENT_BUTTON_PRIMARY,
|
2019-10-03 18:14:12 +00:00
|
|
|
.buttons = AMOTION_EVENT_BUTTON_PRIMARY,
|
2019-09-15 14:16:17 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-01-26 20:31:30 +00:00
|
|
|
unsigned char buf[SC_CONTROL_MSG_MAX_SIZE];
|
2022-01-14 21:17:30 +00:00
|
|
|
size_t size = sc_control_msg_serialize(&msg, buf);
|
2023-01-29 21:14:05 +00:00
|
|
|
assert(size == 32);
|
2019-09-15 14:16:17 +00:00
|
|
|
|
|
|
|
const unsigned char expected[] = {
|
2022-01-26 20:31:30 +00:00
|
|
|
SC_CONTROL_MSG_TYPE_INJECT_TOUCH_EVENT,
|
2019-09-15 14:16:17 +00:00
|
|
|
0x00, // AKEY_EVENT_ACTION_DOWN
|
|
|
|
0x12, 0x34, 0x56, 0x78, 0x87, 0x65, 0x43, 0x21, // pointer id
|
|
|
|
0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0xc8, // 100 200
|
|
|
|
0x04, 0x38, 0x07, 0x80, // 1080 1920
|
|
|
|
0xff, 0xff, // pressure
|
2023-01-29 21:14:05 +00:00
|
|
|
0x00, 0x00, 0x00, 0x01, // AMOTION_EVENT_BUTTON_PRIMARY (action button)
|
|
|
|
0x00, 0x00, 0x00, 0x01, // AMOTION_EVENT_BUTTON_PRIMARY (buttons)
|
2019-09-15 14:16:17 +00:00
|
|
|
};
|
|
|
|
assert(!memcmp(buf, expected, sizeof(expected)));
|
|
|
|
}
|
|
|
|
|
2019-05-31 12:55:11 +00:00
|
|
|
static void test_serialize_inject_scroll_event(void) {
|
2022-01-14 21:17:30 +00:00
|
|
|
struct sc_control_msg msg = {
|
2022-01-26 20:31:30 +00:00
|
|
|
.type = SC_CONTROL_MSG_TYPE_INJECT_SCROLL_EVENT,
|
2019-05-31 12:55:11 +00:00
|
|
|
.inject_scroll_event = {
|
|
|
|
.position = {
|
|
|
|
.point = {
|
|
|
|
.x = 260,
|
|
|
|
.y = 1026,
|
|
|
|
},
|
|
|
|
.screen_size = {
|
|
|
|
.width = 1080,
|
|
|
|
.height = 1920,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
.hscroll = 1,
|
|
|
|
.vscroll = -1,
|
2021-12-31 09:38:05 +00:00
|
|
|
.buttons = 1,
|
2019-05-31 12:55:11 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-01-26 20:31:30 +00:00
|
|
|
unsigned char buf[SC_CONTROL_MSG_MAX_SIZE];
|
2022-01-14 21:17:30 +00:00
|
|
|
size_t size = sc_control_msg_serialize(&msg, buf);
|
2022-07-03 07:02:17 +00:00
|
|
|
assert(size == 21);
|
2019-05-31 12:55:11 +00:00
|
|
|
|
|
|
|
const unsigned char expected[] = {
|
2022-01-26 20:31:30 +00:00
|
|
|
SC_CONTROL_MSG_TYPE_INJECT_SCROLL_EVENT,
|
2019-05-31 12:55:11 +00:00
|
|
|
0x00, 0x00, 0x01, 0x04, 0x00, 0x00, 0x04, 0x02, // 260 1026
|
|
|
|
0x04, 0x38, 0x07, 0x80, // 1080 1920
|
2022-07-03 07:02:17 +00:00
|
|
|
0x7F, 0xFF, // 1 (float encoded as i16)
|
|
|
|
0x80, 0x00, // -1 (float encoded as i16)
|
2021-12-31 09:38:05 +00:00
|
|
|
0x00, 0x00, 0x00, 0x01, // 1
|
2019-05-31 12:55:11 +00:00
|
|
|
};
|
|
|
|
assert(!memcmp(buf, expected, sizeof(expected)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_serialize_back_or_screen_on(void) {
|
2022-01-14 21:17:30 +00:00
|
|
|
struct sc_control_msg msg = {
|
2022-01-26 20:31:30 +00:00
|
|
|
.type = SC_CONTROL_MSG_TYPE_BACK_OR_SCREEN_ON,
|
2021-04-16 16:37:50 +00:00
|
|
|
.back_or_screen_on = {
|
|
|
|
.action = AKEY_EVENT_ACTION_UP,
|
|
|
|
},
|
2019-05-31 12:55:11 +00:00
|
|
|
};
|
|
|
|
|
2022-01-26 20:31:30 +00:00
|
|
|
unsigned char buf[SC_CONTROL_MSG_MAX_SIZE];
|
2022-01-14 21:17:30 +00:00
|
|
|
size_t size = sc_control_msg_serialize(&msg, buf);
|
2021-04-16 16:37:50 +00:00
|
|
|
assert(size == 2);
|
2019-05-31 12:55:11 +00:00
|
|
|
|
|
|
|
const unsigned char expected[] = {
|
2022-01-26 20:31:30 +00:00
|
|
|
SC_CONTROL_MSG_TYPE_BACK_OR_SCREEN_ON,
|
2021-04-16 16:37:50 +00:00
|
|
|
0x01, // AKEY_EVENT_ACTION_UP
|
2019-05-31 12:55:11 +00:00
|
|
|
};
|
|
|
|
assert(!memcmp(buf, expected, sizeof(expected)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_serialize_expand_notification_panel(void) {
|
2022-01-14 21:17:30 +00:00
|
|
|
struct sc_control_msg msg = {
|
2022-01-26 20:31:30 +00:00
|
|
|
.type = SC_CONTROL_MSG_TYPE_EXPAND_NOTIFICATION_PANEL,
|
2019-05-31 12:55:11 +00:00
|
|
|
};
|
|
|
|
|
2022-01-26 20:31:30 +00:00
|
|
|
unsigned char buf[SC_CONTROL_MSG_MAX_SIZE];
|
2022-01-14 21:17:30 +00:00
|
|
|
size_t size = sc_control_msg_serialize(&msg, buf);
|
2019-05-31 12:55:11 +00:00
|
|
|
assert(size == 1);
|
|
|
|
|
|
|
|
const unsigned char expected[] = {
|
2022-01-26 20:31:30 +00:00
|
|
|
SC_CONTROL_MSG_TYPE_EXPAND_NOTIFICATION_PANEL,
|
2019-05-31 12:55:11 +00:00
|
|
|
};
|
|
|
|
assert(!memcmp(buf, expected, sizeof(expected)));
|
|
|
|
}
|
|
|
|
|
2021-04-17 12:32:18 +00:00
|
|
|
static void test_serialize_expand_settings_panel(void) {
|
2022-01-14 21:17:30 +00:00
|
|
|
struct sc_control_msg msg = {
|
2022-01-26 20:31:30 +00:00
|
|
|
.type = SC_CONTROL_MSG_TYPE_EXPAND_SETTINGS_PANEL,
|
2021-04-17 12:32:18 +00:00
|
|
|
};
|
|
|
|
|
2022-01-26 20:31:30 +00:00
|
|
|
unsigned char buf[SC_CONTROL_MSG_MAX_SIZE];
|
2022-01-14 21:17:30 +00:00
|
|
|
size_t size = sc_control_msg_serialize(&msg, buf);
|
2021-04-17 12:32:18 +00:00
|
|
|
assert(size == 1);
|
|
|
|
|
|
|
|
const unsigned char expected[] = {
|
2022-01-26 20:31:30 +00:00
|
|
|
SC_CONTROL_MSG_TYPE_EXPAND_SETTINGS_PANEL,
|
2021-04-17 12:32:18 +00:00
|
|
|
};
|
|
|
|
assert(!memcmp(buf, expected, sizeof(expected)));
|
|
|
|
}
|
|
|
|
|
2021-04-17 12:26:54 +00:00
|
|
|
static void test_serialize_collapse_panels(void) {
|
2022-01-14 21:17:30 +00:00
|
|
|
struct sc_control_msg msg = {
|
2022-01-26 20:31:30 +00:00
|
|
|
.type = SC_CONTROL_MSG_TYPE_COLLAPSE_PANELS,
|
2019-05-31 12:55:11 +00:00
|
|
|
};
|
|
|
|
|
2022-01-26 20:31:30 +00:00
|
|
|
unsigned char buf[SC_CONTROL_MSG_MAX_SIZE];
|
2022-01-14 21:17:30 +00:00
|
|
|
size_t size = sc_control_msg_serialize(&msg, buf);
|
2019-05-31 12:55:11 +00:00
|
|
|
assert(size == 1);
|
|
|
|
|
|
|
|
const unsigned char expected[] = {
|
2022-01-26 20:31:30 +00:00
|
|
|
SC_CONTROL_MSG_TYPE_COLLAPSE_PANELS,
|
2019-05-31 12:55:11 +00:00
|
|
|
};
|
|
|
|
assert(!memcmp(buf, expected, sizeof(expected)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_serialize_get_clipboard(void) {
|
2022-01-14 21:17:30 +00:00
|
|
|
struct sc_control_msg msg = {
|
2022-01-26 20:31:30 +00:00
|
|
|
.type = SC_CONTROL_MSG_TYPE_GET_CLIPBOARD,
|
2021-11-29 08:30:57 +00:00
|
|
|
.get_clipboard = {
|
2022-01-26 20:31:30 +00:00
|
|
|
.copy_key = SC_COPY_KEY_COPY,
|
2021-11-29 08:30:57 +00:00
|
|
|
},
|
2019-05-31 12:55:11 +00:00
|
|
|
};
|
|
|
|
|
2022-01-26 20:31:30 +00:00
|
|
|
unsigned char buf[SC_CONTROL_MSG_MAX_SIZE];
|
2022-01-14 21:17:30 +00:00
|
|
|
size_t size = sc_control_msg_serialize(&msg, buf);
|
2021-11-29 08:30:57 +00:00
|
|
|
assert(size == 2);
|
2019-05-31 12:55:11 +00:00
|
|
|
|
|
|
|
const unsigned char expected[] = {
|
2022-01-26 20:31:30 +00:00
|
|
|
SC_CONTROL_MSG_TYPE_GET_CLIPBOARD,
|
|
|
|
SC_COPY_KEY_COPY,
|
2019-05-31 12:55:11 +00:00
|
|
|
};
|
|
|
|
assert(!memcmp(buf, expected, sizeof(expected)));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_serialize_set_clipboard(void) {
|
2022-01-14 21:17:30 +00:00
|
|
|
struct sc_control_msg msg = {
|
2022-01-26 20:31:30 +00:00
|
|
|
.type = SC_CONTROL_MSG_TYPE_SET_CLIPBOARD,
|
2020-05-25 16:41:05 +00:00
|
|
|
.set_clipboard = {
|
2021-11-20 10:50:33 +00:00
|
|
|
.sequence = UINT64_C(0x0102030405060708),
|
2020-05-25 18:58:24 +00:00
|
|
|
.paste = true,
|
2019-05-31 12:55:11 +00:00
|
|
|
.text = "hello, world!",
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-01-26 20:31:30 +00:00
|
|
|
unsigned char buf[SC_CONTROL_MSG_MAX_SIZE];
|
2022-01-14 21:17:30 +00:00
|
|
|
size_t size = sc_control_msg_serialize(&msg, buf);
|
2021-11-20 10:50:33 +00:00
|
|
|
assert(size == 27);
|
2019-05-31 12:55:11 +00:00
|
|
|
|
|
|
|
const unsigned char expected[] = {
|
2022-01-26 20:31:30 +00:00
|
|
|
SC_CONTROL_MSG_TYPE_SET_CLIPBOARD,
|
2021-11-20 10:50:33 +00:00
|
|
|
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, // sequence
|
2020-05-25 18:58:24 +00:00
|
|
|
1, // paste
|
2020-06-04 19:42:09 +00:00
|
|
|
0x00, 0x00, 0x00, 0x0d, // text length
|
2019-05-31 12:55:11 +00:00
|
|
|
'h', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd', '!', // text
|
|
|
|
};
|
|
|
|
assert(!memcmp(buf, expected, sizeof(expected)));
|
|
|
|
}
|
|
|
|
|
2021-12-04 08:08:21 +00:00
|
|
|
static void test_serialize_set_clipboard_long(void) {
|
2022-01-14 21:17:30 +00:00
|
|
|
struct sc_control_msg msg = {
|
2022-01-26 20:31:30 +00:00
|
|
|
.type = SC_CONTROL_MSG_TYPE_SET_CLIPBOARD,
|
2021-12-04 08:08:21 +00:00
|
|
|
.set_clipboard = {
|
|
|
|
.sequence = UINT64_C(0x0102030405060708),
|
|
|
|
.paste = true,
|
|
|
|
.text = NULL,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-01-26 20:31:30 +00:00
|
|
|
char text[SC_CONTROL_MSG_CLIPBOARD_TEXT_MAX_LENGTH + 1];
|
|
|
|
memset(text, 'a', SC_CONTROL_MSG_CLIPBOARD_TEXT_MAX_LENGTH);
|
|
|
|
text[SC_CONTROL_MSG_CLIPBOARD_TEXT_MAX_LENGTH] = '\0';
|
2021-12-04 08:08:21 +00:00
|
|
|
msg.set_clipboard.text = text;
|
|
|
|
|
2022-01-26 20:31:30 +00:00
|
|
|
unsigned char buf[SC_CONTROL_MSG_MAX_SIZE];
|
2022-01-14 21:17:30 +00:00
|
|
|
size_t size = sc_control_msg_serialize(&msg, buf);
|
2022-01-26 20:31:30 +00:00
|
|
|
assert(size == SC_CONTROL_MSG_MAX_SIZE);
|
2021-12-04 08:08:21 +00:00
|
|
|
|
2022-01-26 20:31:30 +00:00
|
|
|
unsigned char expected[SC_CONTROL_MSG_MAX_SIZE] = {
|
|
|
|
SC_CONTROL_MSG_TYPE_SET_CLIPBOARD,
|
2021-12-04 08:08:21 +00:00
|
|
|
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, // sequence
|
|
|
|
1, // paste
|
|
|
|
// text length
|
2022-01-26 20:31:30 +00:00
|
|
|
SC_CONTROL_MSG_CLIPBOARD_TEXT_MAX_LENGTH >> 24,
|
|
|
|
(SC_CONTROL_MSG_CLIPBOARD_TEXT_MAX_LENGTH >> 16) & 0xff,
|
|
|
|
(SC_CONTROL_MSG_CLIPBOARD_TEXT_MAX_LENGTH >> 8) & 0xff,
|
|
|
|
SC_CONTROL_MSG_CLIPBOARD_TEXT_MAX_LENGTH & 0xff,
|
2021-12-04 08:08:21 +00:00
|
|
|
};
|
2022-01-26 20:31:30 +00:00
|
|
|
memset(expected + 14, 'a', SC_CONTROL_MSG_CLIPBOARD_TEXT_MAX_LENGTH);
|
2021-12-04 08:08:21 +00:00
|
|
|
|
|
|
|
assert(!memcmp(buf, expected, sizeof(expected)));
|
|
|
|
}
|
|
|
|
|
2019-03-15 19:23:30 +00:00
|
|
|
static void test_serialize_set_screen_power_mode(void) {
|
2022-01-14 21:17:30 +00:00
|
|
|
struct sc_control_msg msg = {
|
2022-01-26 20:31:30 +00:00
|
|
|
.type = SC_CONTROL_MSG_TYPE_SET_SCREEN_POWER_MODE,
|
2019-03-15 19:23:30 +00:00
|
|
|
.set_screen_power_mode = {
|
2022-01-26 20:31:30 +00:00
|
|
|
.mode = SC_SCREEN_POWER_MODE_NORMAL,
|
2019-03-15 19:23:30 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2022-01-26 20:31:30 +00:00
|
|
|
unsigned char buf[SC_CONTROL_MSG_MAX_SIZE];
|
2022-01-14 21:17:30 +00:00
|
|
|
size_t size = sc_control_msg_serialize(&msg, buf);
|
2019-03-15 19:23:30 +00:00
|
|
|
assert(size == 2);
|
|
|
|
|
|
|
|
const unsigned char expected[] = {
|
2022-01-26 20:31:30 +00:00
|
|
|
SC_CONTROL_MSG_TYPE_SET_SCREEN_POWER_MODE,
|
|
|
|
0x02, // SC_SCREEN_POWER_MODE_NORMAL
|
2019-03-15 19:23:30 +00:00
|
|
|
};
|
|
|
|
assert(!memcmp(buf, expected, sizeof(expected)));
|
|
|
|
}
|
|
|
|
|
2019-12-04 18:55:28 +00:00
|
|
|
static void test_serialize_rotate_device(void) {
|
2022-01-14 21:17:30 +00:00
|
|
|
struct sc_control_msg msg = {
|
2022-01-26 20:31:30 +00:00
|
|
|
.type = SC_CONTROL_MSG_TYPE_ROTATE_DEVICE,
|
2019-12-04 18:55:28 +00:00
|
|
|
};
|
|
|
|
|
2022-01-26 20:31:30 +00:00
|
|
|
unsigned char buf[SC_CONTROL_MSG_MAX_SIZE];
|
2022-01-14 21:17:30 +00:00
|
|
|
size_t size = sc_control_msg_serialize(&msg, buf);
|
2019-12-04 18:55:28 +00:00
|
|
|
assert(size == 1);
|
|
|
|
|
|
|
|
const unsigned char expected[] = {
|
2022-01-26 20:31:30 +00:00
|
|
|
SC_CONTROL_MSG_TYPE_ROTATE_DEVICE,
|
2019-12-04 18:55:28 +00:00
|
|
|
};
|
|
|
|
assert(!memcmp(buf, expected, sizeof(expected)));
|
|
|
|
}
|
|
|
|
|
2020-07-15 10:17:04 +00:00
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
(void) argc;
|
|
|
|
(void) argv;
|
|
|
|
|
2019-05-31 12:55:11 +00:00
|
|
|
test_serialize_inject_keycode();
|
|
|
|
test_serialize_inject_text();
|
|
|
|
test_serialize_inject_text_long();
|
2019-09-15 14:16:17 +00:00
|
|
|
test_serialize_inject_touch_event();
|
2019-05-31 12:55:11 +00:00
|
|
|
test_serialize_inject_scroll_event();
|
|
|
|
test_serialize_back_or_screen_on();
|
|
|
|
test_serialize_expand_notification_panel();
|
2021-04-17 12:32:18 +00:00
|
|
|
test_serialize_expand_settings_panel();
|
2021-04-17 12:26:54 +00:00
|
|
|
test_serialize_collapse_panels();
|
2019-05-31 12:55:11 +00:00
|
|
|
test_serialize_get_clipboard();
|
|
|
|
test_serialize_set_clipboard();
|
2021-12-04 08:08:21 +00:00
|
|
|
test_serialize_set_clipboard_long();
|
2019-03-15 19:23:30 +00:00
|
|
|
test_serialize_set_screen_power_mode();
|
2019-12-04 18:55:28 +00:00
|
|
|
test_serialize_rotate_device();
|
2019-05-31 12:55:11 +00:00
|
|
|
return 0;
|
|
|
|
}
|