inputflinger_tests: Put `FakeEventHub` in its own file
I would like to be able to put automated tests for the new
`TouchpadEventMapper` in their own file, rather than
InputReader_tests.cpp. To do this I'll need some of the test utilities
in their own files, too.
Aside from extracting the `FakeEventHub` definition into its own file
and putting method bodies into a .cpp file, I've made a few other minor
refactors:
* Use an early return to reduce nesting in `markSupportedKeyCodes`
* Use a ternary instead of an `if` in `getScanCodeState`
* Remove some single-use `device` variables and replace their use with a
call to `getDevice`
* Reordered the methods in the .h to make the grouping a little more
logical
* Tried to follow "Include What You Use" in the new files
Bug: 251196347
Test: atest inputflinger_tests
Change-Id: I55fe8267976d7aba58e1e4067b041d92dfd5347d
to fixup
Change-Id: I59df4e03db7e30cf7d17425ed38fe7f639dec836
diff --git a/services/inputflinger/tests/TestConstants.h b/services/inputflinger/tests/TestConstants.h
new file mode 100644
index 0000000..8dc9d71
--- /dev/null
+++ b/services/inputflinger/tests/TestConstants.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#pragma once
+
+namespace android {
+
+using std::chrono_literals::operator""ms;
+
+// Timeout for waiting for an expected event
+static constexpr std::chrono::duration WAIT_TIMEOUT = 100ms;
+
+// An arbitrary time value.
+static constexpr nsecs_t ARBITRARY_TIME = 1234;
+static constexpr nsecs_t READ_TIME = 4321;
+
+} // namespace android