1
0
Fork 0

[OS Detection] Fix unit tests

This commit is contained in:
Drashna Jael're 2024-02-18 11:12:25 -08:00
parent cbb8b0de36
commit cae37c241c
Signed by: drashna
GPG key ID: DBA1FD3A860D1B11

View file

@ -329,13 +329,13 @@ TEST_F(OsDetectionTest, TestReportAfterDebounce) {
EXPECT_EQ(detected_host_os(), OS_HANDHELD); EXPECT_EQ(detected_host_os(), OS_HANDHELD);
// the task will cause a report // the task will cause a report
os_detection_task(); os_detection_task();
assert_reported(OS_LINUX); assert_reported(OS_HANDHELD);
EXPECT_EQ(detected_host_os(), OS_LINUX); EXPECT_EQ(detected_host_os(), OS_HANDHELD);
// check that it remains the same after a long time // check that it remains the same after a long time
advance_time(OS_DETECTION_DEBOUNCE * 15); advance_time(OS_DETECTION_DEBOUNCE * 15);
assert_reported(OS_LINUX); assert_reported(OS_HANDHELD);
EXPECT_EQ(detected_host_os(), OS_LINUX); EXPECT_EQ(detected_host_os(), OS_HANDHELD);
} }
TEST_F(OsDetectionTest, TestReportAfterDebounceLongWait) { TEST_F(OsDetectionTest, TestReportAfterDebounceLongWait) {
@ -404,13 +404,13 @@ TEST_F(OsDetectionTest, TestDoNotReportIntermediateResults) {
EXPECT_EQ(detected_host_os(), OS_UNSURE); EXPECT_EQ(detected_host_os(), OS_UNSURE);
// at this stage, the final result has not been reached yet // at this stage, the final result has not been reached yet
EXPECT_EQ(check_sequence({0xFF}), OS_LINUX); EXPECT_EQ(check_sequence({0xFF}), OS_HANDHELD);
os_detection_notify_usb_device_state_change(usb_device_state_configured); os_detection_notify_usb_device_state_change(usb_device_state_configured);
advance_time(OS_DETECTION_DEBOUNCE - 1); advance_time(OS_DETECTION_DEBOUNCE - 1);
os_detection_task(); os_detection_task();
assert_not_reported(); assert_not_reported();
// the intermedite but yet unstable result is exposed through detected_host_os() // the intermedite but yet unstable result is exposed through detected_host_os()
EXPECT_EQ(detected_host_os(), OS_LINUX); EXPECT_EQ(detected_host_os(), OS_HANDHELD);
// the remainder is processed // the remainder is processed
EXPECT_EQ(check_sequence({0x4, 0x10, 0xFF, 0xFF, 0xFF, 0x4, 0x10, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A}), OS_WINDOWS); EXPECT_EQ(check_sequence({0x4, 0x10, 0xFF, 0xFF, 0xFF, 0x4, 0x10, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A}), OS_WINDOWS);
@ -438,8 +438,8 @@ TEST_F(OsDetectionTest, TestDoNotReportIntermediateResults) {
TEST_F(OsDetectionTest, TestDoNotGoBackToUnsure) { TEST_F(OsDetectionTest, TestDoNotGoBackToUnsure) {
// 0x02 would cause it to go back to Unsure, so check that it does not // 0x02 would cause it to go back to Unsure, so check that it does not
EXPECT_EQ(check_sequence({0xFF, 0xFF, 0xFF, 0xFE, 0x02}), OS_LINUX); EXPECT_EQ(check_sequence({0xFF, 0xFF, 0xFF, 0xFE, 0x02}), OS_HANDHELD);
os_detection_task(); os_detection_task();
assert_not_reported(); assert_not_reported();
EXPECT_EQ(check_sequence({0x2, 0x4, 0x2, 0x28, 0x2, 0x24}), OS_PS5); EXPECT_EQ(check_sequence({0x2, 0x4, 0x2, 0x28, 0x2, 0x24}), OS_WINDOWS);
} }