Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 2 additions & 48 deletions adam/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,59 +14,16 @@
* limitations under the License.
*/

import com.google.protobuf.gradle.builtins
import com.google.protobuf.gradle.generateProtoTasks
import com.google.protobuf.gradle.id
import com.google.protobuf.gradle.plugins
import com.google.protobuf.gradle.protobuf
import com.google.protobuf.gradle.protoc
import com.google.protobuf.gradle.remove

plugins {
kotlin("jvm")
id("jacoco")
id("org.jetbrains.dokka")
id("com.google.protobuf") version Versions.protobufGradle
id("idea")
}

Deployment.initialize(project)

protobuf {
protoc {
artifact = "com.google.protobuf:protoc:${Versions.protobuf}"
}
plugins {
id("java") {
artifact = "io.grpc:protoc-gen-grpc-java:${Versions.grpc}"
}
id("grpc") {
artifact = "io.grpc:protoc-gen-grpc-java:${Versions.grpc}"
}
id("grpckt") {
artifact = "io.grpc:protoc-gen-grpc-kotlin:${Versions.grpcKotlin}:jdk7@jar"
}
}
generateProtoTasks {
all().forEach {
it.builtins {
remove("java")
}
it.plugins {
id("java") {
option("lite")
}
id("grpc") {
option("lite")
}
id("grpckt") {
option("lite")
}
}
}
}
}

sourceSets {
create("integrationTest") {
compileClasspath += sourceSets.main.get().output
Expand Down Expand Up @@ -153,11 +110,6 @@ dependencies {
implementation(kotlin("stdlib-jdk8", version = Versions.kotlin))
implementation(Libraries.coroutines)
implementation(Libraries.logging)
api(Libraries.protobufLite)
api(Libraries.grpcProtobufLite)
api(Libraries.grpcKotlinStub)
api(Libraries.grpcOkhttp)
api(Libraries.grpcStub)
implementation(Libraries.javaxAnnotations)
implementation(Libraries.vertxCore)
implementation(Libraries.vertxKotlin)
Expand All @@ -175,4 +127,6 @@ dependencies {
integrationTestImplementation(TestLibraries.assertk)
integrationTestImplementation(TestLibraries.junit4)
integrationTestImplementation(kotlin("reflect", version = Versions.kotlin))
integrationTestImplementation(project(":testing"))
integrationTestImplementation(project(":instrumentation-proto"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.malinskiy.adam.request.pkg.multi.ApkSplitInstallationPackage
import com.malinskiy.adam.request.shell.v1.ShellCommandRequest
import com.malinskiy.adam.request.sync.v1.PushFileRequest
import com.malinskiy.adam.rule.AdbDeviceRule
import com.malinskiy.adam.rule.TestFixtures
import kotlinx.coroutines.debug.junit4.CoroutinesTimeout
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
Expand Down Expand Up @@ -69,7 +70,7 @@ class ApkE2ETest {
fun testScenario1() {
runBlocking {
measureTimeMillis {
val testFile = File(javaClass.getResource("/app-debug.apk").toURI())
val testFile = TestFixtures.apk("/app-debug.apk")
val fileName = testFile.name
val channel =
client.execute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import com.malinskiy.adam.request.sync.v1.PullFileRequest
import com.malinskiy.adam.request.sync.v1.PushFileRequest
import com.malinskiy.adam.request.sync.v1.StatFileRequest
import com.malinskiy.adam.rule.AdbDeviceRule
import com.malinskiy.adam.rule.TestFixtures
import kotlinx.coroutines.async
import kotlinx.coroutines.channels.receiveOrNull
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.supervisorScope
Expand Down Expand Up @@ -87,25 +87,25 @@ class FileE2ETest {

@Test
fun testApkPushing() {
val testFile = File(javaClass.getResource("/app-debug.apk").toURI())
val testFile = TestFixtures.apk("/app-debug.apk")
val fileName = testFile.name
runBlocking {
val channel =
adbRule.adb.execute(PushFileRequest(testFile, "/data/local/tmp/$fileName"), this, serial = adbRule.deviceSerial)

var percentage = 0
for(percentageDouble in channel) {
for (percentageDouble in channel) {
val newPercentage = (percentageDouble * 100).roundToInt()
if (newPercentage != percentage) {
print('.')
percentage = newPercentage
}
}
val stats = adbRule.adb.execute(StatFileRequest("/data/local/tmp/app-debug.apk"), adbRule.deviceSerial)

val stats = adbRule.adb.execute(StatFileRequest("/data/local/tmp/$fileName"), adbRule.deviceSerial)
assertThat(stats.size).isEqualTo(testFile.length().toUInt())

val sizeString = adbRule.adb.execute(ShellCommandRequest("${md5()} /data/local/tmp/app-debug.apk"), adbRule.deviceSerial)
val sizeString = adbRule.adb.execute(ShellCommandRequest("${md5()} /data/local/tmp/$fileName"), adbRule.deviceSerial)
val split = sizeString.output.split(" ").filter { it != "" }

/**
Expand Down Expand Up @@ -153,7 +153,7 @@ class FileE2ETest {
)

var percentage = 0
for(percentageDouble in channel) {
for (percentageDouble in channel) {
val newPercentage = (percentageDouble * 100).roundToInt()
if (newPercentage != percentage) {
print('.')
Expand Down Expand Up @@ -192,7 +192,7 @@ class FileE2ETest {
)

var percentage = 0
for(percentageDouble in channel) {
for (percentageDouble in channel) {
val newPercentage = (percentageDouble * 100).roundToInt()
if (newPercentage != percentage) {
print('.')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,17 @@

package com.malinskiy.adam.integration

import assertk.assertThat
import assertk.assertions.contains
import assertk.assertions.isTrue
import com.malinskiy.adam.request.pkg.InstallRemotePackageRequest
import com.malinskiy.adam.request.shell.v1.ShellCommandRequest
import com.malinskiy.adam.request.sync.v1.PushFileRequest
import com.malinskiy.adam.request.testrunner.InstrumentOptions
import com.malinskiy.adam.request.testrunner.TestEnded
import com.malinskiy.adam.request.testrunner.TestEvent
import com.malinskiy.adam.request.testrunner.TestFailed
import com.malinskiy.adam.request.testrunner.TestIdentifier
import com.malinskiy.adam.request.testrunner.TestRunEnded
import com.malinskiy.adam.request.testrunner.TestRunStartedEvent
import com.malinskiy.adam.request.testrunner.TestRunnerRequest
import com.malinskiy.adam.request.testrunner.TestStarted
import com.malinskiy.adam.rule.AdbDeviceRule
import com.malinskiy.adam.rule.TestFixtures
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.runBlocking
import org.junit.After
import org.junit.Assume
import org.junit.Before
import org.junit.Rule
import org.junit.Test
Expand Down Expand Up @@ -64,8 +55,8 @@ class TestRunnerE2ETest {

@Test
fun test1() {
val apk = File(javaClass.getResource("/app-debug.apk").toURI())
val testApk = File(javaClass.getResource("/app-debug-androidTest.apk").toURI())
val apk = TestFixtures.apk("/app-debug.apk")
val testApk = TestFixtures.apk("/app-debug-androidTest.apk")
val apkFileName = apk.name
val testApkFileName = testApk.name

Expand All @@ -92,54 +83,6 @@ class TestRunnerE2ETest {
}
}

@Test
fun testProto() {
val apk = File(javaClass.getResource("/app-debug.apk").toURI())
val testApk = File(javaClass.getResource("/app-debug-androidTest.apk").toURI())
val apkFileName = apk.name
val testApkFileName = testApk.name

runBlocking {
val output = rule.adb.execute(ShellCommandRequest("getprop ro.build.version.sdk"), rule.deviceSerial).output
val sdk = output.trim().toIntOrNull() ?: 0
Assume.assumeTrue("This device doesn't support proto output of am instrument", sdk >= 26)

installApk(apk, apkFileName)
installApk(testApk, testApkFileName)

val channel = rule.adb.execute(
TestRunnerRequest(
"com.example.test",
InstrumentOptions(
clazz = listOf("com.example.AbstractFailingTest")
),
protobuf = true
), serial = rule.deviceSerial,
scope = this
)

val events = mutableListOf<TestEvent>()
for (list in channel) {
events.addAll(list)
}

assertThat(events).contains(TestRunStartedEvent(1))
assertThat(events).contains(TestStarted(TestIdentifier("com.example.AbstractFailingTest", "testAlwaysFailing")))

assertThat(events.any {
it is TestFailed && it.id.className == "com.example.AbstractFailingTest" && it.id.testName == "testAlwaysFailing" && it.stackTrace.isNotEmpty()
}).isTrue()

assertThat(events.any {
it is TestEnded && it.id.className == "com.example.AbstractFailingTest" && it.id.testName == "testAlwaysFailing"
}).isTrue()

assertThat(events.any {
it is TestRunEnded && it.metrics.isEmpty() && it.elapsedTimeMillis > 0
})
}
}

private suspend fun CoroutineScope.installApk(apk: File, apkFileName: String) {
val channel =
rule.adb.execute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import com.malinskiy.adam.request.pkg.multi.ApkSplitInstallationPackage
import com.malinskiy.adam.request.pkg.multi.SingleFileInstallationPackage
import com.malinskiy.adam.rule.AdbDeviceRule
import com.malinskiy.adam.rule.DeviceType
import com.malinskiy.adam.rule.TestFixtures
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import org.junit.After
Expand Down Expand Up @@ -64,7 +65,7 @@ class AbbExecE2ETest {
fun testStreamingInstallRequest() {
runBlocking {
measureTimeMillis {
val testFile = File(javaClass.getResource("/app-debug.apk").toURI())
val testFile = TestFixtures.apk("/app-debug.apk")
val success = adb.adb.execute(
StreamingPackageInstallRequest(
pkg = testFile,
Expand All @@ -84,8 +85,8 @@ class AbbExecE2ETest {
@Test
fun testInstallMultiplePackageRequest() {
runBlocking {
val appFile = File(javaClass.getResource("/app-debug.apk").toURI())
val testFile = File(javaClass.getResource("/app-debug-androidTest.apk").toURI())
val appFile = TestFixtures.apk("/app-debug.apk")
val testFile = TestFixtures.apk("/app-debug-androidTest.apk")
client.execute(
AtomicInstallPackageRequest(
listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import com.malinskiy.adam.request.pkg.multi.ApkSplitInstallationPackage
import com.malinskiy.adam.request.pkg.multi.SingleFileInstallationPackage
import com.malinskiy.adam.rule.AdbDeviceRule
import com.malinskiy.adam.rule.DeviceType
import com.malinskiy.adam.rule.TestFixtures
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.ReceiveChannel
import kotlinx.coroutines.delay
Expand Down Expand Up @@ -70,7 +71,7 @@ class CmdE2ETest {
fun testStreaming() {
runBlocking {
measureTimeMillis {
val testFile = File(javaClass.getResource("/app-debug.apk").toURI())
val testFile = TestFixtures.apk("/app-debug.apk")
val success = client.execute(
StreamingPackageInstallRequest(
pkg = testFile,
Expand All @@ -90,7 +91,7 @@ class CmdE2ETest {
@Test
fun testExecIn() {
runBlocking {
val testFile = File(javaClass.getResource("/app-debug.apk").toURI())
val testFile = TestFixtures.apk("/app-debug.apk")

val blockSizeChannel = Channel<Int>(capacity = 1)
val channel: ReceiveChannel<ByteArray> = sequentialRead(testFile, blockSizeChannel)
Expand Down Expand Up @@ -121,8 +122,8 @@ class CmdE2ETest {
@Test
fun testInstallMultiplePackageRequest() {
runBlocking {
val appFile = File(javaClass.getResource("/app-debug.apk").toURI())
val testFile = File(javaClass.getResource("/app-debug-androidTest.apk").toURI())
val appFile = TestFixtures.apk("/app-debug.apk")
val testFile = TestFixtures.apk("/app-debug-androidTest.apk")
try {
val success = client.execute(
AtomicInstallPackageRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,14 @@ import com.malinskiy.adam.request.sync.v2.PullFileRequest
import com.malinskiy.adam.request.sync.v2.PushFileRequest
import com.malinskiy.adam.rule.AdbDeviceRule
import com.malinskiy.adam.rule.DeviceType
import kotlinx.coroutines.channels.receiveOrNull
import com.malinskiy.adam.rule.TestFixtures
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeout
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TemporaryFolder
import java.io.File
import kotlin.math.roundToInt

class SendRecvV2E2ETest {
Expand Down Expand Up @@ -101,7 +100,7 @@ class SendRecvV2E2ETest {

@Test
fun testApkPushing() {
val testFile = File(javaClass.getResource("/app-debug.apk").toURI())
val testFile = TestFixtures.apk("/app-debug.apk")
val fileName = testFile.name
runBlocking {
val channel =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,19 @@ import com.malinskiy.adam.request.sync.v1.PushFileRequest
import com.malinskiy.adam.request.sync.v2.StatFileRequest
import com.malinskiy.adam.rule.AdbDeviceRule
import com.malinskiy.adam.rule.DeviceType
import kotlinx.coroutines.channels.receiveOrNull
import com.malinskiy.adam.rule.TestFixtures
import kotlinx.coroutines.runBlocking
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import java.io.File
import kotlin.math.roundToInt

class StatV2E2ETest {
@Rule
@JvmField
val adbRule = AdbDeviceRule(DeviceType.ANY, Feature.LS_V2)
val testFile = File(javaClass.getResource("/app-debug.apk").toURI())
val testFile = TestFixtures.apk("/app-debug.apk")

@Before
fun setup() {
Expand Down
Loading