You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Kaleidoscope/testing/hello-simulator/hello-simulator_test.cpp

137 lines
3.8 KiB

/* -*- mode: c++ -*-
* Copyright (C) 2020 Eric Paniagua (epaniagua@google.com)
*
* 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, version 3.
*
* 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/>.
*/
#ifdef KALEIDOSCOPE_VIRTUAL_BUILD
// The Kaleidoscope core
#include "Kaleidoscope.h"
// Support for storing the keymap in EEPROM
#include "Kaleidoscope-EEPROM-Settings.h"
#include "Kaleidoscope-EEPROM-Keymap.h"
// Support for communicating with the host via a simple Serial protocol
#include "Kaleidoscope-FocusSerial.h"
// Support for keys that move the mouse
#include "Kaleidoscope-MouseKeys.h"
// Support for macros
#include "Kaleidoscope-Macros.h"
// Support for controlling the keyboard's LEDs
#include "Kaleidoscope-LEDControl.h"
// Support for "Numpad" mode, which is mostly just the Numpad specific LED mode
#include "Kaleidoscope-NumPad.h"
// Support for the "Boot greeting" effect, which pulses the 'LED' button for 10s
// when the keyboard is connected to a computer (or that computer is powered on)
#include "Kaleidoscope-LEDEffect-BootGreeting.h"
// Support for LED modes that set all LEDs to a single color
#include "Kaleidoscope-LEDEffect-SolidColor.h"
// Support for an LED mode that makes all the LEDs 'breathe'
#include "Kaleidoscope-LEDEffect-Breathe.h"
// Support for an LED mode that makes a red pixel chase a blue pixel across the keyboard
#include "Kaleidoscope-LEDEffect-Chase.h"
// Support for LED modes that pulse the keyboard's LED in a rainbow pattern
#include "Kaleidoscope-LEDEffect-Rainbow.h"
// Support for an LED mode that lights up the keys as you press them
#include "Kaleidoscope-LED-Stalker.h"
// Support for an LED mode that prints the keys you press in letters 4px high
#include "Kaleidoscope-LED-AlphaSquare.h"
// Support for an LED mode that lets one configure per-layer color maps
#include "Kaleidoscope-Colormap.h"
// Support for Keyboardio's internal keyboard testing mode
#include "Kaleidoscope-HardwareTestMode.h"
// Support for host power management (suspend & wakeup)
#include "Kaleidoscope-HostPowerManagement.h"
// Support for magic combos (key chords that trigger an action)
#include "Kaleidoscope-MagicCombo.h"
// Support for USB quirks, like changing the key state report protocol
#include "Kaleidoscope-USB-Quirks.h"
#include "Kaleidoscope-Simulator.h"
#undef min
#undef max
#undef T
#undef U
#undef TEST
#include "gtest/gtest.h"
void executeTestFunction() {
setup(); /* setup Kaleidoscope */
testing::InitGoogleTest();
RUN_ALL_TESTS();
}
namespace kaleidoscope {
namespace simulator {
namespace {
using namespace actions;
using namespace interface;
using namespace interface::actions;
class SimulatorTest : public ::testing::Test {
protected:
void SetUp() {
sim_ = &Simulator::getInstance();
}
Simulator* sim_;
};
class KeyboardReports : public SimulatorTest {};
TEST_F(KeyboardReports, ActiveKeycodesAreAccurate) {
// Assert that the next cycle generates exactly one keyboard report.
//
sim_->cycleActionsQueue().queue(AssertCycleGeneratesNReports<KeyboardReport_> {1});
sim_->tapKey(2, 1); // A
sim_->cycleExpectReports(AssertKeycodesActive{Key_A});
sim_->cycleExpectReports(AssertReportEmpty{});
}
TEST(Test, ThatPasses) {
EXPECT_TRUE(true);
}
TEST(Test, ThatFails) {
EXPECT_TRUE(false);
}
} // namespace
} // namespace simulator
} // namespace kaleidoscope
#endif // KALEIDOSCOPE_VIRTUAL_BUILD