Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Side by Side Diff: base/test/android/javatests/src/org/chromium/base/test/BaseJUnit4ClassRunner.java

Issue 2933623002: Create AwJUnit4ClassRunner AwActivityTestRule and convert AwContentsTest (Closed)
Patch Set: address bo's comments Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.base.test; 5 package org.chromium.base.test;
6 6
7 import static org.chromium.base.test.BaseChromiumAndroidJUnitRunner.toListTests;
8
7 import android.content.Context; 9 import android.content.Context;
8 import android.support.test.InstrumentationRegistry; 10 import android.support.test.InstrumentationRegistry;
9 import android.support.test.internal.runner.junit4.AndroidJUnit4ClassRunner; 11 import android.support.test.internal.runner.junit4.AndroidJUnit4ClassRunner;
10 import android.support.test.internal.util.AndroidRunnerParams; 12 import android.support.test.internal.util.AndroidRunnerParams;
11 13
14 import org.junit.runner.Description;
12 import org.junit.runner.notification.RunNotifier; 15 import org.junit.runner.notification.RunNotifier;
13 import org.junit.runners.model.FrameworkMethod; 16 import org.junit.runners.model.FrameworkMethod;
14 import org.junit.runners.model.InitializationError; 17 import org.junit.runners.model.InitializationError;
15 import org.junit.runners.model.Statement; 18 import org.junit.runners.model.Statement;
16 19
17 import org.chromium.base.CollectionUtil; 20 import org.chromium.base.CollectionUtil;
18 import org.chromium.base.test.BaseTestResult.PreTestHook; 21 import org.chromium.base.test.BaseTestResult.PreTestHook;
19 import org.chromium.base.test.util.DisableIfSkipCheck; 22 import org.chromium.base.test.util.DisableIfSkipCheck;
20 import org.chromium.base.test.util.MinAndroidSdkLevelSkipCheck; 23 import org.chromium.base.test.util.MinAndroidSdkLevelSkipCheck;
21 import org.chromium.base.test.util.RestrictionSkipCheck; 24 import org.chromium.base.test.util.RestrictionSkipCheck;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 125 }
123 126
124 /** 127 /**
125 * Evaluate whether a FrameworkMethod is ignored based on {@code SkipCheck}s . 128 * Evaluate whether a FrameworkMethod is ignored based on {@code SkipCheck}s .
126 */ 129 */
127 @Override 130 @Override
128 protected boolean isIgnored(FrameworkMethod method) { 131 protected boolean isIgnored(FrameworkMethod method) {
129 return super.isIgnored(method) || shouldSkip(method); 132 return super.isIgnored(method) || shouldSkip(method);
130 } 133 }
131 134
135 /**
136 * Run test with or without execution based on bundle arguments.
137 */
138 @Override
139 public void run(RunNotifier notifier) {
140 if (toListTests(InstrumentationRegistry.getArguments())) {
141 for (Description child : getDescription().getChildren()) {
142 notifier.fireTestStarted(child);
143 notifier.fireTestFinished(child);
144 }
145 } else {
146 super.run(notifier);
147 }
148 }
149
132 @Override 150 @Override
133 protected void runChild(FrameworkMethod method, RunNotifier notifier) { 151 protected void runChild(FrameworkMethod method, RunNotifier notifier) {
134 runPreTestHooks(method); 152 runPreTestHooks(method);
135 super.runChild(method, notifier); 153 super.runChild(method, notifier);
136 } 154 }
137 155
138 /** 156 /**
139 * Loop through all the {@code PreTestHook}s to run them 157 * Loop through all the {@code PreTestHook}s to run them
140 */ 158 */
141 private void runPreTestHooks(FrameworkMethod frameworkMethod) { 159 private void runPreTestHooks(FrameworkMethod frameworkMethod) {
(...skipping 16 matching lines...) Expand all
158 return false; 176 return false;
159 } 177 }
160 178
161 /* 179 /*
162 * Overriding this method to take screenshot of failure before tear down fun ctions are run. 180 * Overriding this method to take screenshot of failure before tear down fun ctions are run.
163 */ 181 */
164 @Override 182 @Override
165 protected Statement withAfters(FrameworkMethod method, Object test, Statemen t base) { 183 protected Statement withAfters(FrameworkMethod method, Object test, Statemen t base) {
166 return super.withAfters(method, test, new ScreenshotOnFailureStatement(b ase)); 184 return super.withAfters(method, test, new ScreenshotOnFailureStatement(b ase));
167 } 185 }
186
168 } 187 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698