feat(tests): rework tests in numerous ways (#3059)
This commit is contained in:
parent
3088823ffc
commit
764ce03520
19 changed files with 316 additions and 446 deletions
|
|
@ -3,38 +3,33 @@
|
|||
* @brief Test src/input.*.
|
||||
*/
|
||||
#include <src/input.h>
|
||||
#include <src/platform/common.h>
|
||||
|
||||
#include <tests/conftest.cpp>
|
||||
#include "../tests_common.h"
|
||||
|
||||
class MouseHIDTest: public virtual BaseTest, public PlatformInitBase, public ::testing::WithParamInterface<util::point_t> {
|
||||
protected:
|
||||
struct MouseHIDTest: PlatformTestSuite, testing::WithParamInterface<util::point_t> {
|
||||
void
|
||||
SetUp() override {
|
||||
BaseTest::SetUp();
|
||||
PlatformInitBase::SetUp();
|
||||
#ifdef _WIN32
|
||||
// TODO: Windows tests are failing, `get_mouse_loc` seems broken and `platf::abs_mouse` too
|
||||
// the alternative `platf::abs_mouse` method seem to work better during tests,
|
||||
// but I'm not sure about real work
|
||||
GTEST_SKIP_("MouseTest:: skipped for now. TODO Windows");
|
||||
GTEST_SKIP() << "TODO Windows";
|
||||
#elif __linux__
|
||||
// TODO: Inputtino waiting https://github.com/games-on-whales/inputtino/issues/6 is resolved.
|
||||
GTEST_SKIP_("MouseTest:: skipped for now. TODO Inputtino");
|
||||
GTEST_SKIP() << "TODO Inputtino";
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
TearDown() override {
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
PlatformInitBase::TearDown();
|
||||
BaseTest::TearDown();
|
||||
}
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
MouseInputs,
|
||||
MouseHIDTest,
|
||||
::testing::Values(
|
||||
testing::Values(
|
||||
util::point_t { 40, 40 },
|
||||
util::point_t { 70, 150 }));
|
||||
// todo: add tests for hitting screen edges
|
||||
|
|
@ -42,30 +37,30 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
TEST_P(MouseHIDTest, MoveInputTest) {
|
||||
util::point_t mouse_delta = GetParam();
|
||||
|
||||
std::cout << "MoveInputTest:: got param: " << mouse_delta << std::endl;
|
||||
BOOST_LOG(tests) << "MoveInputTest:: got param: " << mouse_delta;
|
||||
platf::input_t input = platf::input();
|
||||
std::cout << "MoveInputTest:: init input" << std::endl;
|
||||
BOOST_LOG(tests) << "MoveInputTest:: init input";
|
||||
|
||||
std::cout << "MoveInputTest:: get current mouse loc" << std::endl;
|
||||
BOOST_LOG(tests) << "MoveInputTest:: get current mouse loc";
|
||||
auto old_loc = platf::get_mouse_loc(input);
|
||||
std::cout << "MoveInputTest:: got current mouse loc: " << old_loc << std::endl;
|
||||
BOOST_LOG(tests) << "MoveInputTest:: got current mouse loc: " << old_loc;
|
||||
|
||||
std::cout << "MoveInputTest:: move: " << mouse_delta << std::endl;
|
||||
BOOST_LOG(tests) << "MoveInputTest:: move: " << mouse_delta;
|
||||
platf::move_mouse(input, mouse_delta.x, mouse_delta.y);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
std::cout << "MoveInputTest:: moved: " << mouse_delta << std::endl;
|
||||
BOOST_LOG(tests) << "MoveInputTest:: moved: " << mouse_delta;
|
||||
|
||||
std::cout << "MoveInputTest:: get updated mouse loc" << std::endl;
|
||||
BOOST_LOG(tests) << "MoveInputTest:: get updated mouse loc";
|
||||
auto new_loc = platf::get_mouse_loc(input);
|
||||
std::cout << "MoveInputTest:: got updated mouse loc: " << new_loc << std::endl;
|
||||
BOOST_LOG(tests) << "MoveInputTest:: got updated mouse loc: " << new_loc;
|
||||
|
||||
bool has_input_moved = old_loc.x != new_loc.x && old_loc.y != new_loc.y;
|
||||
|
||||
if (!has_input_moved) {
|
||||
std::cout << "MoveInputTest:: haven't moved" << std::endl;
|
||||
BOOST_LOG(tests) << "MoveInputTest:: haven't moved";
|
||||
}
|
||||
else {
|
||||
std::cout << "MoveInputTest:: moved" << std::endl;
|
||||
BOOST_LOG(tests) << "MoveInputTest:: moved";
|
||||
}
|
||||
|
||||
EXPECT_TRUE(has_input_moved);
|
||||
|
|
@ -77,14 +72,14 @@ TEST_P(MouseHIDTest, MoveInputTest) {
|
|||
|
||||
TEST_P(MouseHIDTest, AbsMoveInputTest) {
|
||||
util::point_t mouse_pos = GetParam();
|
||||
std::cout << "AbsMoveInputTest:: got param: " << mouse_pos << std::endl;
|
||||
BOOST_LOG(tests) << "AbsMoveInputTest:: got param: " << mouse_pos;
|
||||
|
||||
platf::input_t input = platf::input();
|
||||
std::cout << "AbsMoveInputTest:: init input" << std::endl;
|
||||
BOOST_LOG(tests) << "AbsMoveInputTest:: init input";
|
||||
|
||||
std::cout << "AbsMoveInputTest:: get current mouse loc" << std::endl;
|
||||
BOOST_LOG(tests) << "AbsMoveInputTest:: get current mouse loc";
|
||||
auto old_loc = platf::get_mouse_loc(input);
|
||||
std::cout << "AbsMoveInputTest:: got current mouse loc: " << old_loc << std::endl;
|
||||
BOOST_LOG(tests) << "AbsMoveInputTest:: got current mouse loc: " << old_loc;
|
||||
|
||||
#ifdef _WIN32
|
||||
platf::touch_port_t abs_port {
|
||||
|
|
@ -99,22 +94,22 @@ TEST_P(MouseHIDTest, AbsMoveInputTest) {
|
|||
#else
|
||||
platf::touch_port_t abs_port {};
|
||||
#endif
|
||||
std::cout << "AbsMoveInputTest:: move: " << mouse_pos << std::endl;
|
||||
BOOST_LOG(tests) << "AbsMoveInputTest:: move: " << mouse_pos;
|
||||
platf::abs_mouse(input, abs_port, mouse_pos.x, mouse_pos.y);
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
std::cout << "AbsMoveInputTest:: moved: " << mouse_pos << std::endl;
|
||||
BOOST_LOG(tests) << "AbsMoveInputTest:: moved: " << mouse_pos;
|
||||
|
||||
std::cout << "AbsMoveInputTest:: get updated mouse loc" << std::endl;
|
||||
BOOST_LOG(tests) << "AbsMoveInputTest:: get updated mouse loc";
|
||||
auto new_loc = platf::get_mouse_loc(input);
|
||||
std::cout << "AbsMoveInputTest:: got updated mouse loc: " << new_loc << std::endl;
|
||||
BOOST_LOG(tests) << "AbsMoveInputTest:: got updated mouse loc: " << new_loc;
|
||||
|
||||
bool has_input_moved = old_loc.x != new_loc.x || old_loc.y != new_loc.y;
|
||||
|
||||
if (!has_input_moved) {
|
||||
std::cout << "AbsMoveInputTest:: haven't moved" << std::endl;
|
||||
BOOST_LOG(tests) << "AbsMoveInputTest:: haven't moved";
|
||||
}
|
||||
else {
|
||||
std::cout << "AbsMoveInputTest:: moved" << std::endl;
|
||||
BOOST_LOG(tests) << "AbsMoveInputTest:: moved";
|
||||
}
|
||||
|
||||
EXPECT_TRUE(has_input_moved);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue