1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package android.platform.test.ravenwood; 17 18 import android.util.Log; 19 20 import org.junit.rules.TestRule; 21 import org.junit.runner.Description; 22 import org.junit.runner.Runner; 23 import org.junit.runner.notification.RunNotifier; 24 import org.junit.runners.model.Statement; 25 import org.junit.runners.model.TestClass; 26 27 /** 28 * A simple pass-through runner that just delegates to the inner runner without doing 29 * anything special (no hooks, etc.). 30 * 31 * This is only used when a real device-side test has Ravenizer enabled. 32 */ 33 public class RavenwoodAwareTestRunner extends RavenwoodAwareTestRunnerBase { 34 private static class NopRule implements TestRule { 35 @Override apply(Statement base, Description description)36 public Statement apply(Statement base, Description description) { 37 return base; 38 } 39 } 40 41 public static final TestRule sImplicitClassOuterRule = new NopRule(); 42 public static final TestRule sImplicitClassInnerRule = sImplicitClassOuterRule; 43 public static final TestRule sImplicitInstOuterRule = sImplicitClassOuterRule; 44 public static final TestRule sImplicitInstInnerRule = sImplicitClassOuterRule; 45 46 private final Runner mRealRunner; 47 RavenwoodAwareTestRunner(Class<?> clazz)48 public RavenwoodAwareTestRunner(Class<?> clazz) { 49 Log.v(TAG, "RavenwoodAwareTestRunner starting for " + clazz.getCanonicalName()); 50 mRealRunner = instantiateRealRunner(new TestClass(clazz)); 51 } 52 53 @Override getRealRunner()54 Runner getRealRunner() { 55 return mRealRunner; 56 } 57 58 @Override run(RunNotifier notifier)59 public void run(RunNotifier notifier) { 60 mRealRunner.run(notifier); 61 } 62 onRavenwoodRuleEnter(Description description, RavenwoodRule rule)63 static void onRavenwoodRuleEnter(Description description, RavenwoodRule rule) { 64 } 65 onRavenwoodRuleExit(Description description, RavenwoodRule rule)66 static void onRavenwoodRuleExit(Description description, RavenwoodRule rule) { 67 } 68 } 69