Last active
April 6, 2017 10:41
-
-
Save koral--/3726be167d3a67a20d87d86640317cf2 to your computer and use it in GitHub Desktop.
Buildscript snippets for blog post: http://www.thedroidsonroids.com/blog/setting-animation-scale-for-android-ui-tests/
This file contains hidden or 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
| import com.android.ddmlib.AndroidDebugBridge | |
| import com.android.ddmlib.IDevice | |
| import com.android.ddmlib.NullOutputReceiver | |
| import java.util.concurrent.TimeUnit | |
| buildscript { | |
| repositories { | |
| jcenter() | |
| } | |
| dependencies { | |
| classpath 'com.android.tools.build:gradle:2.2.3' | |
| } | |
| } | |
| apply plugin: 'com.android.application' | |
| android { | |
| buildToolsVersion '25.0.1' | |
| compileSdkVersion 25 | |
| } | |
| IDevice.metaClass.setZeroScale { | |
| delegate.executeShellCommand("settings put global ${it}_scale 0", NullOutputReceiver.receiver, 1, TimeUnit.SECONDS) | |
| } | |
| task('connectedDisableAnimations') { | |
| AndroidDebugBridge.initIfNeeded(false) | |
| def bridge = AndroidDebugBridge.createBridge(android.adbExecutable.path, false) | |
| doLast { | |
| bridge.devices.each { | |
| it.setZeroScale 'window_animation' | |
| it.setZeroScale 'transition_animation' | |
| it.setZeroScale 'animator_duration' | |
| } | |
| } | |
| } |
This file contains hidden or 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
| import com.android.ddmlib.AndroidDebugBridge | |
| import com.android.ddmlib.IDevice | |
| import com.android.ddmlib.NullOutputReceiver | |
| import java.util.concurrent.TimeUnit | |
| import com.android.build.gradle.AppExtension | |
| import com.android.build.gradle.AppPlugin | |
| import org.gradle.api.Project | |
| import org.jetbrains.kotlin.gradle.plugin.KotlinAndroidPluginWrapper | |
| buildscript { | |
| repositories { | |
| jcenter() | |
| gradleScriptKotlin() | |
| } | |
| dependencies { | |
| classpath("com.android.tools.build:gradle:2.2.2") | |
| classpath(kotlinModule("gradle-plugin")) | |
| } | |
| } | |
| apply { | |
| plugin<AppPlugin>() | |
| plugin<KotlinAndroidPluginWrapper>() | |
| } | |
| android { | |
| buildToolsVersion("25.0.1") | |
| compileSdkVersion(25) | |
| } | |
| fun Project.android(setup: AppExtension.() -> Unit) = the<AppExtension>().setup() | |
| fun IDevice.setZeroScale(prefix: String) { | |
| executeShellCommand("settings put global ${prefix}_scale 0", NullOutputReceiver.getReceiver(), 1, TimeUnit.SECONDS) | |
| } | |
| task("connectedSetup") { | |
| AndroidDebugBridge.initIfNeeded(false) | |
| val bridge = AndroidDebugBridge.createBridge(the<AppExtension>().adbExecutable.path, false) | |
| doLast { | |
| bridge.devices.forEach { | |
| it.setZeroScale("window_animation") | |
| it.setZeroScale("transition_animation") | |
| it.setZeroScale("animator_duration") | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment