Skip to content
Snippets Groups Projects
Commit 2d26539c authored by Makoto Onuki's avatar Makoto Onuki
Browse files

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
parent 035e13c0
No related branches found
No related tags found
No related merge requests found
......@@ -5,6 +5,10 @@
}
],
"ravenwood-presubmit": [
{
"name": "RavenwoodMinimumTest",
"host": true
},
{
"name": "RavenwoodMockitoTest",
"host": true
......
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,
}
/*
* 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");
}
}
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment