-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creates EmulatorConfigRule to configure the emulator for full screen …
…screenshots.
- Loading branch information
Showing
5 changed files
with
49 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,7 @@ | ||
#!/bin/bash | ||
|
||
adb wait-for-devices | ||
|
||
echo "Cleaning up old emulator data" | ||
adb uninstall com.dropbox.dropshots.test || true | ||
adb shell rm -rf /storage/emulated/0/Download/screenshots || true | ||
|
||
adb wait-for-devices | ||
adb shell settings put global sysui_demo_allowed 1 | ||
adb shell am broadcast -a com.android.systemui.demo -e command enter | ||
adb shell am broadcast -a com.android.systemui.demo -e command clock -e hhmm 1234 | ||
adb shell am broadcast -a com.android.systemui.demo -e command battery -e plugged false | ||
adb shell am broadcast -a com.android.systemui.demo -e command battery -e level 100 | ||
adb shell am broadcast -a com.android.systemui.demo -e command network -e wifi show -e level 4 | ||
adb shell am broadcast -a com.android.systemui.demo -e command network -e mobile show -e datatype none -e level 4 | ||
adb shell am broadcast -a com.android.systemui.demo -e command notifications -e visible false | ||
adb shell cmd overlay enable com.android.internal.systemui.navbar.gestural |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
dropshots/src/androidTest/kotlin/com/dropbox/dropshots/EmulatorConfigRule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package com.dropbox.dropshots | ||
|
||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.uiautomator.UiDevice | ||
import org.junit.rules.TestRule | ||
import org.junit.runner.Description | ||
import org.junit.runners.model.Statement | ||
|
||
class EmulatorConfigRule : TestRule { | ||
override fun apply(base: Statement, description: Description): Statement = | ||
EmulatorConfigStatement(base) | ||
|
||
private class EmulatorConfigStatement( | ||
private val base: Statement, | ||
) : Statement() { | ||
override fun evaluate() { | ||
enableDemoMode() | ||
base.evaluate() | ||
disableDemoMode() | ||
} | ||
|
||
private fun enableDemoMode() { | ||
UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) | ||
.apply { | ||
executeShellCommand("cmd overlay enable com.android.internal.systemui.navbar.gestural") | ||
executeShellCommand("settings put global sysui_demo_allowed 1") | ||
executeShellCommand("am broadcast -a com.android.systemui.demo -e command enter") | ||
executeShellCommand("am broadcast -a com.android.systemui.demo -e command clock -e hhmm 1234") | ||
executeShellCommand("am broadcast -a com.android.systemui.demo -e command battery -e plugged false") | ||
executeShellCommand("am broadcast -a com.android.systemui.demo -e command battery -e level 100") | ||
executeShellCommand("am broadcast -a com.android.systemui.demo -e command network -e wifi show -e level 4") | ||
executeShellCommand("am broadcast -a com.android.systemui.demo -e command network -e mobile show -e datatype none -e level 4") | ||
executeShellCommand("am broadcast -a com.android.systemui.demo -e command notifications -e visible false") | ||
} | ||
} | ||
|
||
private fun disableDemoMode() { | ||
UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()) | ||
.executeShellCommand("am broadcast -a com.android.systemui.demo -e command exit") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters