Skip to content

Instantly share code, notes, and snippets.

@dagezi
Last active December 29, 2015 04:17
Show Gist options
  • Save dagezi/48ddf0677dd62b3a8495 to your computer and use it in GitHub Desktop.
Save dagezi/48ddf0677dd62b3a8495 to your computer and use it in GitHub Desktop.
import com.android.build.gradle.internal.tasks.DeviceProviderInstrumentTestTask
import com.android.builder.testing.api.DeviceConnector
def isDeviceReady(DeviceConnector device) {
def res = device.getSystemProperty('init.svc.bootanim').get()
return res == 'stopped'
}
def waitForAllDevicesReady(DeviceProviderInstrumentTestTask testTaks) {
// Add time out?
def devices = testTaks.deviceProvider.devices.clone()
while (!devices.isEmpty()) {
devices.removeAll isDeviceReady
sleep(1000)
}
}
android.testVariants.all { variant ->
variant.connectedInstrumentTest.doFirst {
waitForAllDevicesReady(variant.connectedInstrumentTest)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment