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 {
9
9
targetSdkVersion target_sdk_version
10
10
versionCode 1
11
11
versionName " 1.0"
12
- testInstrumentationRunner " android.support.test.runner.AndroidJUnitRunner "
12
+ testInstrumentationRunner " com.optimizely.ab.android.test_app.TestRunner "
13
13
}
14
14
testOptions {
15
15
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 2
2
<manifest package =" com.optimizely.ab.android.test_app"
3
3
xmlns : android =" http://schemas.android.com/apk/res/android" >
4
4
5
+ <uses-permission android : name =" android.permission.DISABLE_KEYGUARD" />
6
+ <uses-permission android : name =" android.permission.WAKE_LOCK" />
7
+
5
8
<application
6
9
android : name =" .MyApplication"
7
10
android : allowBackup =" false"
You can’t perform that action at this time.
0 commit comments