Loading ravenwood/TEST_MAPPING +4 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,10 @@ } ], "ravenwood-presubmit": [ { "name": "RavenwoodMinimumTest", "host": true }, { "name": "RavenwoodMockitoTest", "host": true Loading ravenwood/minimum-test/Android.bp 0 → 100644 +24 −0 Original line number Diff line number Diff line 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, } ravenwood/minimum-test/test/com/android/ravenwood/RavenwoodMinimumTest.java 0 → 100644 +45 −0 Original line number Diff line number Diff line /* * 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"); } } ravenwood/test-authors.md +16 −0 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 Loading Loading
ravenwood/TEST_MAPPING +4 −0 Original line number Diff line number Diff line Loading @@ -5,6 +5,10 @@ } ], "ravenwood-presubmit": [ { "name": "RavenwoodMinimumTest", "host": true }, { "name": "RavenwoodMockitoTest", "host": true Loading
ravenwood/minimum-test/Android.bp 0 → 100644 +24 −0 Original line number Diff line number Diff line 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, }
ravenwood/minimum-test/test/com/android/ravenwood/RavenwoodMinimumTest.java 0 → 100644 +45 −0 Original line number Diff line number Diff line /* * 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"); } }
ravenwood/test-authors.md +16 −0 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 Loading