From c2b13bd77b71ea73db12a6cda64871565036a6dc Mon Sep 17 00:00:00 2001 From: Stefan Kerkmann Date: Sun, 18 Dec 2022 21:55:14 +0100 Subject: Introduce VERIFY_AND_CLEAR shorthand (#19370) Which is just a syntactic sugar for testing::Mock::VerifyAndClearExpectations to reduce the visual clutter in unit-tests. --- .../permissive_hold/test_one_shot_keys.cpp | 8 ++++---- .../permissive_hold/test_tap_hold.cpp | 24 +++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'tests/tap_hold_configurations/permissive_hold') diff --git a/tests/tap_hold_configurations/permissive_hold/test_one_shot_keys.cpp b/tests/tap_hold_configurations/permissive_hold/test_one_shot_keys.cpp index 1328b5fc0f..81f7fe718e 100644 --- a/tests/tap_hold_configurations/permissive_hold/test_one_shot_keys.cpp +++ b/tests/tap_hold_configurations/permissive_hold/test_one_shot_keys.cpp @@ -35,26 +35,26 @@ TEST_P(OneShotParametrizedTestFixture, OSMAsRegularModifierWithAdditionalKeypres EXPECT_NO_REPORT(driver); osm_key.press(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Press regular key */ EXPECT_NO_REPORT(driver); regular_key.press(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Release regular key */ EXPECT_REPORT(driver, (osm_key.report_code)).Times(2); EXPECT_REPORT(driver, (regular_key.report_code, osm_key.report_code)).Times(1); regular_key.release(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Release OSM */ EXPECT_EMPTY_REPORT(driver).Times(1); osm_key.release(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); } // clang-format off diff --git a/tests/tap_hold_configurations/permissive_hold/test_tap_hold.cpp b/tests/tap_hold_configurations/permissive_hold/test_tap_hold.cpp index e6ecc86401..8acae6ae67 100644 --- a/tests/tap_hold_configurations/permissive_hold/test_tap_hold.cpp +++ b/tests/tap_hold_configurations/permissive_hold/test_tap_hold.cpp @@ -37,13 +37,13 @@ TEST_F(PermissiveHold, tap_regular_key_while_mod_tap_key_is_held) { EXPECT_NO_REPORT(driver); mod_tap_hold_key.press(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Press regular key */ EXPECT_NO_REPORT(driver); regular_key.press(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Release regular key */ EXPECT_REPORT(driver, (KC_LEFT_SHIFT)); @@ -51,13 +51,13 @@ TEST_F(PermissiveHold, tap_regular_key_while_mod_tap_key_is_held) { EXPECT_REPORT(driver, (KC_LEFT_SHIFT)); regular_key.release(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Release mod-tap-hold key */ EXPECT_EMPTY_REPORT(driver); mod_tap_hold_key.release(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); } TEST_F(PermissiveHold, tap_a_mod_tap_key_while_another_mod_tap_key_is_held) { @@ -72,13 +72,13 @@ TEST_F(PermissiveHold, tap_a_mod_tap_key_while_another_mod_tap_key_is_held) { EXPECT_NO_REPORT(driver); first_mod_tap_hold_key.press(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Press second mod-tap-hold key */ EXPECT_NO_REPORT(driver); second_mod_tap_hold_key.press(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Release second mod-tap-hold key */ EXPECT_REPORT(driver, (KC_LEFT_SHIFT)); @@ -86,13 +86,13 @@ TEST_F(PermissiveHold, tap_a_mod_tap_key_while_another_mod_tap_key_is_held) { EXPECT_REPORT(driver, (KC_LEFT_SHIFT)); second_mod_tap_hold_key.release(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Release first mod-tap-hold key */ EXPECT_EMPTY_REPORT(driver); first_mod_tap_hold_key.release(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); } TEST_F(PermissiveHold, tap_regular_key_while_layer_tap_key_is_held) { @@ -108,24 +108,24 @@ TEST_F(PermissiveHold, tap_regular_key_while_layer_tap_key_is_held) { EXPECT_NO_REPORT(driver); layer_tap_hold_key.press(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Press regular key */ EXPECT_NO_REPORT(driver); regular_key.press(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Release regular key */ EXPECT_REPORT(driver, (layer_key.report_code)); EXPECT_EMPTY_REPORT(driver); regular_key.release(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Release layer-tap-hold key */ EXPECT_NO_REPORT(driver); layer_tap_hold_key.release(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); } -- cgit v1.2.3