1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35

content / shell / android / javatests / src / org / chromium / content_shell_apk / ContentShellPreconditionsTest.java [blame]

// Copyright 2015 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

package org.chromium.content_shell_apk;

import android.content.Context;
import android.os.PowerManager;

import androidx.test.InstrumentationRegistry;
import androidx.test.filters.MediumTest;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;

import org.chromium.base.test.BaseJUnit4ClassRunner;
import org.chromium.base.test.util.Feature;

/** Test that verifies preconditions for tests to run. */
@RunWith(BaseJUnit4ClassRunner.class)
public class ContentShellPreconditionsTest {
    @Test
    @SuppressWarnings("deprecation")
    @MediumTest
    @Feature({"TestInfrastructure"})
    public void testScreenIsOn() {
        PowerManager pm =
                (PowerManager)
                        InstrumentationRegistry.getContext()
                                .getSystemService(Context.POWER_SERVICE);

        Assert.assertTrue("Many tests will fail if the screen is not on.", pm.isInteractive());
    }
}