Refactor Nearby robolectric test.
This change rename the robolectric test to align with the unit test target
NearbyUnitTests. We should only pack robolectric test codes in the
NearbyRoboTests target, the app target is a fake app needed by
android_robolectric_test rule.
Test: atest NearbyRoboTests
Bug: 214015364
Change-Id: I59e016e9d63f1066e8eac1cfe728df0b54624a4e
diff --git a/nearby/tests/robotests/Android.bp b/nearby/tests/robotests/Android.bp
index 14b0815..83702f8 100644
--- a/nearby/tests/robotests/Android.bp
+++ b/nearby/tests/robotests/Android.bp
@@ -1,3 +1,17 @@
+// Copyright (C) 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.
+
//############################################
// Nearby Robolectric test target. #
//############################################
@@ -6,23 +20,18 @@
default_applicable_licenses: ["Android-Apache-2.0"],
}
-android_app {
- name: "FastPairTest",
-
+android_robolectric_test {
+ name: "NearbyRoboTests",
srcs: ["src/**/*.java"],
+ instrumentation_for: "NearbyFakeTestApp",
java_resource_dirs: ["config"],
- platform_apis: true,
- optimize: {
- enabled: false,
- },
-
libs: [
"android-support-annotations",
"services.core",
],
- static_libs: [
+ static_libs: [
"androidx.test.core",
"androidx.core_core",
"androidx.annotation_annotation",
@@ -39,12 +48,7 @@
"robolectric_android-all-stub",
"Robolectric_all-target",
],
-}
-android_robolectric_test {
- name: "FastPairRoboTests",
- srcs: ["src/**/*.java"],
- instrumentation_for: "FastPairTest",
test_options: {
// timeout in seconds.
timeout: 36000,
diff --git a/nearby/tests/robotests/fake_app/Android.bp b/nearby/tests/robotests/fake_app/Android.bp
new file mode 100644
index 0000000..707b38f
--- /dev/null
+++ b/nearby/tests/robotests/fake_app/Android.bp
@@ -0,0 +1,26 @@
+// Copyright (C) 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.
+
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+android_app {
+ name: "NearbyFakeTestApp",
+ srcs: ["*.java"],
+ platform_apis: true,
+ optimize: {
+ enabled: false,
+ },
+}
diff --git a/nearby/tests/robotests/fake_app/AndroidManifest.xml b/nearby/tests/robotests/fake_app/AndroidManifest.xml
new file mode 100644
index 0000000..fdb5390
--- /dev/null
+++ b/nearby/tests/robotests/fake_app/AndroidManifest.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 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.
+-->
+
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.server.nearby" />
diff --git a/nearby/tests/robotests/fake_app/Empty.java b/nearby/tests/robotests/fake_app/Empty.java
new file mode 100644
index 0000000..96619d5
--- /dev/null
+++ b/nearby/tests/robotests/fake_app/Empty.java
@@ -0,0 +1,16 @@
+/*
+ * Copyright (C) 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.
+ */
+