-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
117 changes: 117 additions & 0 deletions
117
...projects/android/benchmark/src/androidTest/java/com/example/test/benchmark/RunPassMark.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,117 @@ | ||
package com.example.test.benchmark | ||
|
||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import androidx.test.uiautomator.By | ||
import androidx.test.uiautomator.UiDevice | ||
import androidx.test.uiautomator.UiSelector | ||
import androidx.test.uiautomator.Until | ||
import org.junit.Assert | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
|
||
|
||
private const val TIMEOUT = 10_000L | ||
|
||
private const val BENCHMARK_TIMEOUT = 15 * 60 * 1000L | ||
|
||
|
||
@RunWith(AndroidJUnit4::class) | ||
class RunPassMark { | ||
|
||
private object Res { | ||
const val splash = "android:id/content" | ||
} | ||
|
||
private object Text { | ||
const val search = "Search" | ||
const val appName = "Perform" | ||
const val accept = "Continue" | ||
const val ok = "OK" | ||
const val next = "NEXT" | ||
const val gotIt = "GOT IT!" | ||
const val cancel = "CANCEL" | ||
const val benchmarkType = "RUN BENCHMARK" | ||
const val results = "Benchmark Results" | ||
} | ||
|
||
@Test | ||
fun run() { | ||
|
||
UiDevice.getInstance( | ||
InstrumentationRegistry.getInstrumentation() | ||
).run { | ||
// Start from the home screen | ||
pressHome() | ||
|
||
// Open apps menu on pixel launcher | ||
findObject(UiSelector().descriptionContains(Text.search)).apply { | ||
swipe(0, visibleBounds.centerY(), 0, 0, 10) | ||
} | ||
|
||
// Wait for app launcher icon | ||
wait(Until.hasObject(By.textContains(Text.appName)), TIMEOUT) | ||
|
||
waitForIdle(5000) | ||
|
||
// Click launcher icon | ||
findObject(UiSelector().textContains(Text.appName)).click() | ||
|
||
waitForIdle(5000) | ||
|
||
// Check version dialog | ||
findObject(UiSelector().text(Text.ok)).run { | ||
if (exists()) click() | ||
} | ||
|
||
Thread.sleep(1000) | ||
|
||
// Check version dialog | ||
findObject(UiSelector().text(Text.ok)).run { | ||
if (exists()) click() | ||
} | ||
|
||
// Check permissions dialog | ||
findObject(UiSelector().text(Text.accept)).run { | ||
if (exists()) click() | ||
} | ||
|
||
// Check version dialog | ||
findObject(UiSelector().text(Text.ok)).run { | ||
if (exists()) click() | ||
} | ||
|
||
// Touch to continue... | ||
findObject(UiSelector().resourceId(Res.splash)).click() | ||
|
||
// Check tooltip dialog | ||
findObject(UiSelector().text(Text.next)).run { | ||
if (exists()) click() | ||
} | ||
|
||
// Check tooltip dialog | ||
findObject(UiSelector().text(Text.gotIt)).run { | ||
if (exists()) click() | ||
} | ||
|
||
waitForIdle(5000) | ||
Thread.sleep(2000) | ||
|
||
// Choose proper benchmark screen | ||
findObject(UiSelector().text(Text.benchmarkType)).click() | ||
|
||
waitForIdle(5000) | ||
Thread.sleep(2000) | ||
|
||
// Wait until benchmark finish | ||
wait(Until.hasObject(By.text(Text.cancel)), TIMEOUT) | ||
wait(Until.gone(By.text(Text.cancel)), BENCHMARK_TIMEOUT) | ||
|
||
// Assert that benchmark results screen is visible | ||
wait(Until.hasObject(By.text(Text.results)), BENCHMARK_TIMEOUT) | ||
|
||
// Make sure that results was recorded | ||
Thread.sleep(5000) | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
test_runner/src/test/kotlin/ftl/fixtures/benchmark/passmark-all.yml
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,24 @@ | ||
gcloud: | ||
app: "./src/test/kotlin/ftl/fixtures/tmp/apk/app-debug.apk" | ||
test: "./src/test/kotlin/ftl/fixtures/tmp/apk/benchmark/benchmark-debug-androidTest.apk" | ||
use-orchestrator: false | ||
directories-to-pull: | ||
- "/sdcard/Android/data/com.futuremark.dmandroid.application/files/3DMarkAndroid/" | ||
additional-apks: | ||
- "./src/test/kotlin/ftl/fixtures/tmp/apk/benchmark/PassMark_PerformanceTest_10.0.1001-fileplanet.apk" | ||
device: | ||
- model: NexusLowRes | ||
version: 30 | ||
locale: en | ||
orientation: portrait | ||
- model: NexusLowResEmulator | ||
version: 30 | ||
locale: en | ||
orientation: portrait | ||
# - model: redfin | ||
# version: 30 | ||
# locale: en | ||
# orientation: portrait | ||
record-video: true | ||
test-targets: | ||
- "class com.example.test.benchmark.RunPassMark" |