diff --git a/testing/VirtualDeviceTest.h b/testing/VirtualDeviceTest.h index 592df1a9..d2c17620 100644 --- a/testing/VirtualDeviceTest.h +++ b/testing/VirtualDeviceTest.h @@ -123,3 +123,19 @@ class VirtualDeviceTest : public ::testing::Test { } // namespace testing } // namespace kaleidoscope + + +// XXX This is a horrible hack and this should be a function, but I (Jesse) +// can't quite figure out the right way to get ASSERT_EQ and ElementsAreArray +// into a method in VirtualDeviceTest +#define CHECK_EXPECTED_REPORTS() \ + LoadState(); \ + ASSERT_EQ(HIDReports()->Keyboard().size(), expected_reports_.size()); \ + \ + for (auto i = 0; i < expected_reports_.size(); ++i) { \ + EXPECT_THAT(HIDReports()->Keyboard(i).ActiveKeycodes(), \ + ::testing::ElementsAreArray(expected_reports_[i].Keycodes())) \ + << expected_reports_[i].Message(); \ + } \ + +