File tree Expand file tree Collapse file tree 3 files changed +36
-1
lines changed
androidTest/java/com/optimizely/ab/android/test_app Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ android {
99 targetSdkVersion target_sdk_version
1010 versionCode 1
1111 versionName " 1.0"
12- testInstrumentationRunner " android.support.test.runner.AndroidJUnitRunner "
12+ testInstrumentationRunner " com.optimizely.ab.android.test_app.TestRunner "
1313 }
1414 testOptions {
1515 unitTests. returnDefaultValues = true
Original file line number Diff line number Diff line change 1+ package com .optimizely .ab .android .test_app ;
2+
3+ import android .app .Application ;
4+ import android .app .KeyguardManager ;
5+ import android .content .Context ;
6+ import android .os .PowerManager ;
7+ import android .support .test .runner .AndroidJUnitRunner ;
8+
9+ public class TestRunner extends AndroidJUnitRunner {
10+ private PowerManager .WakeLock wakeLock ;
11+
12+ @ Override
13+ public void callApplicationOnCreate (Application app ) {
14+ // Unlock the screen
15+ KeyguardManager keyguard = (KeyguardManager ) app .getSystemService (Context .KEYGUARD_SERVICE );
16+ keyguard .newKeyguardLock (getClass ().getSimpleName ()).disableKeyguard ();
17+
18+ // Start a wake lock
19+ PowerManager power = (PowerManager ) app .getSystemService (Context .POWER_SERVICE );
20+ wakeLock = power .newWakeLock (PowerManager .FULL_WAKE_LOCK | PowerManager .ACQUIRE_CAUSES_WAKEUP | PowerManager .ON_AFTER_RELEASE , getClass ().getSimpleName ());
21+ wakeLock .acquire ();
22+
23+ super .callApplicationOnCreate (app );
24+ }
25+
26+ @ Override
27+ public void onDestroy () {
28+ wakeLock .release ();
29+
30+ super .onDestroy ();
31+ }
32+ }
Original file line number Diff line number Diff line change 22<manifest package =" com.optimizely.ab.android.test_app"
33 xmlns : android =" http://schemas.android.com/apk/res/android" >
44
5+ <uses-permission android : name =" android.permission.DISABLE_KEYGUARD" />
6+ <uses-permission android : name =" android.permission.WAKE_LOCK" />
7+
58 <application
69 android : name =" .MyApplication"
710 android : allowBackup =" false"
You can’t perform that action at this time.
0 commit comments