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

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

Issue 1519523002: [Android] Support conditional test disabling based on android.os.Build values. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix one outdated use of SkipCheck Created 5 years 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 android.app.Instrumentation; 7 import android.app.Instrumentation;
8 import android.content.Context; 8 import android.content.Context;
9 import android.os.Bundle; 9 import android.os.Bundle;
10 import android.os.SystemClock; 10 import android.os.SystemClock;
11 11
12 import junit.framework.AssertionFailedError; 12 import junit.framework.AssertionFailedError;
13 import junit.framework.TestCase; 13 import junit.framework.TestCase;
14 import junit.framework.TestResult; 14 import junit.framework.TestResult;
15 15
16 import org.chromium.base.Log; 16 import org.chromium.base.Log;
17 import org.chromium.base.test.util.CommandLineFlags; 17 import org.chromium.base.test.util.CommandLineFlags;
18 import org.chromium.base.test.util.SkipCheck;
18 import org.chromium.base.test.util.parameter.BaseParameter; 19 import org.chromium.base.test.util.parameter.BaseParameter;
19 import org.chromium.base.test.util.parameter.Parameter; 20 import org.chromium.base.test.util.parameter.Parameter;
20 import org.chromium.base.test.util.parameter.Parameterizable; 21 import org.chromium.base.test.util.parameter.Parameterizable;
21 import org.chromium.base.test.util.parameter.ParameterizedTest; 22 import org.chromium.base.test.util.parameter.ParameterizedTest;
22 23
23 import java.io.PrintWriter; 24 import java.io.PrintWriter;
24 import java.io.StringWriter; 25 import java.io.StringWriter;
25 import java.lang.reflect.Method; 26 import java.lang.reflect.Method;
26 import java.util.ArrayList; 27 import java.util.ArrayList;
27 import java.util.Arrays; 28 import java.util.Arrays;
(...skipping 18 matching lines...) Expand all
46 /** 47 /**
47 * Creates an instance of BaseTestResult. 48 * Creates an instance of BaseTestResult.
48 */ 49 */
49 public BaseTestResult(Instrumentation instrumentation) { 50 public BaseTestResult(Instrumentation instrumentation) {
50 mSkipChecks = new ArrayList<>(); 51 mSkipChecks = new ArrayList<>();
51 mPreTestHooks = new ArrayList<>(); 52 mPreTestHooks = new ArrayList<>();
52 mInstrumentation = instrumentation; 53 mInstrumentation = instrumentation;
53 } 54 }
54 55
55 /** 56 /**
56 * An interface for classes that check whether a test case should be skipped .
57 */
58 public interface SkipCheck {
59 /**
60 *
61 * Checks whether the given test case should be skipped.
62 *
63 * @param testCase The test case to check.
64 * @return Whether the test case should be skipped.
65 */
66 boolean shouldSkip(TestCase testCase);
67 }
68
69 /**
70 * An interface for classes that have some code to run before a test. They r un after 57 * An interface for classes that have some code to run before a test. They r un after
71 * {@link SkipCheck}s. Provides access to the test method (and the annotatio ns defined for it) 58 * {@link SkipCheck}s. Provides access to the test method (and the annotatio ns defined for it)
72 * and the instrumentation context. 59 * and the instrumentation context.
73 */ 60 */
74 public interface PreTestHook { 61 public interface PreTestHook {
75 /** 62 /**
76 * @param targetContext the instrumentation context that will be used du ring the test. 63 * @param targetContext the instrumentation context that will be used du ring the test.
77 * @param testMethod the test method to be run. 64 * @param testMethod the test method to be run.
78 */ 65 */
79 public void run(Context targetContext, Method testMethod); 66 public void run(Context targetContext, Method testMethod);
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 && SystemClock.uptimeMillis() - startTime < WAIT_DURATION_MS ) { 383 && SystemClock.uptimeMillis() - startTime < WAIT_DURATION_MS ) {
397 Thread.sleep(SLEEP_INTERVAL_MS); 384 Thread.sleep(SLEEP_INTERVAL_MS);
398 targetContext = mInstrumentation.getTargetContext(); 385 targetContext = mInstrumentation.getTargetContext();
399 } 386 }
400 } catch (InterruptedException e) { 387 } catch (InterruptedException e) {
401 Log.e(TAG, "Interrupted while attempting to initialize the command l ine."); 388 Log.e(TAG, "Interrupted while attempting to initialize the command l ine.");
402 } 389 }
403 return targetContext; 390 return targetContext;
404 } 391 }
405 } 392 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698