Introduce VERIFY_AND_CLEAR shorthand (#19370)
Which is just a syntactic sugar for testing::Mock::VerifyAndClearExpectations to reduce the visual clutter in unit-tests.
This commit is contained in:
parent
7aa2d791f6
commit
c2b13bd77b
21 changed files with 257 additions and 251 deletions
|
@ -28,7 +28,7 @@ TEST_F(ActionLayer, LayerStateDBG) {
|
|||
|
||||
layer_state_set(0);
|
||||
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
}
|
||||
|
||||
TEST_F(ActionLayer, LayerStateSet) {
|
||||
|
@ -39,7 +39,7 @@ TEST_F(ActionLayer, LayerStateSet) {
|
|||
layer_state_set(0b001100);
|
||||
EXPECT_EQ(layer_state, 0b001100);
|
||||
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
}
|
||||
|
||||
TEST_F(ActionLayer, LayerStateIs) {
|
||||
|
@ -56,7 +56,7 @@ TEST_F(ActionLayer, LayerStateIs) {
|
|||
EXPECT_EQ(layer_state_is(1), true);
|
||||
EXPECT_EQ(layer_state_is(2), false);
|
||||
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
}
|
||||
|
||||
TEST_F(ActionLayer, LayerStateCmp) {
|
||||
|
@ -76,7 +76,7 @@ TEST_F(ActionLayer, LayerStateCmp) {
|
|||
EXPECT_EQ(layer_state_cmp(prev_layer, 1), true);
|
||||
EXPECT_EQ(layer_state_cmp(prev_layer, 2), false);
|
||||
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
}
|
||||
|
||||
TEST_F(ActionLayer, LayerClear) {
|
||||
|
@ -85,7 +85,7 @@ TEST_F(ActionLayer, LayerClear) {
|
|||
layer_clear();
|
||||
EXPECT_EQ(layer_state, 0);
|
||||
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
}
|
||||
|
||||
TEST_F(ActionLayer, LayerMove) {
|
||||
|
@ -96,7 +96,7 @@ TEST_F(ActionLayer, LayerMove) {
|
|||
layer_move(3);
|
||||
EXPECT_EQ(layer_state, 0b1000);
|
||||
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
}
|
||||
|
||||
TEST_F(ActionLayer, LayerOn) {
|
||||
|
@ -108,7 +108,7 @@ TEST_F(ActionLayer, LayerOn) {
|
|||
layer_on(3);
|
||||
EXPECT_EQ(layer_state, 0b1010);
|
||||
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
}
|
||||
|
||||
TEST_F(ActionLayer, LayerOff) {
|
||||
|
@ -121,7 +121,7 @@ TEST_F(ActionLayer, LayerOff) {
|
|||
layer_off(2);
|
||||
EXPECT_EQ(layer_state, 0b0010);
|
||||
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
}
|
||||
|
||||
TEST_F(ActionLayer, MomentaryLayerDoesNothing) {
|
||||
|
@ -134,12 +134,12 @@ TEST_F(ActionLayer, MomentaryLayerDoesNothing) {
|
|||
EXPECT_NO_REPORT(driver);
|
||||
layer_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
|
||||
EXPECT_NO_REPORT(driver);
|
||||
layer_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
}
|
||||
|
||||
TEST_F(ActionLayer, MomentaryLayerWithKeypress) {
|
||||
|
@ -155,28 +155,28 @@ TEST_F(ActionLayer, MomentaryLayerWithKeypress) {
|
|||
layer_key.press();
|
||||
run_one_scan_loop();
|
||||
EXPECT_TRUE(layer_state_is(1));
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
|
||||
/* Press key on layer 1 */
|
||||
EXPECT_REPORT(driver, (KC_B)).Times(1);
|
||||
regular_key.press();
|
||||
run_one_scan_loop();
|
||||
EXPECT_TRUE(layer_state_is(1));
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
|
||||
/* Release key on layer 1 */
|
||||
EXPECT_EMPTY_REPORT(driver);
|
||||
regular_key.release();
|
||||
run_one_scan_loop();
|
||||
EXPECT_TRUE(layer_state_is(1));
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
|
||||
/* Release MO */
|
||||
EXPECT_NO_REPORT(driver);
|
||||
layer_key.release();
|
||||
run_one_scan_loop();
|
||||
EXPECT_TRUE(layer_state_is(0));
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
}
|
||||
|
||||
TEST_F(ActionLayer, ToggleLayerDoesNothing) {
|
||||
|
@ -192,14 +192,14 @@ TEST_F(ActionLayer, ToggleLayerDoesNothing) {
|
|||
layer_key.press();
|
||||
run_one_scan_loop();
|
||||
EXPECT_TRUE(layer_state_is(1));
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
|
||||
/* Release TG. */
|
||||
EXPECT_NO_REPORT(driver);
|
||||
layer_key.release();
|
||||
run_one_scan_loop();
|
||||
EXPECT_TRUE(layer_state_is(1));
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
}
|
||||
|
||||
TEST_F(ActionLayer, ToggleLayerUpAndDown) {
|
||||
|
@ -216,26 +216,26 @@ TEST_F(ActionLayer, ToggleLayerUpAndDown) {
|
|||
toggle_layer_1_on_layer_0.press();
|
||||
run_one_scan_loop();
|
||||
EXPECT_TRUE(layer_state_is(1));
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
|
||||
EXPECT_NO_REPORT(driver);
|
||||
toggle_layer_1_on_layer_0.release();
|
||||
run_one_scan_loop();
|
||||
EXPECT_TRUE(layer_state_is(1));
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
|
||||
/* Toggle Layer 0. */
|
||||
EXPECT_NO_REPORT(driver);
|
||||
toggle_layer_0_on_layer_1.press();
|
||||
run_one_scan_loop();
|
||||
EXPECT_TRUE(layer_state_is(0));
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
|
||||
EXPECT_NO_REPORT(driver);
|
||||
toggle_layer_0_on_layer_1.release();
|
||||
run_one_scan_loop();
|
||||
EXPECT_TRUE(layer_state_is(0));
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
}
|
||||
|
||||
TEST_F(ActionLayer, LayerTapToggleDoesNothing) {
|
||||
|
@ -251,13 +251,13 @@ TEST_F(ActionLayer, LayerTapToggleDoesNothing) {
|
|||
layer_key.press();
|
||||
run_one_scan_loop();
|
||||
EXPECT_TRUE(layer_state_is(1));
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
|
||||
EXPECT_NO_REPORT(driver);
|
||||
layer_key.release();
|
||||
run_one_scan_loop();
|
||||
EXPECT_TRUE(layer_state_is(0));
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
}
|
||||
|
||||
TEST_F(ActionLayer, LayerTapToggleWithKeypress) {
|
||||
|
@ -275,25 +275,25 @@ TEST_F(ActionLayer, LayerTapToggleWithKeypress) {
|
|||
layer_key.press();
|
||||
run_one_scan_loop();
|
||||
EXPECT_TRUE(layer_state_is(1));
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
|
||||
EXPECT_REPORT(driver, (KC_B)).Times(1);
|
||||
regular_key.press();
|
||||
run_one_scan_loop();
|
||||
EXPECT_TRUE(layer_state_is(1));
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
|
||||
EXPECT_EMPTY_REPORT(driver);
|
||||
regular_key.release();
|
||||
run_one_scan_loop();
|
||||
EXPECT_TRUE(layer_state_is(1));
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
|
||||
EXPECT_NO_REPORT(driver);
|
||||
layer_key.release();
|
||||
run_one_scan_loop();
|
||||
EXPECT_TRUE(layer_state_is(0));
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
}
|
||||
|
||||
TEST_F(ActionLayer, LayerTapToggleWithToggleWithKeypress) {
|
||||
|
@ -344,19 +344,19 @@ TEST_F(ActionLayer, LayerTapToggleWithToggleWithKeypress) {
|
|||
run_one_scan_loop();
|
||||
EXPECT_TRUE(layer_state_is(1));
|
||||
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
|
||||
EXPECT_REPORT(driver, (KC_B)).Times(1);
|
||||
regular_key.press();
|
||||
run_one_scan_loop();
|
||||
EXPECT_TRUE(layer_state_is(1));
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
|
||||
EXPECT_EMPTY_REPORT(driver);
|
||||
regular_key.release();
|
||||
run_one_scan_loop();
|
||||
EXPECT_TRUE(layer_state_is(1));
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
}
|
||||
|
||||
TEST_F(ActionLayer, LayerTapReleasedBeforeKeypressReleaseWithModifiers) {
|
||||
|
@ -373,7 +373,7 @@ TEST_F(ActionLayer, LayerTapReleasedBeforeKeypressReleaseWithModifiers) {
|
|||
layer_0_key_0.press();
|
||||
idle_for(TAPPING_TERM);
|
||||
EXPECT_TRUE(layer_state_is(0));
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
|
||||
/* Press key with layer 1 mapping, result basically expected
|
||||
* altough more reports are send then necessary. */
|
||||
|
@ -382,14 +382,14 @@ TEST_F(ActionLayer, LayerTapReleasedBeforeKeypressReleaseWithModifiers) {
|
|||
layer_1_key_1.press();
|
||||
run_one_scan_loop();
|
||||
EXPECT_TRUE(layer_state_is(1));
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
|
||||
/* Release layer tap key, no report is send because key is still held. */
|
||||
EXPECT_NO_REPORT(driver);
|
||||
layer_0_key_0.release();
|
||||
run_one_scan_loop();
|
||||
EXPECT_TRUE(layer_state_is(0));
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
|
||||
/* Unregister keycode and modifier. */
|
||||
EXPECT_REPORT(driver, (KC_RALT)).Times(1);
|
||||
|
@ -397,5 +397,5 @@ TEST_F(ActionLayer, LayerTapReleasedBeforeKeypressReleaseWithModifiers) {
|
|||
layer_1_key_1.release();
|
||||
run_one_scan_loop();
|
||||
EXPECT_TRUE(layer_state_is(0));
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
VERIFY_AND_CLEAR(driver);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue