From daebce0aa9d4047271e08f67cfd9230a3e846446 Mon Sep 17 00:00:00 2001 From: habibialireza Date: Sun, 4 Oct 2026 15:05:31 +0200 Subject: [PATCH 1/2] Add Patrol Android integration test --- open_wearable/.gitignore | 5 + open_wearable/android/app/build.gradle | 16 + .../teco/openWearable/MainActivityTest.java | 36 ++ .../app/src/debug/res/values/strings.xml | 4 + .../android/app/src/main/AndroidManifest.xml | 2 +- .../app/src/main/res/values/strings.xml | 4 + open_wearable/docs/testing/README.md | 266 ++++++++++++ .../2026-09-29-pixel-9a-general-settings.md | 36 ++ .../2026-09-29-pixel-9a-late-microphone.md | 30 ++ .../runs/2026-09-29-pixel-9a-navigation.md | 44 ++ .../2026-09-29-pixel-9a-overview-shortcuts.md | 32 ++ .../runs/2026-09-29-pixel-9a-permissions.md | 26 ++ ...6-09-29-pixel-9a-phone-sensor-recording.md | 30 ++ .../runs/2026-09-29-pixel-9a-this-device.md | 27 ++ .../2026-09-30-pixel-9a-openearable-pair.md | 44 ++ .../2026-09-30-pixel-9a-pair-sample-rates.md | 65 +++ open_wearable/docs/testing/test-catalog.md | 304 ++++++++++++++ open_wearable/docs/testing/ui-coverage.md | 227 ++++++++++ open_wearable/lib/main.dart | 121 +++--- .../lib/models/bluetooth_auto_connector.dart | 1 + .../lib/widgets/common/no_devices_prompt.dart | 3 + .../widgets/devices/connect_devices_page.dart | 9 + .../device_detail/device_detail_page.dart | 6 + .../lib/widgets/devices/devices_page.dart | 14 + open_wearable/lib/widgets/home_page.dart | 24 +- .../lib/widgets/home_page_overview.dart | 7 + .../permissions_onboarding_page.dart | 5 + .../sensor_configuration_detail_view.dart | 13 + .../sensor_configuration_value_row.dart | 4 + .../sensor_configuration_view.dart | 1 + .../local_recorder_recording_card.dart | 1 + .../local_recorder_recording_folder_card.dart | 4 + .../local_recorder/local_recorder_view.dart | 6 + .../lib/widgets/sensors/sensor_page.dart | 34 +- .../settings/general_settings_page.dart | 15 + .../lib/widgets/settings/settings_page.dart | 6 + .../lib/widgets/updates/app_upgrade_page.dart | 1 + .../Flutter/GeneratedPluginRegistrant.swift | 2 + .../patrol_test/general_settings_test.dart | 99 +++++ .../late_microphone_permission_test.dart | 47 +++ .../navigation_and_settings_test.dart | 62 +++ .../onboarding_permissions_test.dart | 50 +++ .../open_earable_connection_test.dart | 68 +++ .../open_earable_pair_sample_rate_test.dart | 389 ++++++++++++++++++ .../patrol_test/open_earable_pair_test.dart | 49 +++ .../patrol_test/overview_shortcuts_test.dart | 59 +++ .../patrol_test/pair_discovery_test.dart | 43 ++ .../patrol_test/support/app_driver.dart | 288 +++++++++++++ .../support/open_earable_pair_driver.dart | 204 +++++++++ .../this_device_connection_test.dart | 39 ++ .../this_device_recording_test.dart | 94 +++++ open_wearable/pubspec.lock | 64 ++- open_wearable/pubspec.yaml | 10 + open_wearable/tool/ui_tests/build_android.ps1 | 164 ++++++++ .../tool/ui_tests/choose_android_test.ps1 | 85 ++++ open_wearable/tool/ui_tests/run_android.ps1 | 169 ++++++++ 56 files changed, 3379 insertions(+), 79 deletions(-) create mode 100644 open_wearable/android/app/src/androidTest/java/edu/kit/teco/openWearable/MainActivityTest.java create mode 100644 open_wearable/android/app/src/debug/res/values/strings.xml create mode 100644 open_wearable/android/app/src/main/res/values/strings.xml create mode 100644 open_wearable/docs/testing/README.md create mode 100644 open_wearable/docs/testing/runs/2026-09-29-pixel-9a-general-settings.md create mode 100644 open_wearable/docs/testing/runs/2026-09-29-pixel-9a-late-microphone.md create mode 100644 open_wearable/docs/testing/runs/2026-09-29-pixel-9a-navigation.md create mode 100644 open_wearable/docs/testing/runs/2026-09-29-pixel-9a-overview-shortcuts.md create mode 100644 open_wearable/docs/testing/runs/2026-09-29-pixel-9a-permissions.md create mode 100644 open_wearable/docs/testing/runs/2026-09-29-pixel-9a-phone-sensor-recording.md create mode 100644 open_wearable/docs/testing/runs/2026-09-29-pixel-9a-this-device.md create mode 100644 open_wearable/docs/testing/runs/2026-09-30-pixel-9a-openearable-pair.md create mode 100644 open_wearable/docs/testing/runs/2026-09-30-pixel-9a-pair-sample-rates.md create mode 100644 open_wearable/docs/testing/test-catalog.md create mode 100644 open_wearable/docs/testing/ui-coverage.md create mode 100644 open_wearable/patrol_test/general_settings_test.dart create mode 100644 open_wearable/patrol_test/late_microphone_permission_test.dart create mode 100644 open_wearable/patrol_test/navigation_and_settings_test.dart create mode 100644 open_wearable/patrol_test/onboarding_permissions_test.dart create mode 100644 open_wearable/patrol_test/open_earable_connection_test.dart create mode 100644 open_wearable/patrol_test/open_earable_pair_sample_rate_test.dart create mode 100644 open_wearable/patrol_test/open_earable_pair_test.dart create mode 100644 open_wearable/patrol_test/overview_shortcuts_test.dart create mode 100644 open_wearable/patrol_test/pair_discovery_test.dart create mode 100644 open_wearable/patrol_test/support/app_driver.dart create mode 100644 open_wearable/patrol_test/support/open_earable_pair_driver.dart create mode 100644 open_wearable/patrol_test/this_device_connection_test.dart create mode 100644 open_wearable/patrol_test/this_device_recording_test.dart create mode 100644 open_wearable/tool/ui_tests/build_android.ps1 create mode 100644 open_wearable/tool/ui_tests/choose_android_test.ps1 create mode 100644 open_wearable/tool/ui_tests/run_android.ps1 diff --git a/open_wearable/.gitignore b/open_wearable/.gitignore index b223fb72a..8f0304540 100644 --- a/open_wearable/.gitignore +++ b/open_wearable/.gitignore @@ -33,6 +33,11 @@ migrate_working_dir/ .pub/ /build/ +# Patrol-generated entry point, local test settings, and run artifacts. +**/test_bundle.dart +.patrol.env +/test-results/ + # Generated plugin registrants **/GeneratedPluginRegistrant.swift **/generated_plugin_registrant.cc diff --git a/open_wearable/android/app/build.gradle b/open_wearable/android/app/build.gradle index 30ee3d7cb..8bd257b88 100644 --- a/open_wearable/android/app/build.gradle +++ b/open_wearable/android/app/build.gradle @@ -29,9 +29,17 @@ android { targetSdk = flutter.targetSdkVersion versionCode = customVersionCode.toInteger() versionName = flutter.versionName + testInstrumentationRunner "pl.leancode.patrol.PatrolJUnitRunner" + testInstrumentationRunnerArguments["clearPackageData"] = "true" } buildTypes { + debug { + // Patrol runs debug builds. Give that build its own Android identity + // so it can live beside the user's normal OpenWearables app and so + // test-data cleanup never touches the production installation. + applicationIdSuffix = ".patrol" + } release { // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. @@ -41,6 +49,10 @@ android { proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } + + testOptions { + execution "ANDROIDX_TEST_ORCHESTRATOR" + } } flutter { @@ -52,3 +64,7 @@ kotlin { jvmTarget = org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17 } } + +dependencies { + androidTestUtil "androidx.test:orchestrator:1.5.1" +} diff --git a/open_wearable/android/app/src/androidTest/java/edu/kit/teco/openWearable/MainActivityTest.java b/open_wearable/android/app/src/androidTest/java/edu/kit/teco/openWearable/MainActivityTest.java new file mode 100644 index 000000000..1214fb702 --- /dev/null +++ b/open_wearable/android/app/src/androidTest/java/edu/kit/teco/openWearable/MainActivityTest.java @@ -0,0 +1,36 @@ +package edu.kit.teco.openWearable; + +import androidx.test.platform.app.InstrumentationRegistry; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; + +import pl.leancode.patrol.PatrolJUnitRunner; + +/** Runs every discovered Dart Patrol test as an Android instrumentation test. */ +@RunWith(Parameterized.class) +public class MainActivityTest { + @Parameters(name = "{0}") + public static Object[] testCases() { + PatrolJUnitRunner instrumentation = + (PatrolJUnitRunner) InstrumentationRegistry.getInstrumentation(); + instrumentation.setUp(MainActivity.class); + instrumentation.waitForPatrolAppService(); + return instrumentation.listDartTests(); + } + + private final String dartTestName; + + public MainActivityTest(String dartTestName) { + this.dartTestName = dartTestName; + } + + @Test + public void runDartTest() { + PatrolJUnitRunner instrumentation = + (PatrolJUnitRunner) InstrumentationRegistry.getInstrumentation(); + instrumentation.runDartTest(dartTestName); + } +} diff --git a/open_wearable/android/app/src/debug/res/values/strings.xml b/open_wearable/android/app/src/debug/res/values/strings.xml new file mode 100644 index 000000000..a4723d769 --- /dev/null +++ b/open_wearable/android/app/src/debug/res/values/strings.xml @@ -0,0 +1,4 @@ + + + OpenWearables Test + diff --git a/open_wearable/android/app/src/main/AndroidManifest.xml b/open_wearable/android/app/src/main/AndroidManifest.xml index 744041532..a2a93bd10 100644 --- a/open_wearable/android/app/src/main/AndroidManifest.xml +++ b/open_wearable/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ - +