MCPcopy Create free account
hub / github.com/ClassicOldSong/Apollo / TEST_P

Function TEST_P

tests/unit/test_mouse.cpp:38–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

36// todo: add tests for hitting screen edges
37
38TEST_P(MouseHIDTest, MoveInputTest) {
39 util::point_t mouse_delta = GetParam();
40
41 BOOST_LOG(tests) << "MoveInputTest:: got param: " << mouse_delta;
42 platf::input_t input = platf::input();
43 BOOST_LOG(tests) << "MoveInputTest:: init input";
44
45 BOOST_LOG(tests) << "MoveInputTest:: get current mouse loc";
46 auto old_loc = platf::get_mouse_loc(input);
47 BOOST_LOG(tests) << "MoveInputTest:: got current mouse loc: " << old_loc;
48
49 BOOST_LOG(tests) << "MoveInputTest:: move: " << mouse_delta;
50 platf::move_mouse(input, mouse_delta.x, mouse_delta.y);
51 std::this_thread::sleep_for(std::chrono::milliseconds(200));
52 BOOST_LOG(tests) << "MoveInputTest:: moved: " << mouse_delta;
53
54 BOOST_LOG(tests) << "MoveInputTest:: get updated mouse loc";
55 auto new_loc = platf::get_mouse_loc(input);
56 BOOST_LOG(tests) << "MoveInputTest:: got updated mouse loc: " << new_loc;
57
58 bool has_input_moved = old_loc.x != new_loc.x && old_loc.y != new_loc.y;
59
60 if (!has_input_moved) {
61 BOOST_LOG(tests) << "MoveInputTest:: haven't moved";
62 } else {
63 BOOST_LOG(tests) << "MoveInputTest:: moved";
64 }
65
66 EXPECT_TRUE(has_input_moved);
67
68 // Verify we moved as much as we requested
69 EXPECT_EQ(new_loc.x - old_loc.x, mouse_delta.x);
70 EXPECT_EQ(new_loc.y - old_loc.y, mouse_delta.y);
71}
72
73TEST_P(MouseHIDTest, AbsMoveInputTest) {
74 util::point_t mouse_pos = GetParam();

Callers

nothing calls this directly

Calls 4

inputFunction · 0.50
get_mouse_locFunction · 0.50
move_mouseFunction · 0.50
abs_mouseFunction · 0.50

Tested by

no test coverage detected