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

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: Small fix to StripLayoutHelperTest Created 3 years, 9 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
9 import org.robolectric.RobolectricTestRunner; 8 import org.robolectric.RobolectricTestRunner;
10 import org.robolectric.annotation.Config; 9 import org.robolectric.annotation.Config;
11 import org.robolectric.manifest.AndroidManifest; 10 import org.robolectric.internal.ManifestFactory;
12 11
13 /** 12 /**
14 * A custom Robolectric Junit4 Test Runner. This test runner will ignore the 13 * A custom Robolectric Junit4 Test Runner with Chromium specific settings.
15 * API level written in the AndroidManifest as that can cause issues if
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 */ 14 */
20 public class LocalRobolectricTestRunner extends RobolectricTestRunner { 15 public class LocalRobolectricTestRunner extends RobolectricTestRunner {
21 16 private static final int DEFAULT_SDK = 25;
22 private static final int DEFAULT_ANDROID_API_LEVEL = 21;
23 17
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 Config buildGlobalConfig() {
30 // Pulling from the manifest is dangerous as the apk might target a vers ion of 24 return new Config.Builder().setSdk(DEFAULT_SDK).build();
31 // android that robolectric does not yet support. We still allow the API level to 25 }
32 // be overridden with the Config annotation. 26
33 if (config != null) { 27 @Override
34 if (config.sdk().length > 1) { 28 protected ManifestFactory getManifestFactory(Config config) {
35 throw new IllegalArgumentException( 29 return new GNManifestFactory();
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 } 30 }
43 } 31 }
OLDNEW
« no previous file with comments | « testing/android/junit/java/src/org/chromium/testing/local/GNManifestFactory.java ('k') | third_party/.gitignore » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698