Merge "Changes to reduce flakiness of TrustTests" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
0d97e88c02
@@ -16,6 +16,13 @@
|
|||||||
-->
|
-->
|
||||||
<configuration description="TrustTests configuration">
|
<configuration description="TrustTests configuration">
|
||||||
<option name="test-tag" value="TrustTests" />
|
<option name="test-tag" value="TrustTests" />
|
||||||
|
<target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
|
||||||
|
<!-- Disable the double-tap power button for camera -->
|
||||||
|
<option name="run-command"
|
||||||
|
value="settings put secure camera_double_tap_power_gesture_disabled 1" />
|
||||||
|
<option name="teardown-command"
|
||||||
|
value="settings delete secure camera_double_tap_power_gesture_disabled" />
|
||||||
|
</target_preparer>
|
||||||
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
|
<target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
|
||||||
<option name="cleanup-apks" value="true" />
|
<option name="cleanup-apks" value="true" />
|
||||||
<option name="test-file-name" value="TrustTests.apk" />
|
<option name="test-file-name" value="TrustTests.apk" />
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import org.junit.runner.RunWith
|
|||||||
*/
|
*/
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class UserUnlockRequestTest {
|
class UserUnlockRequestTest {
|
||||||
private val context: Context = getApplicationContext()
|
private val context = getApplicationContext<Context>()
|
||||||
private val trustManager = context.getSystemService(TrustManager::class.java) as TrustManager
|
private val trustManager = context.getSystemService(TrustManager::class.java) as TrustManager
|
||||||
private val userId = context.userId
|
private val userId = context.userId
|
||||||
private val activityScenarioRule = ActivityScenarioRule(TrustTestActivity::class.java)
|
private val activityScenarioRule = ActivityScenarioRule(TrustTestActivity::class.java)
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package android.trust.test.lib
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
|
import android.view.KeyEvent
|
||||||
import android.view.WindowManagerGlobal
|
import android.view.WindowManagerGlobal
|
||||||
import androidx.test.core.app.ApplicationProvider.getApplicationContext
|
import androidx.test.core.app.ApplicationProvider.getApplicationContext
|
||||||
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
|
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
|
||||||
@@ -64,17 +65,19 @@ class ScreenLockRule : TestRule {
|
|||||||
|
|
||||||
fun dismissKeyguard() {
|
fun dismissKeyguard() {
|
||||||
wait("keyguard dismissed") { count ->
|
wait("keyguard dismissed") { count ->
|
||||||
windowManager.dismissKeyguard(null, null)
|
if (!uiDevice.isScreenOn) {
|
||||||
|
Log.i(TAG, "Waking device, +500ms")
|
||||||
// Sometimes, bouncer gets shown due to a race, so we have to put display to sleep
|
|
||||||
// and wake it back up to get it to go away
|
|
||||||
if (count >= 10 && count % 5 == 0) {
|
|
||||||
Log.i(TAG, "Escalation: attempting screen off/on to get rid of bouncer")
|
|
||||||
uiDevice.sleep()
|
|
||||||
Thread.sleep(250)
|
|
||||||
uiDevice.wakeUp()
|
uiDevice.wakeUp()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Bouncer may be shown due to a race; back dismisses it
|
||||||
|
if (count >= 10) {
|
||||||
|
Log.i(TAG, "Pressing back to dismiss Bouncer")
|
||||||
|
uiDevice.pressKeyCode(KeyEvent.KEYCODE_BACK)
|
||||||
|
}
|
||||||
|
|
||||||
|
windowManager.dismissKeyguard(null, null)
|
||||||
|
|
||||||
!windowManager.isKeyguardLocked
|
!windowManager.isKeyguardLocked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user