-
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. (#62) * Creates EmulatorConfigRule to configure the emulator for full screen screenshots. * Updates target sdk versions * 🤖 Updates screenshots * updates AGP and dependencies. * Fixes up some versioning things. * Format update to kick workflow. * Updates gradle wrapper validation action. * Fixes gradle wrapper validation name. * Updates jdk to 17 * 🤖 Updates screenshots * Updates api dump * Updates lint and test targetSdk * Updates dependencies. * Updates min sdk version * 🤖 Updates screenshots --------- Co-authored-by: rharter <[email protected]>
- Loading branch information
Showing
19 changed files
with
143 additions
and
134 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
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
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
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
Binary file modified
BIN
+5 Bytes
(100%)
dropshots/src/androidTest/assets/MatchesActivityScreenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-705 Bytes
(98%)
dropshots/src/androidTest/assets/MatchesFullScreenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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") | ||
} | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
dropshots/src/debug/kotlin/com/dropbox/dropshots/TestActivity.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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
package com.dropbox.dropshots | ||
|
||
class TestActivity : androidx.fragment.app.FragmentActivity() | ||
public class TestActivity : androidx.fragment.app.FragmentActivity() |
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
Oops, something went wrong.