[OS Detection] Fix unit tests

This commit is contained in:
Drashna Jael're 2024-02-18 11:12:25 -08:00
parent a331eefb31
commit 30eb35bb15
No known key found for this signature in database
GPG Key ID: DBA1FD3A860D1B11

View File

@ -293,13 +293,13 @@ TEST_F(OsDetectionTest, TestReportAfterDebounce) {
EXPECT_EQ(detected_host_os(), OS_HANDHELD);
// the task will cause a report
os_detection_task();
assert_reported(OS_LINUX);
EXPECT_EQ(detected_host_os(), OS_LINUX);
assert_reported(OS_HANDHELD);
EXPECT_EQ(detected_host_os(), OS_HANDHELD);
// check that it remains the same after a long time
advance_time(OS_DETECTION_DEBOUNCE * 15);
assert_reported(OS_LINUX);
EXPECT_EQ(detected_host_os(), OS_LINUX);
assert_reported(OS_HANDHELD);
EXPECT_EQ(detected_host_os(), OS_HANDHELD);
}
TEST_F(OsDetectionTest, TestReportAfterDebounceLongWait) {
@ -368,13 +368,13 @@ TEST_F(OsDetectionTest, TestDoNotReportIntermediateResults) {
EXPECT_EQ(detected_host_os(), OS_UNSURE);
// 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);
advance_time(OS_DETECTION_DEBOUNCE - 1);
os_detection_task();
assert_not_reported();
// 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
EXPECT_EQ(check_sequence({0x4, 0x10, 0xFF, 0xFF, 0xFF, 0x4, 0x10, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A, 0x20A}), OS_WINDOWS);
@ -402,8 +402,8 @@ TEST_F(OsDetectionTest, TestDoNotReportIntermediateResults) {
TEST_F(OsDetectionTest, TestDoNotGoBackToUnsure) {
// 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();
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);
}