Skip to content

Commit

Permalink
[OS Detection] Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
drashna committed Mar 24, 2024
1 parent ea9e171 commit 4dde7ec
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions quantum/os_detection/tests/os_detection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}

0 comments on commit 4dde7ec

Please sign in to comment.