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. --- .../quick_tap/test_action_layer.cpp | 6 +- .../quick_tap/test_quick_tap.cpp | 64 +++++++++++----------- 2 files changed, 35 insertions(+), 35 deletions(-) (limited to 'tests/tap_hold_configurations/quick_tap') diff --git a/tests/tap_hold_configurations/quick_tap/test_action_layer.cpp b/tests/tap_hold_configurations/quick_tap/test_action_layer.cpp index 9c3b38050a..44dd14c033 100644 --- a/tests/tap_hold_configurations/quick_tap/test_action_layer.cpp +++ b/tests/tap_hold_configurations/quick_tap/test_action_layer.cpp @@ -66,17 +66,17 @@ TEST_F(ActionLayer, LayerTapToggleWithToggleWithKeypress) { run_one_scan_loop(); expect_layer_state(0); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); EXPECT_REPORT(driver, (KC_A)).Times(1); regular_key.press(); run_one_scan_loop(); expect_layer_state(0); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); EXPECT_EMPTY_REPORT(driver).Times(1); regular_key.release(); run_one_scan_loop(); expect_layer_state(0); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); } diff --git a/tests/tap_hold_configurations/quick_tap/test_quick_tap.cpp b/tests/tap_hold_configurations/quick_tap/test_quick_tap.cpp index e2f8c51340..8ec6ea62a3 100644 --- a/tests/tap_hold_configurations/quick_tap/test_quick_tap.cpp +++ b/tests/tap_hold_configurations/quick_tap/test_quick_tap.cpp @@ -39,32 +39,32 @@ TEST_F(QuickTap, tap_regular_key_while_mod_tap_key_is_held) { EXPECT_NO_REPORT(driver); mod_tap_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_NO_REPORT(driver); regular_key.release(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Release mod-tap key. */ EXPECT_REPORT(driver, (KC_LSFT)); mod_tap_key.release(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Idle for tapping term of mod tap hold key. */ EXPECT_REPORT(driver, (KC_LSFT, KC_A)); EXPECT_REPORT(driver, (KC_LSFT)); EXPECT_EMPTY_REPORT(driver); idle_for(TAPPING_TERM - 3); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); } TEST_F(QuickTap, tap_mod_tap_key_while_mod_tap_key_is_held) { @@ -79,32 +79,32 @@ TEST_F(QuickTap, tap_mod_tap_key_while_mod_tap_key_is_held) { EXPECT_NO_REPORT(driver); first_mod_tap_key.press(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Press second mod-tap key */ EXPECT_NO_REPORT(driver); second_mod_tap_key.press(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Release second tap-hold key */ EXPECT_NO_REPORT(driver); second_mod_tap_key.release(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Release first mod-tap key */ EXPECT_REPORT(driver, (KC_LSFT)); first_mod_tap_key.release(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Idle for tapping term of first mod-tap key. */ EXPECT_REPORT(driver, (KC_LSFT, KC_A)); EXPECT_REPORT(driver, (KC_LSFT)); EXPECT_EMPTY_REPORT(driver); idle_for(TAPPING_TERM - 3); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); } TEST_F(QuickTap, tap_regular_key_while_layer_tap_key_is_held) { @@ -120,19 +120,19 @@ TEST_F(QuickTap, tap_regular_key_while_layer_tap_key_is_held) { EXPECT_NO_REPORT(driver); layer_tap_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_NO_REPORT(driver); regular_key.release(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Release layer-tap key */ EXPECT_REPORT(driver, (KC_P)); @@ -141,7 +141,7 @@ TEST_F(QuickTap, tap_regular_key_while_layer_tap_key_is_held) { EXPECT_EMPTY_REPORT(driver); layer_tap_key.release(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); } TEST_F(QuickTap, tap_key_and_tap_again_before_quick_tap_term) { @@ -155,7 +155,7 @@ TEST_F(QuickTap, tap_key_and_tap_again_before_quick_tap_term) { EXPECT_NO_REPORT(driver); mod_tap_key.press(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Release mod-tap key. */ EXPECT_REPORT(driver, (KC_P)); @@ -163,19 +163,19 @@ TEST_F(QuickTap, tap_key_and_tap_again_before_quick_tap_term) { mod_tap_key.release(); idle_for(QUICK_TAP_TERM - 10); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Press and tap mod-tap key again. */ EXPECT_REPORT(driver, (KC_P)); mod_tap_key.press(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Release mod-tap key. */ EXPECT_EMPTY_REPORT(driver); mod_tap_key.release(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); } TEST_F(QuickTap, tap_key_and_hold_again_before_quick_tap_term) { @@ -189,31 +189,31 @@ TEST_F(QuickTap, tap_key_and_hold_again_before_quick_tap_term) { EXPECT_NO_REPORT(driver); mod_tap_key.press(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Release mod-tap key. */ EXPECT_REPORT(driver, (KC_P)); EXPECT_EMPTY_REPORT(driver); mod_tap_key.release(); idle_for(QUICK_TAP_TERM - 10); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Press and hold mod-tap key again. */ EXPECT_REPORT(driver, (KC_P)); mod_tap_key.press(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Wait until tapping term expired */ EXPECT_NO_REPORT(driver); idle_for(TAPPING_TERM); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Release mod-tap key. */ EXPECT_EMPTY_REPORT(driver); mod_tap_key.release(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); } TEST_F(QuickTap, tap_key_and_tap_again_after_quick_tap_term) { @@ -227,7 +227,7 @@ TEST_F(QuickTap, tap_key_and_tap_again_after_quick_tap_term) { EXPECT_NO_REPORT(driver); mod_tap_key.press(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Release mod-tap key. */ EXPECT_REPORT(driver, (KC_P)); @@ -235,20 +235,20 @@ TEST_F(QuickTap, tap_key_and_tap_again_after_quick_tap_term) { mod_tap_key.release(); idle_for(QUICK_TAP_TERM + 10); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Press mod-tap key again. */ EXPECT_NO_REPORT(driver); mod_tap_key.press(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Release mod-tap key. */ EXPECT_REPORT(driver, (KC_P)); EXPECT_EMPTY_REPORT(driver); mod_tap_key.release(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); } TEST_F(QuickTap, tap_key_and_hold_again_after_quick_tap_term) { @@ -262,29 +262,29 @@ TEST_F(QuickTap, tap_key_and_hold_again_after_quick_tap_term) { EXPECT_NO_REPORT(driver); mod_tap_key.press(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Release mod-tap key. */ EXPECT_REPORT(driver, (KC_P)); EXPECT_EMPTY_REPORT(driver); mod_tap_key.release(); idle_for(QUICK_TAP_TERM + 10); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Press and hold mod-tap key again. */ EXPECT_NO_REPORT(driver); mod_tap_key.press(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Wait until tapping term expired */ EXPECT_REPORT(driver, (KC_LSFT)); idle_for(TAPPING_TERM); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); /* Release mod-tap key. */ EXPECT_EMPTY_REPORT(driver); mod_tap_key.release(); run_one_scan_loop(); - testing::Mock::VerifyAndClearExpectations(&driver); + VERIFY_AND_CLEAR(driver); } -- cgit v1.2.3