Code layout cleanup

- Fwd declare where possible
- List .h first in the .cpp to verify proper includes
- Remove hacky -internal.h file and move testBitInRange to a new component

Change-Id: I442248c4b32738c6c2af250f45d4c8822c862e08
diff --git a/tests/input/evdev/Android.mk b/tests/input/evdev/Android.mk
index a79de34..1d8bf43 100644
--- a/tests/input/evdev/Android.mk
+++ b/tests/input/evdev/Android.mk
@@ -5,6 +5,7 @@
 LOCAL_C_INCLUDES += $(TOP)/external/gmock/include
 
 LOCAL_SRC_FILES:= \
+    BitUtils_test.cpp \
     InputDevice_test.cpp \
     InputHub_test.cpp \
     InputMocks.cpp \
diff --git a/tests/input/evdev/BitUtils_test.cpp b/tests/input/evdev/BitUtils_test.cpp
new file mode 100644
index 0000000..76fc8af
--- /dev/null
+++ b/tests/input/evdev/BitUtils_test.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
+#include "BitUtils.h"
+
+#include <gtest/gtest.h>
+
+namespace android {
+namespace tests {
+
+TEST(BitInRange, testInvalidRange) {
+    uint8_t arr[2] = { 0xff, 0xff };
+    EXPECT_FALSE(testBitInRange(arr, 0, 0));
+    EXPECT_FALSE(testBitInRange(arr, 1, 0));
+}
+
+TEST(BitInRange, testNoBits) {
+    uint8_t arr[1];
+    arr[0] = 0;
+    EXPECT_FALSE(testBitInRange(arr, 0, 8));
+}
+
+TEST(BitInRange, testOneBit) {
+    uint8_t arr[1];
+    for (int i = 0; i < 8; ++i) {
+        arr[0] = 1 << i;
+        EXPECT_TRUE(testBitInRange(arr, 0, 8));
+    }
+}
+
+TEST(BitInRange, testZeroStart) {
+    uint8_t arr[1] = { 0x10 };
+    for (int i = 0; i < 5; ++i) {
+        EXPECT_FALSE(testBitInRange(arr, 0, i));
+    }
+    for (int i = 5; i <= 8; ++i) {
+        EXPECT_TRUE(testBitInRange(arr, 0, i));
+    }
+}
+
+TEST(BitInRange, testByteBoundaryEnd) {
+    uint8_t arr[1] = { 0x10 };
+    for (int i = 0; i < 5; ++i) {
+        EXPECT_TRUE(testBitInRange(arr, i, 8));
+    }
+    for (int i = 5; i <= 8; ++i) {
+        EXPECT_FALSE(testBitInRange(arr, i, 8));
+    }
+}
+
+TEST(BitInRange, testMultiByteArray) {
+    // bits set: 11 and 16
+    uint8_t arr[3] = { 0x00, 0x08, 0x01 };
+    for (int start = 0; start < 24; ++start) {
+        for (int end = start + 1; end <= 24; ++end) {
+            if (start > 16 || end <= 11 || (start > 11 && end <= 16)) {
+                EXPECT_FALSE(testBitInRange(arr, start, end))
+                    << "range = (" << start << ", " << end << ")";
+            } else {
+                EXPECT_TRUE(testBitInRange(arr, start, end))
+                    << "range = (" << start << ", " << end << ")";
+            }
+        }
+    }
+}
+
+}  // namespace tests
+}  // namespace android
diff --git a/tests/input/evdev/InputDevice_test.cpp b/tests/input/evdev/InputDevice_test.cpp
index bed05b8..8d6aa68 100644
--- a/tests/input/evdev/InputDevice_test.cpp
+++ b/tests/input/evdev/InputDevice_test.cpp
@@ -14,8 +14,7 @@
  * limitations under the License.
  */
 
-#define LOG_TAG "InputHub_test"
-//#define LOG_NDEBUG 0
+#include "InputDevice.h"
 
 #include <memory>
 
@@ -25,7 +24,6 @@
 
 #include <utils/Timers.h>
 
-#include "InputDevice.h"
 #include "InputHub.h"
 #include "InputMocks.h"
 #include "MockInputHost.h"
diff --git a/tests/input/evdev/InputHub_test.cpp b/tests/input/evdev/InputHub_test.cpp
index 5864a95..64671ff 100644
--- a/tests/input/evdev/InputHub_test.cpp
+++ b/tests/input/evdev/InputHub_test.cpp
@@ -14,23 +14,19 @@
  * limitations under the License.
  */
 
-#define LOG_TAG "InputHub_test"
-//#define LOG_NDEBUG 0
-
-#include <linux/input.h>
+#include "InputHub.h"
 
 #include <chrono>
 #include <memory>
 #include <mutex>
 
+#include <linux/input.h>
+
 #include <gtest/gtest.h>
 
-#include <utils/Log.h>
 #include <utils/StopWatch.h>
 #include <utils/Timers.h>
 
-#include "InputHub.h"
-#include "InputHub-internal.h"
 #include "TestHelpers.h"
 
 // # of milliseconds to fudge stopwatch measurements
@@ -257,63 +253,5 @@
     EXPECT_TRUE(deviceCallbackFinished);
 }
 
-using internal::testBitInRange;
-
-TEST(BitInRange, testInvalidRange) {
-    uint8_t arr[2] = { 0xff, 0xff };
-    EXPECT_FALSE(testBitInRange(arr, 0, 0));
-    EXPECT_FALSE(testBitInRange(arr, 1, 0));
-}
-
-TEST(BitInRange, testNoBits) {
-    uint8_t arr[1];
-    arr[0] = 0;
-    EXPECT_FALSE(testBitInRange(arr, 0, 8));
-}
-
-TEST(BitInRange, testOneBit) {
-    uint8_t arr[1];
-    for (int i = 0; i < 8; ++i) {
-        arr[0] = 1 << i;
-        EXPECT_TRUE(testBitInRange(arr, 0, 8));
-    }
-}
-
-TEST(BitInRange, testZeroStart) {
-    uint8_t arr[1] = { 0x10 };
-    for (int i = 0; i < 5; ++i) {
-        EXPECT_FALSE(testBitInRange(arr, 0, i));
-    }
-    for (int i = 5; i <= 8; ++i) {
-        EXPECT_TRUE(testBitInRange(arr, 0, i));
-    }
-}
-
-TEST(BitInRange, testByteBoundaryEnd) {
-    uint8_t arr[1] = { 0x10 };
-    for (int i = 0; i < 5; ++i) {
-        EXPECT_TRUE(testBitInRange(arr, i, 8));
-    }
-    for (int i = 5; i <= 8; ++i) {
-        EXPECT_FALSE(testBitInRange(arr, i, 8));
-    }
-}
-
-TEST(BitInRange, testMultiByteArray) {
-    // bits set: 11 and 16
-    uint8_t arr[3] = { 0x00, 0x08, 0x01 };
-    for (int start = 0; start < 24; ++start) {
-        for (int end = start + 1; end <= 24; ++end) {
-            if (start > 16 || end <= 11 || (start > 11 && end <= 16)) {
-                EXPECT_FALSE(testBitInRange(arr, start, end))
-                    << "range = (" << start << ", " << end << ")";
-            } else {
-                EXPECT_TRUE(testBitInRange(arr, start, end))
-                    << "range = (" << start << ", " << end << ")";
-            }
-        }
-    }
-}
-
 }  // namespace tests
 }  // namespace android
diff --git a/tests/input/evdev/InputMocks.cpp b/tests/input/evdev/InputMocks.cpp
index f4a341a..bd09a3d 100644
--- a/tests/input/evdev/InputMocks.cpp
+++ b/tests/input/evdev/InputMocks.cpp
@@ -1,3 +1,19 @@
+/*
+ * Copyright (C) 2015 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.
+ */
+
 #include "InputMocks.h"
 
 namespace android {
diff --git a/tests/input/evdev/MockInputHost.h b/tests/input/evdev/MockInputHost.h
index a91f95c..aae0564 100644
--- a/tests/input/evdev/MockInputHost.h
+++ b/tests/input/evdev/MockInputHost.h
@@ -17,9 +17,10 @@
 #ifndef ANDROID_MOCK_INPUT_HOST_H_
 #define ANDROID_MOCK_INPUT_HOST_H_
 
+#include "InputHost.h"
+
 #include "gmock/gmock.h"
 
-#include "InputHost.h"
 
 namespace android {
 namespace tests {
diff --git a/tests/input/evdev/TestHelpers.cpp b/tests/input/evdev/TestHelpers.cpp
index 63b579e..9898a6f 100644
--- a/tests/input/evdev/TestHelpers.cpp
+++ b/tests/input/evdev/TestHelpers.cpp
@@ -17,6 +17,8 @@
 #define LOG_TAG "TestHelpers"
 #define LOG_NDEBUG 0
 
+#include "TestHelpers.h"
+
 #include <dirent.h>
 #include <fcntl.h>
 #include <stdlib.h>
@@ -26,8 +28,6 @@
 
 #include <utils/Log.h>
 
-#include "TestHelpers.h"
-
 namespace android {
 
 static const char kTmpDirTemplate[] = "/data/local/tmp/XXXXXX";