Revert "[Tests] Increase QMK test coverage (#13789)"
This reverts commit b6054c0206609f3755f71d819643644d250288b0.
This commit is contained in:
7
Makefile
7
Makefile
@ -378,12 +378,11 @@ define PARSE_ALL_KEYMAPS
|
||||
endef
|
||||
|
||||
define BUILD_TEST
|
||||
TEST_PATH := $1
|
||||
TEST_NAME := $$(notdir $$(TEST_PATH))
|
||||
TEST_NAME := $1
|
||||
MAKE_TARGET := $2
|
||||
COMMAND := $1
|
||||
MAKE_CMD := $$(MAKE) -r -R -C $(ROOT_DIR) -f build_test.mk $$(MAKE_TARGET)
|
||||
MAKE_VARS := TEST=$$(TEST_NAME) TEST_PATH=$$(TEST_PATH) FULL_TESTS="$$(FULL_TESTS)"
|
||||
MAKE_VARS := TEST=$$(TEST_NAME) FULL_TESTS="$$(FULL_TESTS)"
|
||||
MAKE_MSG := $$(MSG_MAKE_TEST)
|
||||
$$(eval $$(call BUILD))
|
||||
ifneq ($$(MAKE_TARGET),clean)
|
||||
@ -407,7 +406,7 @@ define PARSE_TEST
|
||||
ifeq ($$(TEST_NAME),all)
|
||||
MATCHED_TESTS := $$(TEST_LIST)
|
||||
else
|
||||
MATCHED_TESTS := $$(foreach TEST, $$(TEST_LIST),$$(if $$(findstring $$(TEST_NAME), $$(notdir $$(TEST))), $$(TEST),))
|
||||
MATCHED_TESTS := $$(foreach TEST,$$(TEST_LIST),$$(if $$(findstring $$(TEST_NAME),$$(TEST)),$$(TEST),))
|
||||
endif
|
||||
$$(foreach TEST,$$(MATCHED_TESTS),$$(eval $$(call BUILD_TEST,$$(TEST),$$(TEST_TARGET))))
|
||||
endef
|
||||
|
@ -13,24 +13,21 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
$(TEST)_INC := \
|
||||
tests\test_common\common_config.h
|
||||
#include $(TMK_PATH)/protocol.mk
|
||||
|
||||
$(TEST)_SRC := \
|
||||
TEST_PATH=tests/$(TEST)
|
||||
|
||||
$(TEST)_SRC= \
|
||||
$(TEST_PATH)/keymap.c \
|
||||
$(TMK_COMMON_SRC) \
|
||||
$(QUANTUM_SRC) \
|
||||
$(SRC) \
|
||||
tests/test_common/keymap.c \
|
||||
tests/test_common/matrix.c \
|
||||
tests/test_common/test_driver.cpp \
|
||||
tests/test_common/keyboard_report_util.cpp \
|
||||
tests/test_common/test_fixture.cpp \
|
||||
tests/test_common/test_keymap_key.cpp \
|
||||
tests/test_common/test_logger.cpp \
|
||||
$(patsubst $(ROOTDIR)/%,%,$(wildcard $(TEST_PATH)/*.cpp))
|
||||
tests/test_common/test_fixture.cpp
|
||||
$(TEST)_SRC += $(patsubst $(ROOTDIR)/%,%,$(wildcard $(TEST_PATH)/*.cpp))
|
||||
|
||||
$(TEST)_DEFS := $(TMK_COMMON_DEFS) $(OPT_DEFS)
|
||||
|
||||
$(TEST)_CONFIG := $(TEST_PATH)/config.h
|
||||
|
||||
VPATH += $(TOP_DIR)/tests/test_common
|
||||
$(TEST)_DEFS=$(TMK_COMMON_DEFS) $(OPT_DEFS)
|
||||
$(TEST)_CONFIG=$(TEST_PATH)/config.h
|
||||
VPATH+=$(TOP_DIR)/tests/test_common
|
||||
|
@ -16,14 +16,14 @@ TEST_OBJ = $(BUILD_DIR)/test_obj
|
||||
OUTPUTS := $(TEST_OBJ)/$(TEST) $(GTEST_OUTPUT)
|
||||
|
||||
GTEST_INC := \
|
||||
$(LIB_PATH)/googletest/googletest/include \
|
||||
$(LIB_PATH)/googletest/googlemock/include
|
||||
$(LIB_PATH)/googletest/googletest/include\
|
||||
$(LIB_PATH)/googletest/googlemock/include\
|
||||
|
||||
GTEST_INTERNAL_INC := \
|
||||
$(LIB_PATH)/googletest/googletest \
|
||||
GTEST_INTERNAL_INC :=\
|
||||
$(LIB_PATH)/googletest/googletest\
|
||||
$(LIB_PATH)/googletest/googlemock
|
||||
|
||||
$(GTEST_OUTPUT)_SRC := \
|
||||
$(GTEST_OUTPUT)_SRC :=\
|
||||
googletest/src/gtest-all.cc\
|
||||
googlemock/src/gmock-all.cc
|
||||
|
||||
@ -33,9 +33,9 @@ $(GTEST_OUTPUT)_INC := $(GTEST_INC) $(GTEST_INTERNAL_INC)
|
||||
LDFLAGS += -lstdc++ -lpthread -shared-libgcc
|
||||
CREATE_MAP := no
|
||||
|
||||
VPATH += \
|
||||
$(LIB_PATH)/googletest \
|
||||
$(LIB_PATH)/googlemock \
|
||||
VPATH +=\
|
||||
$(LIB_PATH)/googletest\
|
||||
$(LIB_PATH)/googlemock\
|
||||
$(LIB_PATH)/printf
|
||||
|
||||
all: elf
|
||||
@ -49,8 +49,7 @@ CONSOLE_ENABLE = yes
|
||||
endif
|
||||
|
||||
ifneq ($(filter $(FULL_TESTS),$(TEST)),)
|
||||
include tests/test_common/build.mk
|
||||
include $(TEST_PATH)/test.mk
|
||||
include tests/$(TEST)/rules.mk
|
||||
endif
|
||||
|
||||
include common_features.mk
|
||||
|
@ -558,6 +558,40 @@ enum quantum_keycodes {
|
||||
PROGRAMMABLE_BUTTON_31,
|
||||
PROGRAMMABLE_BUTTON_32,
|
||||
|
||||
// Dedicated macro keys for Configurator and VIA
|
||||
MACRO_0,
|
||||
MACRO_1,
|
||||
MACRO_2,
|
||||
MACRO_3,
|
||||
MACRO_4,
|
||||
MACRO_5,
|
||||
MACRO_6,
|
||||
MACRO_7,
|
||||
MACRO_8,
|
||||
MACRO_9,
|
||||
MACRO_10,
|
||||
MACRO_11,
|
||||
MACRO_12,
|
||||
MACRO_13,
|
||||
MACRO_14,
|
||||
MACRO_15,
|
||||
MACRO_16,
|
||||
MACRO_17,
|
||||
MACRO_18,
|
||||
MACRO_19,
|
||||
MACRO_20,
|
||||
MACRO_21,
|
||||
MACRO_22,
|
||||
MACRO_23,
|
||||
MACRO_24,
|
||||
MACRO_25,
|
||||
MACRO_26,
|
||||
MACRO_27,
|
||||
MACRO_28,
|
||||
MACRO_29,
|
||||
MACRO_30,
|
||||
MACRO_31,
|
||||
|
||||
// Start of custom keycode range for keyboards and keymaps - always leave at the end
|
||||
SAFE_RANGE
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
TEST_LIST = $(sort $(patsubst %/test.mk,%, $(shell find $(ROOT_DIR)tests -type f -name test.mk)))
|
||||
FULL_TESTS := $(notdir $(TEST_LIST))
|
||||
TEST_LIST = $(notdir $(patsubst %/rules.mk,%,$(wildcard $(ROOT_DIR)/tests/*/rules.mk)))
|
||||
FULL_TESTS := $(TEST_LIST)
|
||||
|
||||
include $(QUANTUM_PATH)/debounce/tests/testlist.mk
|
||||
include $(QUANTUM_PATH)/encoder/tests/testlist.mk
|
||||
|
@ -1,19 +0,0 @@
|
||||
/* Copyright 2021 Stefan Kerkmann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "test_common.h"
|
@ -1,20 +0,0 @@
|
||||
# Copyright 2021 Stefan Kerkmann
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# --------------------------------------------------------------------------------
|
||||
# Keep this file, even if it is empty, as a marker that this folder contains tests
|
||||
# --------------------------------------------------------------------------------
|
||||
|
||||
AUTO_SHIFT_ENABLE = yes
|
@ -1,73 +0,0 @@
|
||||
/* Copyright 2021 Stefan Kerkmann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "keyboard_report_util.hpp"
|
||||
#include "keycode.h"
|
||||
#include "test_common.hpp"
|
||||
#include "action_tapping.h"
|
||||
#include "test_fixture.hpp"
|
||||
#include "test_keymap_key.hpp"
|
||||
|
||||
using testing::_;
|
||||
using testing::InSequence;
|
||||
|
||||
class AutoShift : public TestFixture {};
|
||||
|
||||
TEST_F(AutoShift, key_release_before_timeout) {
|
||||
TestDriver driver;
|
||||
InSequence s;
|
||||
auto regular_key = KeymapKey(0, 2, 0, KC_A);
|
||||
|
||||
set_keymap({regular_key});
|
||||
|
||||
/* Press regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
regular_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
regular_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
}
|
||||
|
||||
TEST_F(AutoShift, key_release_after_timeout) {
|
||||
TestDriver driver;
|
||||
InSequence s;
|
||||
auto regular_key = KeymapKey(0, 2, 0, KC_A);
|
||||
|
||||
set_keymap({regular_key});
|
||||
|
||||
/* Press regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
regular_key.press();
|
||||
idle_for(AUTO_SHIFT_TIMEOUT);
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
regular_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
}
|
@ -16,4 +16,5 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "test_common.h"
|
||||
#define MATRIX_ROWS 4
|
||||
#define MATRIX_COLS 10
|
||||
|
45
tests/basic/keymap.c
Normal file
45
tests/basic/keymap.c
Normal file
@ -0,0 +1,45 @@
|
||||
/* Copyright 2017 Fred Sundvik
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "quantum.h"
|
||||
|
||||
// Don't rearrange keys as existing tests might rely on the order
|
||||
// Col2, Row 0 has to be KC_NO, because tests rely on it
|
||||
|
||||
#define COMBO1 RSFT(LCTL(KC_O))
|
||||
|
||||
const uint16_t PROGMEM
|
||||
keymaps[][MATRIX_ROWS][MATRIX_COLS] =
|
||||
{
|
||||
[0] =
|
||||
{
|
||||
// 0 1 2 3 4 5 6 7 8 9
|
||||
{KC_A, KC_B, KC_NO, KC_LSFT, KC_RSFT, KC_LCTL, COMBO1, SFT_T(KC_P), M(0), KC_NO},
|
||||
{KC_EQL, KC_PLUS, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO},
|
||||
{KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO},
|
||||
{KC_C, KC_D, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO},
|
||||
},
|
||||
};
|
||||
|
||||
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
|
||||
if (record->event.pressed) {
|
||||
switch (id) {
|
||||
case 0:
|
||||
return MACRO(D(LSFT), T(H), U(LSFT), T(E), T(L), T(L), T(O), T(SPACE), W(100), D(LSFT), T(W), U(LSFT), I(10), T(O), T(R), T(L), T(D), D(LSFT), T(1), U(LSFT), END);
|
||||
}
|
||||
}
|
||||
return MACRO_NONE;
|
||||
};
|
@ -1,4 +1,4 @@
|
||||
# Copyright 2021 Stefan Kerkmann
|
||||
# Copyright 2017 Fred Sundvik
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -13,4 +13,4 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
CUSTOM_MATRIX=yes
|
||||
CUSTOM_MATRIX=yes
|
@ -1,18 +0,0 @@
|
||||
# Copyright 2017 Fred Sundvik
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# --------------------------------------------------------------------------------
|
||||
# Keep this file, even if it is empty, as a marker that this folder contains tests
|
||||
# --------------------------------------------------------------------------------
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -24,25 +24,10 @@ class Macro : public TestFixture {};
|
||||
|
||||
#define AT_TIME(t) WillOnce(InvokeWithoutArgs([current_time]() { EXPECT_EQ(timer_elapsed32(current_time), t); }))
|
||||
|
||||
extern "C" const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
|
||||
if (record->event.pressed) {
|
||||
switch (id) {
|
||||
case 0:
|
||||
return MACRO(D(LSFT), T(H), U(LSFT), T(E), T(L), T(L), T(O), T(SPACE), W(100), D(LSFT), T(W), U(LSFT), I(10), T(O), T(R), T(L), T(D), D(LSFT), T(1), U(LSFT), END);
|
||||
}
|
||||
}
|
||||
return MACRO_NONE;
|
||||
};
|
||||
|
||||
TEST_F(Macro, PlayASimpleMacro) {
|
||||
TestDriver driver;
|
||||
InSequence s;
|
||||
auto key_macro = KeymapKey(0, 8, 0, M(0));
|
||||
|
||||
set_keymap({key_macro});
|
||||
|
||||
key_macro.press();
|
||||
|
||||
press_key(8, 0);
|
||||
uint32_t current_time = timer_read32();
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))).AT_TIME(0);
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT, KC_H))).AT_TIME(0);
|
||||
@ -83,6 +68,4 @@ TEST_F(Macro, PlayASimpleMacro) {
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))).AT_TIME(210);
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).AT_TIME(220);
|
||||
run_one_scan_loop();
|
||||
|
||||
key_macro.release();
|
||||
}
|
||||
|
@ -1,197 +0,0 @@
|
||||
/* Copyright 2021 Stefan Kerkmann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "action_util.h"
|
||||
#include "keyboard_report_util.hpp"
|
||||
#include "test_common.hpp"
|
||||
|
||||
using testing::_;
|
||||
using testing::InSequence;
|
||||
|
||||
class OneShot : public TestFixture {};
|
||||
class OneShotParametrizedTestFixture : public ::testing::WithParamInterface<std::pair<KeymapKey, KeymapKey>>, public OneShot {};
|
||||
|
||||
TEST_F(OneShot, OSMWithoutAdditionalKeypressDoesNothing) {
|
||||
TestDriver driver;
|
||||
auto osm_key = KeymapKey(0, 0, 0, OSM(MOD_LSFT), KC_LSFT);
|
||||
|
||||
set_keymap({osm_key});
|
||||
|
||||
/* Press and release OSM key*/
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
osm_key.press();
|
||||
run_one_scan_loop();
|
||||
osm_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* OSM are added when an actual report is send */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(osm_key.report_code)));
|
||||
send_keyboard_report();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Make unit-test pass */
|
||||
clear_oneshot_mods();
|
||||
}
|
||||
|
||||
#if defined(ONESHOT_TIMEOUT)
|
||||
|
||||
TEST_P(OneShotParametrizedTestFixture, OSMExpiredDoesNothing) {
|
||||
TestDriver driver;
|
||||
KeymapKey osm_key = GetParam().first;
|
||||
KeymapKey regular_key = GetParam().second;
|
||||
|
||||
set_keymap({osm_key, regular_key});
|
||||
|
||||
/* Press and release OSM */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
osm_key.press();
|
||||
run_one_scan_loop();
|
||||
osm_key.release();
|
||||
idle_for(ONESHOT_TIMEOUT);
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Press regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(regular_key.report_code))).Times(1);
|
||||
regular_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
regular_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
TEST_P(OneShotParametrizedTestFixture, OSMWithAdditionalKeypress) {
|
||||
TestDriver driver;
|
||||
KeymapKey osm_key = GetParam().first;
|
||||
KeymapKey regular_key = GetParam().second;
|
||||
|
||||
set_keymap({osm_key, regular_key});
|
||||
|
||||
/* Press and release OSM */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
osm_key.press();
|
||||
run_one_scan_loop();
|
||||
osm_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Press regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(osm_key.report_code, regular_key.report_code))).Times(1);
|
||||
regular_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
regular_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
}
|
||||
|
||||
TEST_P(OneShotParametrizedTestFixture, OSMAsRegularModifierWithAdditionalKeypress) {
|
||||
TestDriver driver;
|
||||
testing::InSequence s;
|
||||
|
||||
KeymapKey osm_key = GetParam().first;
|
||||
KeymapKey regular_key = GetParam().second;
|
||||
|
||||
set_keymap({osm_key, regular_key});
|
||||
|
||||
/* Press OSM */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
osm_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Press regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
regular_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
regular_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release OSM */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(regular_key.report_code, osm_key.report_code))).Times(1);
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1);
|
||||
osm_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
OneShotModifierTests,
|
||||
OneShotParametrizedTestFixture,
|
||||
::testing::Values(
|
||||
/* first is osm key, second is regular key. */
|
||||
std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_LSFT), KC_LSFT}, KeymapKey{0, 1, 1, KC_A}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_LCTL), KC_LCTL}, KeymapKey{0, 1, 1, KC_A}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_LALT), KC_LALT}, KeymapKey{0, 1, 1, KC_A}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_LGUI), KC_LGUI}, KeymapKey{0, 1, 1, KC_A}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_RCTL), KC_RCTL}, KeymapKey{0, 1, 1, KC_A}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_RSFT), KC_RSFT}, KeymapKey{0, 1, 1, KC_A}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_RALT), KC_RALT}, KeymapKey{0, 1, 1, KC_A}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_RGUI), KC_RGUI}, KeymapKey{0, 1, 1, KC_A})
|
||||
));
|
||||
// clang-format on
|
||||
|
||||
TEST_F(OneShot, OSLWithAdditionalKeypress) {
|
||||
TestDriver driver;
|
||||
InSequence s;
|
||||
KeymapKey osl_key = KeymapKey{0, 0, 0, OSL(1)};
|
||||
KeymapKey regular_key = KeymapKey{1, 1, 0, KC_A};
|
||||
|
||||
set_keymap({osl_key, regular_key});
|
||||
|
||||
/* Press OSL key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
osl_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release OSL key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(2);
|
||||
osl_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Press regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(regular_key.report_code))).Times(2);
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
regular_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
regular_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
}
|
@ -14,11 +14,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "keyboard_report_util.hpp"
|
||||
#include "keycode.h"
|
||||
#include "test_common.hpp"
|
||||
#include "action_tapping.h"
|
||||
#include "test_keymap_key.hpp"
|
||||
|
||||
using testing::_;
|
||||
using testing::InSequence;
|
||||
@ -28,19 +25,14 @@ class Tapping : public TestFixture {};
|
||||
TEST_F(Tapping, TapA_SHFT_T_KeyReportsKey) {
|
||||
TestDriver driver;
|
||||
InSequence s;
|
||||
auto key_shift_hold_p_tap = KeymapKey(0, 7, 0, SFT_T(KC_P));
|
||||
|
||||
set_keymap({key_shift_hold_p_tap});
|
||||
|
||||
press_key(7, 0);
|
||||
// Tapping keys does nothing on press
|
||||
key_shift_hold_p_tap.press();
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
run_one_scan_loop();
|
||||
|
||||
release_key(7, 0);
|
||||
// First we get the key press
|
||||
key_shift_hold_p_tap.release();
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
|
||||
|
||||
// Then the release
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
run_one_scan_loop();
|
||||
@ -49,38 +41,25 @@ TEST_F(Tapping, TapA_SHFT_T_KeyReportsKey) {
|
||||
TEST_F(Tapping, HoldA_SHFT_T_KeyReportsShift) {
|
||||
TestDriver driver;
|
||||
InSequence s;
|
||||
auto mod_tap_hold_key = KeymapKey(0, 7, 0, SFT_T(KC_P));
|
||||
|
||||
set_keymap({mod_tap_hold_key});
|
||||
|
||||
mod_tap_hold_key.press();
|
||||
|
||||
press_key(7, 0);
|
||||
// Tapping keys does nothing on press
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
idle_for(TAPPING_TERM);
|
||||
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT)));
|
||||
run_one_scan_loop();
|
||||
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
mod_tap_hold_key.release();
|
||||
run_one_scan_loop();
|
||||
}
|
||||
|
||||
TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) {
|
||||
// See issue #1478 for more information
|
||||
TestDriver driver;
|
||||
InSequence s;
|
||||
auto key_shift_hold_p_tap = KeymapKey(0, 7, 0, SFT_T(KC_P));
|
||||
|
||||
set_keymap({key_shift_hold_p_tap});
|
||||
|
||||
press_key(7, 0);
|
||||
// Tapping keys does nothing on press
|
||||
key_shift_hold_p_tap.press();
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
run_one_scan_loop();
|
||||
key_shift_hold_p_tap.release();
|
||||
|
||||
release_key(7, 0);
|
||||
// First we get the key press
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
|
||||
// Then the release
|
||||
@ -88,20 +67,19 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) {
|
||||
run_one_scan_loop();
|
||||
|
||||
// This sends KC_P, even if it should do nothing
|
||||
key_shift_hold_p_tap.press();
|
||||
press_key(7, 0);
|
||||
// This test should not succed if everything works correctly
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
|
||||
run_one_scan_loop();
|
||||
|
||||
key_shift_hold_p_tap.release();
|
||||
release_key(7, 0);
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
idle_for(TAPPING_TERM + 1);
|
||||
|
||||
// On the other hand, nothing is sent if we are outside the tapping term
|
||||
key_shift_hold_p_tap.press();
|
||||
press_key(7, 0);
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
run_one_scan_loop();
|
||||
key_shift_hold_p_tap.release();
|
||||
release_key(7, 0);
|
||||
|
||||
// First we get the key press
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
|
||||
@ -112,12 +90,8 @@ TEST_F(Tapping, ANewTapWithinTappingTermIsBuggy) {
|
||||
// Now we are geting into strange territory, as the hold registers too early here
|
||||
// But the stranges part is:
|
||||
// If TAPPING_TERM + 1 above is changed to TAPPING_TERM or TAPPING_TERM + 2 it doesn't
|
||||
key_shift_hold_p_tap.press();
|
||||
press_key(7, 0);
|
||||
// Shouldn't be called here really
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LEFT_SHIFT))).Times(1);
|
||||
idle_for(TAPPING_TERM);
|
||||
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
key_shift_hold_p_tap.release();
|
||||
run_one_scan_loop();
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
/* Copyright 2021 Stefan Kerkmann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "test_common.h"
|
||||
|
||||
#define IGNORE_MOD_TAP_INTERRUPT
|
@ -1,18 +0,0 @@
|
||||
# Copyright 2021 Stefan Kerkmann
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# --------------------------------------------------------------------------------
|
||||
# Keep this file, even if it is empty, as a marker that this folder contains tests
|
||||
# --------------------------------------------------------------------------------
|
@ -1,230 +0,0 @@
|
||||
/* Copyright 2021 Stefan Kerkmann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "keyboard_report_util.hpp"
|
||||
#include "keycode.h"
|
||||
#include "test_common.hpp"
|
||||
#include "action_tapping.h"
|
||||
#include "test_fixture.hpp"
|
||||
#include "test_keymap_key.hpp"
|
||||
|
||||
using testing::_;
|
||||
using testing::InSequence;
|
||||
|
||||
class DefaultTapHold : public TestFixture {};
|
||||
|
||||
TEST_F(DefaultTapHold, tap_regular_key_while_mod_tap_key_is_held) {
|
||||
TestDriver driver;
|
||||
InSequence s;
|
||||
auto mod_tap_hold_key = KeymapKey(0, 1, 0, SFT_T(KC_P));
|
||||
auto regular_key = KeymapKey(0, 2, 0, KC_A);
|
||||
|
||||
set_keymap({mod_tap_hold_key, regular_key});
|
||||
|
||||
/* Press mod-tap-hold key. */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
mod_tap_hold_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Press regular key. */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
regular_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release regular key. */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
regular_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release mod-tap-hold key. */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P, KC_A)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
mod_tap_hold_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Idle for tapping term of mod tap hold key. */
|
||||
idle_for(TAPPING_TERM - 3);
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
}
|
||||
|
||||
TEST_F(DefaultTapHold, tap_mod_tap_key_while_mod_tap_key_is_held) {
|
||||
TestDriver driver;
|
||||
InSequence s;
|
||||
auto first_mod_tap_hold_key = KeymapKey(0, 1, 0, SFT_T(KC_P));
|
||||
auto second_mod_tap_hold_key = KeymapKey(0, 2, 0, RSFT_T(KC_A));
|
||||
|
||||
set_keymap({first_mod_tap_hold_key, second_mod_tap_hold_key});
|
||||
|
||||
/* Press first mod-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
first_mod_tap_hold_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Press second tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
second_mod_tap_hold_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release second tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
second_mod_tap_hold_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release first mod-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P, KC_A)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
first_mod_tap_hold_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
}
|
||||
|
||||
TEST_F(DefaultTapHold, tap_regular_key_while_layer_tap_key_is_held) {
|
||||
TestDriver driver;
|
||||
InSequence s;
|
||||
auto layer_tap_hold_key = KeymapKey(0, 1, 0, LT(1, KC_P));
|
||||
auto regular_key = KeymapKey(0, 2, 0, KC_A);
|
||||
auto layer_key = KeymapKey(1, 2, 0, KC_B);
|
||||
|
||||
set_keymap({layer_tap_hold_key, regular_key, layer_key});
|
||||
|
||||
/* Press layer-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
layer_tap_hold_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Press regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
regular_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
regular_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release layer-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A, KC_P)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_));
|
||||
layer_tap_hold_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
}
|
||||
|
||||
TEST_F(DefaultTapHold, tap_mod_tap_hold_key_two_times) {
|
||||
GTEST_SKIP() << "TODO:Holding a modtap key results in out of bounds access to the keymap, this is a bug in QMK.";
|
||||
|
||||
TestDriver driver;
|
||||
InSequence s;
|
||||
auto mod_tap_hold_key = KeymapKey(0, 1, 0, SFT_T(KC_P));
|
||||
|
||||
set_keymap({mod_tap_hold_key});
|
||||
|
||||
/* Press mod-tap-hold key. */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
mod_tap_hold_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release mod-tap-hold key. */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
mod_tap_hold_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Press mod-tap-hold key again. */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
|
||||
mod_tap_hold_key.press();
|
||||
idle_for(TAPPING_TERM);
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release mod-tap-hold key. */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
mod_tap_hold_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
}
|
||||
|
||||
TEST_F(DefaultTapHold, tap_mod_tap_hold_key_twice_and_hold_on_second_time) {
|
||||
GTEST_SKIP() << "TODO:Holding a modtap key results in out of bounds access to the keymap, this is a bug in QMK.";
|
||||
|
||||
TestDriver driver;
|
||||
InSequence s;
|
||||
auto mod_tap_hold_key = KeymapKey(0, 1, 0, SFT_T(KC_P));
|
||||
|
||||
set_keymap({mod_tap_hold_key});
|
||||
|
||||
/* Press mod-tap-hold key. */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
mod_tap_hold_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release mod-tap-hold key. */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
mod_tap_hold_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Press mod-tap-hold key again. */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
|
||||
mod_tap_hold_key.press();
|
||||
idle_for(TAPPING_TERM);
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release mod-tap-hold key. */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
mod_tap_hold_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
}
|
||||
|
||||
TEST_F(DefaultTapHold, tap_and_hold_mod_tap_hold_key) {
|
||||
TestDriver driver;
|
||||
InSequence s;
|
||||
auto mod_tap_hold_key = KeymapKey(0, 1, 0, SFT_T(KC_P));
|
||||
|
||||
set_keymap({mod_tap_hold_key});
|
||||
|
||||
/* Press mod-tap-hold key. */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSHIFT)));
|
||||
mod_tap_hold_key.press();
|
||||
idle_for(TAPPING_TERM + 1);
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release mod-tap-hold key. */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
mod_tap_hold_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/* Copyright 2021 Stefan Kerkmann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "test_common.h"
|
||||
|
||||
#define IGNORE_MOD_TAP_INTERRUPT
|
@ -1,18 +0,0 @@
|
||||
# Copyright 2021 Stefan Kerkmann
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# --------------------------------------------------------------------------------
|
||||
# Keep this file, even if it is empty, as a marker that this folder contains tests
|
||||
# --------------------------------------------------------------------------------
|
@ -1,136 +0,0 @@
|
||||
/* Copyright 2021 Stefan Kerkmann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "keyboard_report_util.hpp"
|
||||
#include "keycode.h"
|
||||
#include "test_common.hpp"
|
||||
#include "action_tapping.h"
|
||||
#include "test_fixture.hpp"
|
||||
#include "test_keymap_key.hpp"
|
||||
|
||||
using testing::_;
|
||||
using testing::InSequence;
|
||||
|
||||
class IgnoreModTapInterrupt : public TestFixture {};
|
||||
|
||||
TEST_F(IgnoreModTapInterrupt, tap_regular_key_while_mod_tap_key_is_held) {
|
||||
TestDriver driver;
|
||||
InSequence s;
|
||||
auto mod_tap_hold_key = KeymapKey(0, 1, 0, SFT_T(KC_P));
|
||||
auto regular_key = KeymapKey(0, 2, 0, KC_A);
|
||||
|
||||
set_keymap({mod_tap_hold_key, regular_key});
|
||||
|
||||
/* Press mod-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
mod_tap_hold_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Press regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
regular_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
regular_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release mod-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A, KC_P)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
mod_tap_hold_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
}
|
||||
|
||||
TEST_F(IgnoreModTapInterrupt, tap_mod_tap_key_while_mod_tap_key_is_held) {
|
||||
TestDriver driver;
|
||||
InSequence s;
|
||||
auto first_mod_tap_hold_key = KeymapKey(0, 1, 0, SFT_T(KC_P));
|
||||
auto second_mod_tap_hold_key = KeymapKey(0, 2, 0, RSFT_T(KC_A));
|
||||
|
||||
set_keymap({first_mod_tap_hold_key, second_mod_tap_hold_key});
|
||||
|
||||
/* Press first mod-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
first_mod_tap_hold_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Press second tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
second_mod_tap_hold_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release second tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
second_mod_tap_hold_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release first mod-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_A, KC_P)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
first_mod_tap_hold_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
}
|
||||
|
||||
TEST_F(IgnoreModTapInterrupt, tap_regular_key_while_layer_tap_key_is_held) {
|
||||
TestDriver driver;
|
||||
InSequence s;
|
||||
auto layer_tap_hold_key = KeymapKey(0, 1, 0, LT(1, KC_P));
|
||||
auto regular_key = KeymapKey(0, 2, 0, KC_A);
|
||||
auto layer_key = KeymapKey(1, 2, 0, KC_B);
|
||||
|
||||
set_keymap({layer_tap_hold_key, regular_key, layer_key});
|
||||
|
||||
/* Press layer-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
layer_tap_hold_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Press regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
regular_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
regular_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release layer-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P, regular_key.report_code)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_P)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
layer_tap_hold_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/* Copyright 2021 Stefan Kerkmann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "test_common.h"
|
||||
|
||||
#define PERMISSIVE_HOLD
|
@ -1,18 +0,0 @@
|
||||
# Copyright 2021 Stefan Kerkmann
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# --------------------------------------------------------------------------------
|
||||
# Keep this file, even if it is empty, as a marker that this folder contains tests
|
||||
# --------------------------------------------------------------------------------
|
@ -1,76 +0,0 @@
|
||||
/* Copyright 2021 Stefan Kerkmann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "action_util.h"
|
||||
#include "keyboard_report_util.hpp"
|
||||
#include "test_common.hpp"
|
||||
|
||||
using testing::_;
|
||||
using testing::InSequence;
|
||||
|
||||
class OneShot : public TestFixture {};
|
||||
class OneShotParametrizedTestFixture : public ::testing::WithParamInterface<std::pair<KeymapKey, KeymapKey>>, public OneShot {};
|
||||
|
||||
TEST_P(OneShotParametrizedTestFixture, OSMAsRegularModifierWithAdditionalKeypress) {
|
||||
TestDriver driver;
|
||||
KeymapKey osm_key = GetParam().first;
|
||||
KeymapKey regular_key = GetParam().second;
|
||||
|
||||
set_keymap({osm_key, regular_key});
|
||||
|
||||
/* Press OSM */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
osm_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Press regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
regular_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(osm_key.report_code))).Times(2);
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(regular_key.report_code, osm_key.report_code))).Times(1);
|
||||
regular_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release OSM */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport())).Times(1);
|
||||
osm_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
}
|
||||
|
||||
// clang-format off
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
OneShotModifierTests,
|
||||
OneShotParametrizedTestFixture,
|
||||
::testing::Values(
|
||||
/* first is osm key, second is regular key. */
|
||||
std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_LSFT), KC_LSFT}, KeymapKey{0, 1, 1, KC_A}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_LCTL), KC_LCTL}, KeymapKey{0, 1, 1, KC_A}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_LALT), KC_LALT}, KeymapKey{0, 1, 1, KC_A}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_LGUI), KC_LGUI}, KeymapKey{0, 1, 1, KC_A}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_RCTL), KC_RCTL}, KeymapKey{0, 1, 1, KC_A}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_RSFT), KC_RSFT}, KeymapKey{0, 1, 1, KC_A}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_RALT), KC_RALT}, KeymapKey{0, 1, 1, KC_A}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, OSM(MOD_RGUI), KC_RGUI}, KeymapKey{0, 1, 1, KC_A})
|
||||
));
|
||||
// clang-format on
|
@ -1,132 +0,0 @@
|
||||
/* Copyright 2021 Stefan Kerkmann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "keyboard_report_util.hpp"
|
||||
#include "keycode.h"
|
||||
#include "test_common.hpp"
|
||||
#include "action_tapping.h"
|
||||
#include "test_fixture.hpp"
|
||||
#include "test_keymap_key.hpp"
|
||||
|
||||
using testing::_;
|
||||
using testing::InSequence;
|
||||
class PermissiveHold : public TestFixture {};
|
||||
|
||||
TEST_F(PermissiveHold, tap_regular_key_while_mod_tap_key_is_held) {
|
||||
TestDriver driver;
|
||||
InSequence s;
|
||||
auto mod_tap_hold_key = KeymapKey(0, 1, 0, SFT_T(KC_P));
|
||||
auto regular_key = KeymapKey(0, 2, 0, KC_A);
|
||||
|
||||
set_keymap({mod_tap_hold_key, regular_key});
|
||||
|
||||
/* Press mod-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
mod_tap_hold_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Press regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
regular_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSHIFT)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSHIFT, regular_key.report_code)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSHIFT)));
|
||||
regular_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release mod-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
mod_tap_hold_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
}
|
||||
|
||||
TEST_F(PermissiveHold, tap_mod_tap_key_while_mod_tap_key_is_held) {
|
||||
TestDriver driver;
|
||||
InSequence s;
|
||||
auto first_mod_tap_hold_key = KeymapKey(0, 1, 0, SFT_T(KC_P));
|
||||
auto second_mod_tap_hold_key = KeymapKey(0, 2, 0, RSFT_T(KC_A));
|
||||
|
||||
set_keymap({first_mod_tap_hold_key, second_mod_tap_hold_key});
|
||||
|
||||
/* Press first mod-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
first_mod_tap_hold_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Press second mod-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
second_mod_tap_hold_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release second mod-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSHIFT)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSHIFT, second_mod_tap_hold_key.report_code)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSHIFT)));
|
||||
second_mod_tap_hold_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release first mod-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
first_mod_tap_hold_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
}
|
||||
|
||||
TEST_F(PermissiveHold, tap_regular_key_while_layer_tap_key_is_held) {
|
||||
TestDriver driver;
|
||||
InSequence s;
|
||||
auto layer_tap_hold_key = KeymapKey(0, 1, 0, LT(1, KC_P));
|
||||
auto regular_key = KeymapKey(0, 2, 0, KC_A);
|
||||
auto layer_key = KeymapKey(1, 2, 0, KC_B);
|
||||
|
||||
set_keymap({layer_tap_hold_key, regular_key, layer_key});
|
||||
|
||||
/* Press layer-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
layer_tap_hold_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Press regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
regular_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(layer_key.report_code)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
regular_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release layer-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
layer_tap_hold_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
/* Copyright 2021 Stefan Kerkmann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "test_common.h"
|
||||
|
||||
#define IGNORE_MOD_TAP_INTERRUPT
|
||||
#define PERMISSIVE_HOLD
|
@ -1,18 +0,0 @@
|
||||
# Copyright 2021 Stefan Kerkmann
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# --------------------------------------------------------------------------------
|
||||
# Keep this file, even if it is empty, as a marker that this folder contains tests
|
||||
# --------------------------------------------------------------------------------
|
@ -1,134 +0,0 @@
|
||||
|
||||
/* Copyright 2021 Stefan Kerkmann
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "keyboard_report_util.hpp"
|
||||
#include "keycode.h"
|
||||
#include "test_common.hpp"
|
||||
#include "action_tapping.h"
|
||||
#include "test_fixture.hpp"
|
||||
#include "test_keymap_key.hpp"
|
||||
|
||||
using testing::_;
|
||||
using testing::InSequence;
|
||||
|
||||
class PermissiveHold_IgnoreModTapInterrupt : public TestFixture {};
|
||||
|
||||
TEST_F(PermissiveHold_IgnoreModTapInterrupt, tap_regular_key_while_mod_tap_key_is_held) {
|
||||
TestDriver driver;
|
||||
InSequence s;
|
||||
auto mod_tap_hold_key = KeymapKey(0, 1, 0, SFT_T(KC_P));
|
||||
auto regular_key = KeymapKey(0, 2, 0, KC_A);
|
||||
|
||||
set_keymap({mod_tap_hold_key, regular_key});
|
||||
|
||||
/* Press mod-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
mod_tap_hold_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Press regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
regular_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
|
||||
regular_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release mod-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
mod_tap_hold_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
}
|
||||
|
||||
TEST_F(PermissiveHold_IgnoreModTapInterrupt, tap_mod_tap_key_while_mod_tap_key_is_held) {
|
||||
TestDriver driver;
|
||||
InSequence s;
|
||||
auto first_mod_tap_hold_key = KeymapKey(0, 1, 0, SFT_T(KC_P));
|
||||
auto second_mod_tap_hold_key = KeymapKey(0, 2, 0, RSFT_T(KC_A));
|
||||
|
||||
set_keymap({first_mod_tap_hold_key, second_mod_tap_hold_key});
|
||||
|
||||
/* Press first mod-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
first_mod_tap_hold_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Press second tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
second_mod_tap_hold_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release second tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT, KC_A)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_LSFT)));
|
||||
second_mod_tap_hold_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release first mod-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
first_mod_tap_hold_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
}
|
||||
|
||||
TEST_F(PermissiveHold_IgnoreModTapInterrupt, tap_regular_key_while_layer_tap_key_is_held) {
|
||||
TestDriver driver;
|
||||
InSequence s;
|
||||
auto layer_tap_hold_key = KeymapKey(0, 1, 0, LT(1, KC_P));
|
||||
auto regular_key = KeymapKey(0, 2, 0, KC_A);
|
||||
auto layer_key = KeymapKey(1, 2, 0, KC_B);
|
||||
|
||||
set_keymap({layer_tap_hold_key, regular_key, layer_key});
|
||||
|
||||
/* Press layer-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
layer_tap_hold_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Press regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(_)).Times(0);
|
||||
regular_key.press();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release regular key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport(KC_B)));
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
regular_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
|
||||
/* Release layer-tap-hold key */
|
||||
EXPECT_CALL(driver, send_keyboard_mock(KeyboardReport()));
|
||||
layer_tap_hold_key.release();
|
||||
run_one_scan_loop();
|
||||
testing::Mock::VerifyAndClearExpectations(&driver);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user