diff options
author | 2024-09-26 22:59:40 +0000 | |
---|---|---|
committer | 2024-09-26 22:59:40 +0000 | |
commit | 983461633b96db0bc58205a657edeffad3ce4080 (patch) | |
tree | 8df76979756f92a675ea35ac852917a2369d152f /ravenwood/junit-stub-src | |
parent | 6f7665370b368b3f4164cdce501ae224b3351c9b (diff) |
Cherry-pick Ravenwood "core" code
- Copied f/b/r and f/b/t/h
- Ported files under f/b/core, only what needed to for run-ravenwood-tests.sh to pass
- Local changes because of missing resoucres support
- Added @DisabledOnRavenwood(reason="AOSP is missing resources support") to tests under f/b/r that depends on resources
bivalentinst and servicestest
- Added try-catch around ResourcesManager.setInstance()
Flag: EXEMPT host test change only
Bug: 292141694
Test: $ANDROID_BUILD_TOP/frameworks/base/ravenwood/scripts/run-ravenwood-tests.sh
Merged-in: I8a9b8374be3ae052ba4f152eb43af20d0871597f
Change-Id: Iefd574dbded8c4ab2e244c4918c26641364a3432
Diffstat (limited to 'ravenwood/junit-stub-src')
4 files changed, 145 insertions, 42 deletions
diff --git a/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerHook.java b/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerHook.java new file mode 100644 index 000000000000..aa8c29936082 --- /dev/null +++ b/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerHook.java @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2024 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 android.platform.test.ravenwood; + +import android.platform.test.ravenwood.RavenwoodAwareTestRunner.Order; +import android.platform.test.ravenwood.RavenwoodAwareTestRunner.Scope; + +import org.junit.runner.Description; +import org.junit.runners.model.TestClass; + +/** + * Provide hook points created by {@link RavenwoodAwareTestRunner}. This is a version + * that's used on a device side test. + * + * All methods are no-op in real device tests. + * + * TODO: Use some kind of factory to provide different implementation for the device test + * and the ravenwood test. + */ +public class RavenwoodAwareTestRunnerHook { + private RavenwoodAwareTestRunnerHook() { + } + + /** + * Called before any code starts. Internally it will only initialize the environment once. + */ + public static void performGlobalInitialization() { + } + + /** + * Called when a runner starts, before the inner runner gets a chance to run. + */ + public static void onRunnerInitializing(RavenwoodAwareTestRunner runner, TestClass testClass) { + } + + /** + * Called when a whole test class is skipped. + */ + public static void onClassSkipped(Description description) { + } + + /** + * Called before the inner runner starts. + */ + public static void onBeforeInnerRunnerStart( + RavenwoodAwareTestRunner runner, Description description) throws Throwable { + } + + /** + * Called after the inner runner finished. + */ + public static void onAfterInnerRunnerFinished( + RavenwoodAwareTestRunner runner, Description description) throws Throwable { + } + + /** + * Called before a test / class. + * + * Return false if it should be skipped. + */ + public static boolean onBefore(RavenwoodAwareTestRunner runner, Description description, + Scope scope, Order order) throws Throwable { + return true; + } + + public static void onRavenwoodRuleEnter(RavenwoodAwareTestRunner runner, + Description description, RavenwoodRule rule) throws Throwable { + } + + public static void onRavenwoodRuleExit(RavenwoodAwareTestRunner runner, + Description description, RavenwoodRule rule) throws Throwable { + } + + + /** + * Called after a test / class. + * + * Return false if the exception should be ignored. + */ + public static boolean onAfter(RavenwoodAwareTestRunner runner, Description description, + Scope scope, Order order, Throwable th) { + return true; + } + + public static boolean shouldRunClassOnRavenwood(Class<?> clazz) { + return true; + } +} diff --git a/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodConfigState.java b/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodConfigState.java new file mode 100644 index 000000000000..43a28ba72ec9 --- /dev/null +++ b/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodConfigState.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2024 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 android.platform.test.ravenwood; + +/** Stub class. The actual implementaetion is in junit-impl-src. */ +public class RavenwoodConfigState { + public RavenwoodConfigState(RavenwoodConfig config) { + } +} diff --git a/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java b/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java deleted file mode 100644 index 483b98a96034..000000000000 --- a/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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 android.platform.test.ravenwood; - -import org.junit.runner.Description; -import org.junit.runners.model.Statement; - -public class RavenwoodRuleImpl { - public static void init(RavenwoodRule rule) { - // No-op when running on a real device - } - - public static void reset(RavenwoodRule rule) { - // No-op when running on a real device - } - - public static void logTestRunner(String label, Description description) { - // No-op when running on a real device - } - - public static void validate(Statement base, Description description, - boolean enableOptionalValidation) { - } - - public static long realCurrentTimeMillis() { - return System.currentTimeMillis(); - } -} diff --git a/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodRunnerState.java b/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodRunnerState.java new file mode 100644 index 000000000000..83cbc5265d8f --- /dev/null +++ b/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodRunnerState.java @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2024 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 android.platform.test.ravenwood; + +/** Stub class. The actual implementaetion is in junit-impl-src. */ +public class RavenwoodRunnerState { + public RavenwoodRunnerState(RavenwoodAwareTestRunner runner) { + } +} |