tests: Update some of the naming in the layer activation order test

Thanks @obra for the new names!

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/867/head
Gergely Nagy 4 years ago
parent 60c138d756
commit 7d7615ef6f
No known key found for this signature in database
GPG Key ID: AC1E90BAC433F68F

@ -44,24 +44,24 @@ class LayerActivationOrder : public VirtualDeviceTest {
sim_.Release(addr.row(), addr.col()); sim_.Release(addr.row(), addr.col());
} }
auto pressKeyswitchAndCycle(const KeyAddr& addr) { auto pressKeyswitchAndRunCycle(const KeyAddr& addr) {
pressKeyswitch(addr); pressKeyswitch(addr);
return RunCycle(); return RunCycle();
} }
auto releaseKeyswitchAndCycle(const KeyAddr& addr) { auto releaseKeyswitchAndRunCycle(const KeyAddr& addr) {
releaseKeyswitch(addr); releaseKeyswitch(addr);
return RunCycle(); return RunCycle();
} }
void assertSingleReportThatContains(std::unique_ptr<State> &state, Key k) { void assertSingleKeyboardReportContaining(std::unique_ptr<State> &state, Key k) {
ASSERT_EQ(state->HIDReports()->Keyboard().size(), 1); ASSERT_EQ(state->HIDReports()->Keyboard().size(), 1);
EXPECT_THAT( EXPECT_THAT(
state->HIDReports()->Keyboard(0).ActiveKeycodes(), state->HIDReports()->Keyboard(0).ActiveKeycodes(),
Contains(k)); Contains(k));
} }
void assertSingleReportThatDoesNotContain(std::unique_ptr<State> &state, Key k) { void assertSingleKeyboardReportNotContaining(std::unique_ptr<State> &state, Key k) {
ASSERT_EQ(state->HIDReports()->Keyboard().size(), 1); ASSERT_EQ(state->HIDReports()->Keyboard().size(), 1);
EXPECT_THAT( EXPECT_THAT(
state->HIDReports()->Keyboard(0).ActiveKeycodes(), state->HIDReports()->Keyboard(0).ActiveKeycodes(),
@ -85,10 +85,10 @@ class LayerActivationOrder : public VirtualDeviceTest {
} }
void TestPressAndRelease(const KeyAddr& addr, Key k) { void TestPressAndRelease(const KeyAddr& addr, Key k) {
auto state = pressKeyswitchAndCycle(addr); auto state = pressKeyswitchAndRunCycle(addr);
assertSingleReportThatContains(state, k); assertSingleKeyboardReportContaining(state, k);
state = releaseKeyswitchAndCycle(addr); state = releaseKeyswitchAndRunCycle(addr);
assertSingleEmptyReport(state); assertSingleEmptyReport(state);
assertNoReportAfterCycle(); assertNoReportAfterCycle();
@ -101,21 +101,21 @@ TEST_F(LayerActivationOrder, BaseLayerHasNotRegressed) {
TEST_F(LayerActivationOrder, ShifToLayerOne) { TEST_F(LayerActivationOrder, ShifToLayerOne) {
// Pressing (KEYSWITCH_LEFT_PALM) shifts to Layer 1, and we stay there until release. // Pressing (KEYSWITCH_LEFT_PALM) shifts to Layer 1, and we stay there until release.
auto state = pressKeyswitchAndCycle(KEYSWITCH_LEFT_PALM); auto state = pressKeyswitchAndRunCycle(KEYSWITCH_LEFT_PALM);
TestPressAndRelease(KEYSWITCH_TOP_LEFT, LAYER1_KEY); TestPressAndRelease(KEYSWITCH_TOP_LEFT, LAYER1_KEY);
// Releasing (KEYSWITCH_LEFT_PALM) gets us back to the base layer // Releasing (KEYSWITCH_LEFT_PALM) gets us back to the base layer
state = releaseKeyswitchAndCycle(KEYSWITCH_LEFT_PALM); state = releaseKeyswitchAndRunCycle(KEYSWITCH_LEFT_PALM);
TestPressAndRelease(KEYSWITCH_TOP_LEFT, LAYER0_KEY); TestPressAndRelease(KEYSWITCH_TOP_LEFT, LAYER0_KEY);
} }
TEST_F(LayerActivationOrder, ShiftingWithCaching) { TEST_F(LayerActivationOrder, ShiftingWithCaching) {
// Pressing (KEYSWITCH_TOP_LEFT) will activate the key on layer 0 // Pressing (KEYSWITCH_TOP_LEFT) will activate the key on layer 0
auto state = pressKeyswitchAndCycle(KEYSWITCH_TOP_LEFT); auto state = pressKeyswitchAndRunCycle(KEYSWITCH_TOP_LEFT);
assertSingleReportThatContains(state, LAYER0_KEY); assertSingleKeyboardReportContaining(state, LAYER0_KEY);
// Pressing (KEYSWITCH_LEFT_PALM) will switch to Layer 1 // Pressing (KEYSWITCH_LEFT_PALM) will switch to Layer 1
state = pressKeyswitchAndCycle(KEYSWITCH_LEFT_PALM); state = pressKeyswitchAndRunCycle(KEYSWITCH_LEFT_PALM);
// ...since we're still pressing (KEYSWITCH_TOP_LEFT), and there was no change // ...since we're still pressing (KEYSWITCH_TOP_LEFT), and there was no change
// in the HID states, we shouldn't emit a report. // in the HID states, we shouldn't emit a report.
@ -124,24 +124,24 @@ TEST_F(LayerActivationOrder, ShiftingWithCaching) {
// Pressing (KEYSWITCH_TOP_RIGHT), the report shall contain keys from both // Pressing (KEYSWITCH_TOP_RIGHT), the report shall contain keys from both
// layer 0 and layer1, because we started holding the layer 0 key prior to // layer 0 and layer1, because we started holding the layer 0 key prior to
// switching layers, so it's code should remain cached. // switching layers, so it's code should remain cached.
state = pressKeyswitchAndCycle(KEYSWITCH_TOP_RIGHT); state = pressKeyswitchAndRunCycle(KEYSWITCH_TOP_RIGHT);
assertSingleReportThatContains(state, LAYER0_KEY); assertSingleKeyboardReportContaining(state, LAYER0_KEY);
assertSingleReportThatContains(state, LAYER1_KEY); assertSingleKeyboardReportContaining(state, LAYER1_KEY);
// Releasing (KEYSWITCH_TOP_LEFT), the report should now contain the key from // Releasing (KEYSWITCH_TOP_LEFT), the report should now contain the key from
// layer1 only, and should not contain the layer0 key anymore. // layer1 only, and should not contain the layer0 key anymore.
state = releaseKeyswitchAndCycle(KEYSWITCH_TOP_LEFT); state = releaseKeyswitchAndRunCycle(KEYSWITCH_TOP_LEFT);
assertSingleReportThatContains(state, LAYER1_KEY); assertSingleKeyboardReportContaining(state, LAYER1_KEY);
assertSingleReportThatDoesNotContain(state, LAYER0_KEY); assertSingleKeyboardReportNotContaining(state, LAYER0_KEY);
// Release (KEYSWITCH_TOP_RIGHT) // Release (KEYSWITCH_TOP_RIGHT)
state = releaseKeyswitchAndCycle(KEYSWITCH_TOP_RIGHT); state = releaseKeyswitchAndRunCycle(KEYSWITCH_TOP_RIGHT);
// Test the layer 1 key in isolation again // Test the layer 1 key in isolation again
TestPressAndRelease(KEYSWITCH_TOP_LEFT, LAYER1_KEY); TestPressAndRelease(KEYSWITCH_TOP_LEFT, LAYER1_KEY);
// Release the layer key as well. // Release the layer key as well.
state = releaseKeyswitchAndCycle(KEYSWITCH_LEFT_PALM); state = releaseKeyswitchAndRunCycle(KEYSWITCH_LEFT_PALM);
// Since the layer key release is internal to us, we shouldn't send a report. // Since the layer key release is internal to us, we shouldn't send a report.
assertNoReport(state); assertNoReport(state);
@ -149,23 +149,23 @@ TEST_F(LayerActivationOrder, ShiftingWithCaching) {
TEST_F(LayerActivationOrder, Ordering) { TEST_F(LayerActivationOrder, Ordering) {
// Pressing (KEYSWITCH_RIGHT_PALM) will switch to Layer 2 // Pressing (KEYSWITCH_RIGHT_PALM) will switch to Layer 2
auto state = pressKeyswitchAndCycle(KEYSWITCH_RIGHT_PALM); auto state = pressKeyswitchAndRunCycle(KEYSWITCH_RIGHT_PALM);
// Pressing (KEYSWITCH_TOP_LEFT) will activate a key on layer 2 // Pressing (KEYSWITCH_TOP_LEFT) will activate a key on layer 2
state = pressKeyswitchAndCycle(KEYSWITCH_TOP_LEFT); state = pressKeyswitchAndRunCycle(KEYSWITCH_TOP_LEFT);
assertSingleReportThatContains(state, LAYER2_KEY); assertSingleKeyboardReportContaining(state, LAYER2_KEY);
// Pressing (KEYSWITCH_LEFT_PALM) will activate Layer 1 // Pressing (KEYSWITCH_LEFT_PALM) will activate Layer 1
state = pressKeyswitchAndCycle(KEYSWITCH_LEFT_PALM); state = pressKeyswitchAndRunCycle(KEYSWITCH_LEFT_PALM);
// Pressing (KEYSWITCH_TOP_RIGHT) will activate the layer 1 key now, due to // Pressing (KEYSWITCH_TOP_RIGHT) will activate the layer 1 key now, due to
// activation ordering. // activation ordering.
state = pressKeyswitchAndCycle(KEYSWITCH_TOP_RIGHT); state = pressKeyswitchAndRunCycle(KEYSWITCH_TOP_RIGHT);
// We should have both the layer 1 and the layer 2 key active, because we're // We should have both the layer 1 and the layer 2 key active, because we're
// holding both. // holding both.
assertSingleReportThatContains(state, LAYER1_KEY); assertSingleKeyboardReportContaining(state, LAYER1_KEY);
assertSingleReportThatContains(state, LAYER2_KEY); assertSingleKeyboardReportContaining(state, LAYER2_KEY);
// Releaseing all held keys, we should get an empty report. // Releaseing all held keys, we should get an empty report.
releaseKeyswitch(KEYSWITCH_TOP_LEFT); releaseKeyswitch(KEYSWITCH_TOP_LEFT);
@ -183,11 +183,11 @@ TEST_F(LayerActivationOrder, Ordering) {
TEST_F(LayerActivationOrder, LayerZero) { TEST_F(LayerActivationOrder, LayerZero) {
// Pressing the rightmost of the left thumb keys should deactivate layer 0 // Pressing the rightmost of the left thumb keys should deactivate layer 0
auto state = pressKeyswitchAndCycle(KEYSWITCH_LEFT_THUMB_RIGHTMOST); auto state = pressKeyswitchAndRunCycle(KEYSWITCH_LEFT_THUMB_RIGHTMOST);
// Pressing KEYSWITCH_TOP_LEFT should fall back to activating the key on layer 0 // Pressing KEYSWITCH_TOP_LEFT should fall back to activating the key on layer 0
state = pressKeyswitchAndCycle(KEYSWITCH_TOP_LEFT); state = pressKeyswitchAndRunCycle(KEYSWITCH_TOP_LEFT);
assertSingleReportThatContains(state, LAYER0_KEY); assertSingleKeyboardReportContaining(state, LAYER0_KEY);
// Releasing all keys should generate a single empty report // Releasing all keys should generate a single empty report
releaseKeyswitch(KEYSWITCH_TOP_LEFT); releaseKeyswitch(KEYSWITCH_TOP_LEFT);

Loading…
Cancel
Save