CursorInputMapper: move unit tests to InputMapperUnitTest
This puts most of CursorInputMapper's unit tests in one place
(CursorInputMapper_test.cpp) and under one input mapper testing system,
which will hopefully simplify future additions to the tests. The only
CursorInputMapper tests remaining to be migrated are those which rely on
setting an associated viewport, which I'm saving for a follow-up CL
since they'll need the introduction of a fake InputDeviceContext.
Also make a few smaller clean-ups:
* underscores have been removed from test names, as they can cause
problems in gTest;
* assertions have been moved to the newer style using matchers,
improving conciseness and readability;
* tests for the creation of NotifyKeyArgs for certain mouse buttons have
been parameterized.
Bug: 283812079
Test: atest inputflinger_tests
Change-Id: I0f0307dc57edcc62d0ce24b15bf0d9e8b8b915c6
diff --git a/services/inputflinger/tests/InputMapperTest.h b/services/inputflinger/tests/InputMapperTest.h
index 995909b..e176a65 100644
--- a/services/inputflinger/tests/InputMapperTest.h
+++ b/services/inputflinger/tests/InputMapperTest.h
@@ -32,6 +32,7 @@
#include "InterfaceMocks.h"
#include "TestConstants.h"
#include "TestInputListener.h"
+#include "input/PropertyMap.h"
namespace android {
@@ -41,7 +42,8 @@
static constexpr int32_t DEVICE_ID = END_RESERVED_ID + 1000;
static constexpr float INITIAL_CURSOR_X = 400;
static constexpr float INITIAL_CURSOR_Y = 240;
- virtual void SetUp() override;
+ virtual void SetUp() override { SetUpWithBus(0); }
+ virtual void SetUpWithBus(int bus);
/**
* Initializes mDevice and mDeviceContext. When this happens, mDevice takes a copy of
@@ -72,6 +74,7 @@
InputReaderConfiguration mReaderConfiguration;
// The mapper should be created by the subclasses.
std::unique_ptr<InputMapper> mMapper;
+ PropertyMap mPropertyMap;
};
/**
@@ -138,13 +141,13 @@
void resetMapper(InputMapper& mapper, nsecs_t when);
std::list<NotifyArgs> handleTimeout(InputMapper& mapper, nsecs_t when);
-
- static void assertMotionRange(const InputDeviceInfo& info, int32_t axis, uint32_t source,
- float min, float max, float flat, float fuzz);
- static void assertPointerCoords(const PointerCoords& coords, float x, float y, float pressure,
- float size, float touchMajor, float touchMinor, float toolMajor,
- float toolMinor, float orientation, float distance,
- float scaledAxisEpsilon = 1.f);
};
+void assertMotionRange(const InputDeviceInfo& info, int32_t axis, uint32_t source, float min,
+ float max, float flat, float fuzz);
+
+void assertPointerCoords(const PointerCoords& coords, float x, float y, float pressure, float size,
+ float touchMajor, float touchMinor, float toolMajor, float toolMinor,
+ float orientation, float distance, float scaledAxisEpsilon = 1.f);
+
} // namespace android