diff options
author | 2023-12-01 11:10:09 -0800 | |
---|---|---|
committer | 2023-12-01 12:09:15 -0800 | |
commit | 2d26539c4111de15fe0e27b07af984721bf8a295 (patch) | |
tree | 33159f74e77b6d45e93b2b4b072da694a1e8b87b | |
parent | 035e13c03fd1e04dc50d76da81251fb83fb73a16 (diff) |
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
-rw-r--r-- | ravenwood/TEST_MAPPING | 4 | ||||
-rw-r--r-- | ravenwood/minimum-test/Android.bp | 24 | ||||
-rw-r--r-- | ravenwood/minimum-test/test/com/android/ravenwood/RavenwoodMinimumTest.java | 45 | ||||
-rw-r--r-- | ravenwood/test-authors.md | 16 |
4 files changed, 89 insertions, 0 deletions
diff --git a/ravenwood/TEST_MAPPING b/ravenwood/TEST_MAPPING index 540b3a99e19d..031984829e77 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 000000000000..bf3583cebd2c --- /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 000000000000..085c18622885 --- /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 2b5bd9083a40..5adef534a2b2 100644 --- a/ravenwood/test-authors.md +++ b/ravenwood/test-authors.md @@ -31,6 +31,14 @@ android_ravenwood_test { * 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 @@ public class MyCodeTest { * 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 |