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

Side by Side Diff: testing/android/junit/java/src/org/chromium/testing/local/LocalRobolectricTestRunner.java

Issue 2710343003: Update Robolectric to 3.2.2 (Closed)
Patch Set: Update Robolectric to 3.2 Created 3 years, 10 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 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.testing.local; 5 package org.chromium.testing.local;
6 6
7 import org.junit.runners.model.InitializationError; 7 import org.junit.runners.model.InitializationError;
8 8
9 import org.robolectric.RobolectricTestRunner; 9 import org.robolectric.RobolectricTestRunner;
10 import org.robolectric.annotation.Config; 10 import org.robolectric.SdkPicker;
11 import org.robolectric.manifest.AndroidManifest;
12 11
13 /** 12 /**
14 * A custom Robolectric Junit4 Test Runner. This test runner will ignore the 13 * A custom Robolectric Junit4 Test Runner. This test runner specifies which
15 * API level written in the AndroidManifest as that can cause issues if 14 * API levels are supported in Chromium.
16 * Robolectric does not support that API level. The API level will be grabbed
17 * from the robolectric Config annotation, or just be
18 * |DEFAULT_ANDROID_API_LEVEL|
19 */ 15 */
20 public class LocalRobolectricTestRunner extends RobolectricTestRunner { 16 public class LocalRobolectricTestRunner extends RobolectricTestRunner {
21 17
22 private static final int DEFAULT_ANDROID_API_LEVEL = 21;
23
24 public LocalRobolectricTestRunner(Class<?> testClass) throws InitializationE rror { 18 public LocalRobolectricTestRunner(Class<?> testClass) throws InitializationE rror {
25 super(testClass); 19 super(testClass);
26 } 20 }
27 21
28 @Override 22 @Override
29 protected int pickSdkVersion(Config config, AndroidManifest appManifest) { 23 protected SdkPicker createSdkPicker() {
30 // Pulling from the manifest is dangerous as the apk might target a vers ion of 24 return new SdkPicker(System.getProperties(), 18, 21, 25);
31 // android that robolectric does not yet support. We still allow the API level to
32 // be overridden with the Config annotation.
33 if (config != null) {
34 if (config.sdk().length > 1) {
35 throw new IllegalArgumentException(
36 "RobolectricTestRunner does not support multiple values for @Config.sdk");
37 } else if (config.sdk().length == 1) {
38 return config.sdk()[0];
39 }
40 }
41 return DEFAULT_ANDROID_API_LEVEL;
42 } 25 }
43 } 26 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698