Skip to content

Commit

Permalink
Fix example, make it compile and work (#1993)
Browse files Browse the repository at this point in the history
fix example, make it compile and work
  • Loading branch information
bartekpacia authored Aug 30, 2024
1 parent 95ee50b commit 0357b5e
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 67 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copied from https://youtrack.jetbrains.com/issue/FL-15599/No-way-of-disabling-Java-Kotlin-wildcard-imports

[*.java]
ij_java_class_count_to_use_import_on_demand = 1024
ij_java_names_count_to_use_import_on_demand = 1024

[*.kt]
ij_kotlin_name_count_to_use_star_import = 1024
ij_kotlin_name_count_to_use_star_import_for_members = 1024
15 changes: 0 additions & 15 deletions example/build.gradle

This file was deleted.

24 changes: 24 additions & 0 deletions example/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask

plugins {
application
alias(libs.plugins.kotlin.jvm)
}

application {
applicationName = "maestro-example"
mainClass.set("MainKt")
}

tasks.named("compileKotlin", KotlinCompilationTask::class.java) {
compilerOptions {
freeCompilerArgs.addAll("-Xjdk-release=1.8")
}
}

dependencies {
implementation("dev.mobile:maestro-client:1.38.1")
implementation("dev.mobile:maestro-orchestra:1.38.1")
implementation("dev.mobile:maestro-ios:1.38.1")
}

75 changes: 25 additions & 50 deletions example/src/main/kotlin/Main.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import dadb.Dadb
import io.grpc.ManagedChannelBuilder
import ios.IOSDevice
import maestro.Maestro
import maestro.drivers.AndroidDriver
import maestro.orchestra.AssertCommand
import maestro.orchestra.MaestroCommand
import maestro.orchestra.ElementSelector
import maestro.orchestra.LaunchAppCommand
import maestro.orchestra.MaestroCommand
import maestro.orchestra.Orchestra
import maestro.orchestra.TapOnElementCommand
import dadb.Dadb
import io.grpc.ManagedChannelBuilder
import ios.IOSDevice
import ios.idb.IdbIOSDevice
import java.io.File
import maestro.drivers.AndroidDriver

/*
*
* Copyright (c) 2022 mobile.dev inc.
Expand All @@ -32,58 +32,33 @@ import maestro.drivers.AndroidDriver

fun main() {
executeAndroidCommands()
executeIOSCommands()
}

private fun executeAndroidCommands() {
val dadb = Dadb.create("localhost", 5555)
val androidApk = File("./examples/samples/src/main/resources/android-app-debug.apk")
val androidApk = File("./e2e/apps/demo_app.apk")
dadb.install(androidApk)
val driver = AndroidDriver(dadb)
val maestro = Maestro.android(driver)
val launchAppCommand = MaestroCommand(launchAppCommand = LaunchAppCommand("dev.mobile.sample"))
val tapViewDetailsCommand = MaestroCommand(
tapOnElement = TapOnElementCommand(ElementSelector(textRegex = "VIEW DETAILS"))
)
val assertCommand = MaestroCommand(
assertCommand = AssertCommand(ElementSelector(textRegex = "Here is the detailed content"))
)
maestro.use {
Orchestra(it).executeCommands(
listOf(
launchAppCommand,
tapViewDetailsCommand,
assertCommand
)
)
}
}

private fun executeIOSCommands() {
val localhost = "localhost"
val port = 10883
val iosArchive = File("./examples/samples/src/main/resources/CovidCertificateVerifier.zip").inputStream()
val channel = ManagedChannelBuilder.forAddress(localhost, port)
.usePlaintext()
.build()
IdbIOSDevice(channel).use { it.install(iosArchive) }
val maestro = Maestro.ios(localhost, port)
val launchAppCommand = MaestroCommand(
launchAppCommand = LaunchAppCommand("ch.admin.bag.covidcertificate.verifier.dev")
)
val tapOnElementCommand = MaestroCommand(
tapOnElement = TapOnElementCommand(
ElementSelector(textRegex = "HOW IT WORKS")
)
)
val assertCommand = MaestroCommand(
assertCommand = AssertCommand(
ElementSelector(textRegex = "HOW IT WORKS")
)
val commands = listOf(
MaestroCommand(
launchAppCommand = LaunchAppCommand("com.example.example"),
),
MaestroCommand(
tapOnElement = TapOnElementCommand(ElementSelector(idRegex = "fabAddIcon")),
),
MaestroCommand(
tapOnElement = TapOnElementCommand(ElementSelector(idRegex = "fabAddIcon")),
),
MaestroCommand(
assertCommand = AssertCommand(
ElementSelector(textRegex = "2"),
),
),
)

maestro.use {
Orchestra(maestro).executeCommands(
listOf(launchAppCommand, tapOnElementCommand, assertCommand)
)
Orchestra(it).executeCommands(commands)
}
}
}
Binary file not shown.
4 changes: 2 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pluginManagement {
gradlePluginPortal()
}
}

dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
Expand All @@ -15,6 +16,7 @@ dependencyResolutionManagement {
}
}

include("example")
include("maestro-utils")
include("maestro-android")
include("maestro-cli")
Expand All @@ -29,5 +31,3 @@ include("maestro-studio:server")
include("maestro-studio:web")
include("maestro-test")
include("maestro-ai")
//include("examples:samples")
//findProject(":examples:samples")?.name = "samples"

0 comments on commit 0357b5e

Please sign in to comment.