OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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.content_shell_apk; | 5 package org.chromium.content_shell_apk; |
6 | 6 |
7 import android.annotation.TargetApi; | 7 import android.annotation.TargetApi; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.os.Build; | 9 import android.os.Build; |
10 import android.os.PowerManager; | 10 import android.os.PowerManager; |
| 11 import android.support.test.InstrumentationRegistry; |
11 import android.support.test.filters.MediumTest; | 12 import android.support.test.filters.MediumTest; |
12 | 13 |
| 14 import org.junit.Assert; |
| 15 import org.junit.Rule; |
| 16 import org.junit.Test; |
| 17 import org.junit.rules.TestRule; |
| 18 import org.junit.runner.RunWith; |
| 19 |
| 20 import org.chromium.base.test.BaseJUnit4ClassRunner; |
13 import org.chromium.base.test.util.Feature; | 21 import org.chromium.base.test.util.Feature; |
14 | 22 |
15 /** | 23 /** |
16 * Test that verifies preconditions for tests to run. | 24 * Test that verifies preconditions for tests to run. |
17 */ | 25 */ |
18 public class ContentShellPreconditionsTest extends ContentShellTestBase { | 26 @RunWith(BaseJUnit4ClassRunner.class) |
| 27 public class ContentShellPreconditionsTest { |
| 28 @Rule |
| 29 public TestRule mActivityTestRule = new ContentShellActivityTestRule(); |
| 30 |
| 31 @Test |
19 @TargetApi(Build.VERSION_CODES.KITKAT_WATCH) | 32 @TargetApi(Build.VERSION_CODES.KITKAT_WATCH) |
20 @SuppressWarnings("deprecation") | 33 @SuppressWarnings("deprecation") |
21 @MediumTest | 34 @MediumTest |
22 @Feature({"TestInfrastructure"}) | 35 @Feature({"TestInfrastructure"}) |
23 public void testScreenIsOn() throws Exception { | 36 public void testScreenIsOn() throws Exception { |
24 PowerManager pm = (PowerManager) getInstrumentation().getContext().getSy
stemService( | 37 PowerManager pm = (PowerManager) InstrumentationRegistry.getContext().ge
tSystemService( |
25 Context.POWER_SERVICE); | 38 Context.POWER_SERVICE); |
26 | 39 |
27 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { | 40 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { |
28 assertTrue("Many tests will fail if the screen is not on.", pm.isInt
eractive()); | 41 Assert.assertTrue("Many tests will fail if the screen is not on.", p
m.isInteractive()); |
29 } else { | 42 } else { |
30 assertTrue("Many tests will fail if the screen is not on.", pm.isScr
eenOn()); | 43 Assert.assertTrue("Many tests will fail if the screen is not on.", p
m.isScreenOn()); |
31 } | 44 } |
32 } | 45 } |
33 } | 46 } |
OLD | NEW |