Add TouchIntegrationTest tests

Base on InputReaderIntegrationTest which would test the threading
functionality. This would emulate the touch screen device and
send the raw events to verify if InputListener could really
receive the MotionEvent.

- Add tests for handling single touch and multi touch.
- Add test for handling MT_TOOL_PALM.

Bug: 117933934
Test: atest TouchIntegrationTest
Change-Id: I450c0159ac60d7da0471235407b3c537ab94fa6f
diff --git a/services/inputflinger/tests/UinputDevice.h b/services/inputflinger/tests/UinputDevice.h
index 57d9011..ec3cd9f 100644
--- a/services/inputflinger/tests/UinputDevice.h
+++ b/services/inputflinger/tests/UinputDevice.h
@@ -22,6 +22,8 @@
 #include <inttypes.h>
 #include <linux/uinput.h>
 #include <log/log.h>
+#include <ui/Point.h>
+#include <ui/Rect.h>
 
 #include <memory>
 
@@ -106,6 +108,40 @@
     UinputHomeKey();
 };
 
+// --- UinputTouchScreen ---
+// A touch screen device with specific size.
+class UinputTouchScreen : public UinputDevice {
+public:
+    static constexpr const char* DEVICE_NAME = "Test Touch Screen";
+    static const int32_t RAW_TOUCH_MIN = 0;
+    static const int32_t RAW_TOUCH_MAX = 31;
+    static const int32_t RAW_ID_MIN = 0;
+    static const int32_t RAW_ID_MAX = 9;
+    static const int32_t RAW_SLOT_MIN = 0;
+    static const int32_t RAW_SLOT_MAX = 9;
+    static const int32_t RAW_PRESSURE_MIN = 0;
+    static const int32_t RAW_PRESSURE_MAX = 255;
+
+    template <class D, class... Ts>
+    friend std::unique_ptr<D> createUinputDevice(Ts... args);
+
+    void sendSlot(int32_t slot);
+    void sendTrackingId(int32_t trackingId);
+    void sendDown(const Point& point);
+    void sendMove(const Point& point);
+    void sendUp();
+    void sendToolType(int32_t toolType);
+
+    const Point getCenterPoint();
+
+protected:
+    UinputTouchScreen(const Rect* size);
+
+private:
+    void configureDevice(int fd, uinput_user_dev* device) override;
+    const Rect mSize;
+};
+
 } // namespace android
 
 #endif // _UI_TEST_INPUT_UINPUT_INJECTOR_H