Add ravenwood minimum test
This helps examine what ravenwood test jars contain.
Currently it's rather large:
$ ll $ANDROID_HOST_OUT/testcases/RavenwoodMinimumTest/RavenwoodMinimumTest.jar
-rw-r--r-- 1 omakoto primarygroup 2705929 Dec 1 11:06 /android/main-without-vendor/out/host/linux-x86/testcases/RavenwoodMinimumTest/RavenwoodMinimumTest.jar
$ jar tvf $ANDROID_HOST_OUT/testcases/RavenwoodMinimumTest/RavenwoodMinimumTest.jar | wc -l
2000
Seems like we're pulling in even kotlin runtime classes from the
androidx dependencies?
We can move them to ravenwood-runtime.
Bug: 292141694
Test: atest --host RavenwoodMinimumTest
Change-Id: Ifb939c9914ef7fa6610adb697d05369d16c76d29
diff --git a/ravenwood/TEST_MAPPING b/ravenwood/TEST_MAPPING
index 540b3a9..0319848 100644
--- a/ravenwood/TEST_MAPPING
+++ b/ravenwood/TEST_MAPPING
@@ -6,6 +6,10 @@
],
"ravenwood-presubmit": [
{
+ "name": "RavenwoodMinimumTest",
+ "host": true
+ },
+ {
"name": "RavenwoodMockitoTest",
"host": true
},
diff --git a/ravenwood/minimum-test/Android.bp b/ravenwood/minimum-test/Android.bp
new file mode 100644
index 0000000..bf3583c
--- /dev/null
+++ b/ravenwood/minimum-test/Android.bp
@@ -0,0 +1,24 @@
+package {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "frameworks_base_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["frameworks_base_license"],
+}
+
+// Minimum ravenwood test according to test-authors.md.
+android_ravenwood_test {
+ name: "RavenwoodMinimumTest",
+
+ static_libs: [
+ "androidx.annotation_annotation",
+ "androidx.test.rules",
+ ],
+
+ srcs: [
+ "test/**/*.java",
+ ],
+ sdk_version: "test_current",
+ auto_gen_config: true,
+}
diff --git a/ravenwood/minimum-test/test/com/android/ravenwood/RavenwoodMinimumTest.java b/ravenwood/minimum-test/test/com/android/ravenwood/RavenwoodMinimumTest.java
new file mode 100644
index 0000000..085c186
--- /dev/null
+++ b/ravenwood/minimum-test/test/com/android/ravenwood/RavenwoodMinimumTest.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2023 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 com.android.ravenwood;
+
+import android.platform.test.annotations.IgnoreUnderRavenwood;
+import android.platform.test.ravenwood.RavenwoodRule;
+
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Assert;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class RavenwoodMinimumTest {
+ @Rule
+ public RavenwoodRule mRavenwood = new RavenwoodRule.Builder()
+ .setProcessApp()
+ .build();
+
+ @Test
+ public void testSimple() {
+ Assert.assertTrue(android.os.Process.isApplicationUid(android.os.Process.myUid()));
+ }
+
+ @Test
+ @IgnoreUnderRavenwood
+ public void testIgnored() {
+ throw new RuntimeException("Shouldn't be executed under ravenwood");
+ }
+}
diff --git a/ravenwood/test-authors.md b/ravenwood/test-authors.md
index 2b5bd908..5adef53 100644
--- a/ravenwood/test-authors.md
+++ b/ravenwood/test-authors.md
@@ -31,6 +31,14 @@
* Write your unit test just like you would for an Android device:
```
+import android.platform.test.annotations.IgnoreUnderRavenwood;
+import android.platform.test.ravenwood.RavenwoodRule;
+
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
@RunWith(AndroidJUnit4.class)
public class MyCodeTest {
@Test
@@ -43,6 +51,14 @@
* APIs available under Ravenwood are stateless by default. If your test requires explicit states (such as defining the UID you’re running under, or requiring a main `Looper` thread), add a `RavenwoodRule` to declare that:
```
+import android.platform.test.annotations.IgnoreUnderRavenwood;
+import android.platform.test.ravenwood.RavenwoodRule;
+
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
@RunWith(AndroidJUnit4.class)
public class MyCodeTest {
@Rule