From 67f722c9c8cb077b946dfb2b6a3b538e37f3aa8c Mon Sep 17 00:00:00 2001 From: Fred Sundvik Date: Sun, 2 Jul 2017 21:46:35 +0300 Subject: Configure vscode file associations, use hpp instead of h --- tests/basic/test_keypress.cpp | 2 +- tests/basic/test_macro.cpp | 2 +- tests/basic/test_tapping.cpp | 2 +- tests/test_common/keyboard_report_util.cpp | 2 +- tests/test_common/keyboard_report_util.h | 39 ------------------------ tests/test_common/keyboard_report_util.hpp | 39 ++++++++++++++++++++++++ tests/test_common/test_common.h | 24 --------------- tests/test_common/test_common.hpp | 24 +++++++++++++++ tests/test_common/test_driver.cpp | 2 +- tests/test_common/test_driver.h | 48 ------------------------------ tests/test_common/test_driver.hpp | 48 ++++++++++++++++++++++++++++++ tests/test_common/test_fixture.cpp | 4 +-- tests/test_common/test_fixture.h | 30 ------------------- tests/test_common/test_fixture.hpp | 30 +++++++++++++++++++ 14 files changed, 148 insertions(+), 148 deletions(-) delete mode 100644 tests/test_common/keyboard_report_util.h create mode 100644 tests/test_common/keyboard_report_util.hpp delete mode 100644 tests/test_common/test_common.h create mode 100644 tests/test_common/test_common.hpp delete mode 100644 tests/test_common/test_driver.h create mode 100644 tests/test_common/test_driver.hpp delete mode 100644 tests/test_common/test_fixture.h create mode 100644 tests/test_common/test_fixture.hpp (limited to 'tests') diff --git a/tests/basic/test_keypress.cpp b/tests/basic/test_keypress.cpp index 2323b7cb4..460c38385 100644 --- a/tests/basic/test_keypress.cpp +++ b/tests/basic/test_keypress.cpp @@ -14,7 +14,7 @@ * along with this program. If not, see . */ -#include "test_common.h" +#include "test_common.hpp" using testing::_; using testing::Return; diff --git a/tests/basic/test_macro.cpp b/tests/basic/test_macro.cpp index f1990bf6f..56ee5ad3e 100644 --- a/tests/basic/test_macro.cpp +++ b/tests/basic/test_macro.cpp @@ -14,7 +14,7 @@ * along with this program. If not, see . */ -#include "test_common.h" +#include "test_common.hpp" #include "time.h" using testing::InSequence; diff --git a/tests/basic/test_tapping.cpp b/tests/basic/test_tapping.cpp index c158e1718..75a1bcafb 100644 --- a/tests/basic/test_tapping.cpp +++ b/tests/basic/test_tapping.cpp @@ -14,7 +14,7 @@ * along with this program. If not, see . */ -#include "test_common.h" +#include "test_common.hpp" #include "action_tapping.h" using testing::_; diff --git a/tests/test_common/keyboard_report_util.cpp b/tests/test_common/keyboard_report_util.cpp index aa096e416..bf728b9a2 100644 --- a/tests/test_common/keyboard_report_util.cpp +++ b/tests/test_common/keyboard_report_util.cpp @@ -14,7 +14,7 @@ * along with this program. If not, see . */ - #include "keyboard_report_util.h" + #include "keyboard_report_util.hpp" #include #include using namespace testing; diff --git a/tests/test_common/keyboard_report_util.h b/tests/test_common/keyboard_report_util.h deleted file mode 100644 index 48543c205..000000000 --- a/tests/test_common/keyboard_report_util.h +++ /dev/null @@ -1,39 +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 . - */ - -#pragma once -#include "report.h" -#include -#include "gmock/gmock.h" - -bool operator==(const report_keyboard_t& lhs, const report_keyboard_t& rhs); -std::ostream& operator<<(std::ostream& stream, const report_keyboard_t& value); - -class KeyboardReportMatcher : public testing::MatcherInterface { - public: - KeyboardReportMatcher(const std::vector& keys); - virtual bool MatchAndExplain(report_keyboard_t& report, testing::MatchResultListener* listener) const override; - virtual void DescribeTo(::std::ostream* os) const override; - virtual void DescribeNegationTo(::std::ostream* os) const override; -private: - report_keyboard_t m_report; -}; - - -template -inline testing::Matcher KeyboardReport(Ts... keys) { - return testing::MakeMatcher(new KeyboardReportMatcher(std::vector({keys...}))); -} \ No newline at end of file diff --git a/tests/test_common/keyboard_report_util.hpp b/tests/test_common/keyboard_report_util.hpp new file mode 100644 index 000000000..48543c205 --- /dev/null +++ b/tests/test_common/keyboard_report_util.hpp @@ -0,0 +1,39 @@ +/* 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 . + */ + +#pragma once +#include "report.h" +#include +#include "gmock/gmock.h" + +bool operator==(const report_keyboard_t& lhs, const report_keyboard_t& rhs); +std::ostream& operator<<(std::ostream& stream, const report_keyboard_t& value); + +class KeyboardReportMatcher : public testing::MatcherInterface { + public: + KeyboardReportMatcher(const std::vector& keys); + virtual bool MatchAndExplain(report_keyboard_t& report, testing::MatchResultListener* listener) const override; + virtual void DescribeTo(::std::ostream* os) const override; + virtual void DescribeNegationTo(::std::ostream* os) const override; +private: + report_keyboard_t m_report; +}; + + +template +inline testing::Matcher KeyboardReport(Ts... keys) { + return testing::MakeMatcher(new KeyboardReportMatcher(std::vector({keys...}))); +} \ No newline at end of file diff --git a/tests/test_common/test_common.h b/tests/test_common/test_common.h deleted file mode 100644 index 38eb0ed93..000000000 --- a/tests/test_common/test_common.h +++ /dev/null @@ -1,24 +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 . - */ - -#include "gtest/gtest.h" -#include "gmock/gmock.h" - -#include "quantum.h" -#include "test_driver.h" -#include "test_matrix.h" -#include "keyboard_report_util.h" -#include "test_fixture.h" \ No newline at end of file diff --git a/tests/test_common/test_common.hpp b/tests/test_common/test_common.hpp new file mode 100644 index 000000000..239844633 --- /dev/null +++ b/tests/test_common/test_common.hpp @@ -0,0 +1,24 @@ +/* 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 . + */ + +#include "gtest/gtest.h" +#include "gmock/gmock.h" + +#include "quantum.h" +#include "test_driver.hpp" +#include "test_matrix.h" +#include "keyboard_report_util.hpp" +#include "test_fixture.hpp" \ No newline at end of file diff --git a/tests/test_common/test_driver.cpp b/tests/test_common/test_driver.cpp index feb80563a..511309969 100644 --- a/tests/test_common/test_driver.cpp +++ b/tests/test_common/test_driver.cpp @@ -14,7 +14,7 @@ * along with this program. If not, see . */ -#include "test_driver.h" +#include "test_driver.hpp" TestDriver* TestDriver::m_this = nullptr; diff --git a/tests/test_common/test_driver.h b/tests/test_common/test_driver.h deleted file mode 100644 index 0123fd539..000000000 --- a/tests/test_common/test_driver.h +++ /dev/null @@ -1,48 +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 . - */ - -#ifndef TESTS_TEST_COMMON_TEST_DRIVER_H_ -#define TESTS_TEST_COMMON_TEST_DRIVER_H_ - -#include "gmock/gmock.h" -#include -#include "host.h" -#include "keyboard_report_util.h" - - -class TestDriver { -public: - TestDriver(); - ~TestDriver(); - void set_leds(uint8_t leds) { m_leds = leds; } - - MOCK_METHOD1(send_keyboard_mock, void (report_keyboard_t&)); - MOCK_METHOD1(send_mouse_mock, void (report_mouse_t&)); - MOCK_METHOD1(send_system_mock, void (uint16_t)); - MOCK_METHOD1(send_consumer_mock, void (uint16_t)); -private: - static uint8_t keyboard_leds(void); - static void send_keyboard(report_keyboard_t *report); - static void send_mouse(report_mouse_t* report); - static void send_system(uint16_t data); - static void send_consumer(uint16_t data); - host_driver_t m_driver; - uint8_t m_leds = 0; - static TestDriver* m_this; -}; - - -#endif /* TESTS_TEST_COMMON_TEST_DRIVER_H_ */ diff --git a/tests/test_common/test_driver.hpp b/tests/test_common/test_driver.hpp new file mode 100644 index 000000000..c3ae17b1a --- /dev/null +++ b/tests/test_common/test_driver.hpp @@ -0,0 +1,48 @@ +/* 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 . + */ + +#ifndef TESTS_TEST_COMMON_TEST_DRIVER_H_ +#define TESTS_TEST_COMMON_TEST_DRIVER_H_ + +#include "gmock/gmock.h" +#include +#include "host.h" +#include "keyboard_report_util.hpp" + + +class TestDriver { +public: + TestDriver(); + ~TestDriver(); + void set_leds(uint8_t leds) { m_leds = leds; } + + MOCK_METHOD1(send_keyboard_mock, void (report_keyboard_t&)); + MOCK_METHOD1(send_mouse_mock, void (report_mouse_t&)); + MOCK_METHOD1(send_system_mock, void (uint16_t)); + MOCK_METHOD1(send_consumer_mock, void (uint16_t)); +private: + static uint8_t keyboard_leds(void); + static void send_keyboard(report_keyboard_t *report); + static void send_mouse(report_mouse_t* report); + static void send_system(uint16_t data); + static void send_consumer(uint16_t data); + host_driver_t m_driver; + uint8_t m_leds = 0; + static TestDriver* m_this; +}; + + +#endif /* TESTS_TEST_COMMON_TEST_DRIVER_H_ */ diff --git a/tests/test_common/test_fixture.cpp b/tests/test_common/test_fixture.cpp index 5ca5247db..df57338df 100644 --- a/tests/test_common/test_fixture.cpp +++ b/tests/test_common/test_fixture.cpp @@ -1,6 +1,6 @@ -#include "test_fixture.h" +#include "test_fixture.hpp" #include "gmock/gmock.h" -#include "test_driver.h" +#include "test_driver.hpp" #include "test_matrix.h" #include "keyboard.h" #include "action.h" diff --git a/tests/test_common/test_fixture.h b/tests/test_common/test_fixture.h deleted file mode 100644 index 4146b682b..000000000 --- a/tests/test_common/test_fixture.h +++ /dev/null @@ -1,30 +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 . - */ - - #pragma once - -#include "gtest/gtest.h" - -class TestFixture : public testing::Test { -public: - TestFixture(); - ~TestFixture(); - static void SetUpTestCase(); - static void TearDownTestCase(); - - void run_one_scan_loop(); - void idle_for(uint ms); -}; \ No newline at end of file diff --git a/tests/test_common/test_fixture.hpp b/tests/test_common/test_fixture.hpp new file mode 100644 index 000000000..4146b682b --- /dev/null +++ b/tests/test_common/test_fixture.hpp @@ -0,0 +1,30 @@ +/* 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 . + */ + + #pragma once + +#include "gtest/gtest.h" + +class TestFixture : public testing::Test { +public: + TestFixture(); + ~TestFixture(); + static void SetUpTestCase(); + static void TearDownTestCase(); + + void run_one_scan_loop(); + void idle_for(uint ms); +}; \ No newline at end of file -- cgit v1.2.3-24-g4f1b