From 9e1992c9061268eb80102aff4a70d754e2d79731 Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Thu, 9 Nov 2023 13:52:59 +0100 Subject: [PATCH 1/5] use latest Flutter master on CI ktlint format --- .github/workflows/patrol-prepare.yaml | 19 +++++++++++++++---- .github/workflows/patrol_cli-prepare.yaml | 4 +++- .../patrol_devtools_extension-prepare.yaml | 4 +++- .github/workflows/patrol_finders-prepare.yaml | 4 +++- .github/workflows/test-android-device.yaml | 10 ++++++---- .../test-android-emulator-webview.yaml | 10 ++++++---- .github/workflows/test-android-emulator.yaml | 10 ++++++---- .github/workflows/test-ios-device.yaml | 10 ++++++---- .../workflows/test-ios-simulator-webview.yaml | 10 ++++++---- .github/workflows/test-ios-simulator.yaml | 10 ++++++---- .../kotlin/pl/leancode/patrol/Automator.kt | 2 +- .../pl/leancode/patrol/AutomatorServer.kt | 4 ++-- .../kotlin/pl/leancode/patrol/UITreeUtils.kt | 8 +++++--- 13 files changed, 68 insertions(+), 37 deletions(-) diff --git a/.github/workflows/patrol-prepare.yaml b/.github/workflows/patrol-prepare.yaml index 6b669996d..c803506d4 100644 --- a/.github/workflows/patrol-prepare.yaml +++ b/.github/workflows/patrol-prepare.yaml @@ -15,6 +15,8 @@ jobs: fail-fast: false matrix: os: [windows-latest] + flutter-version: ['3.17.0-5.0.pre.26'] + flutter-channel: ['master'] defaults: run: @@ -27,7 +29,8 @@ jobs: - name: Set up Flutter uses: subosito/flutter-action@v2 with: - flutter-version: '3.13.x' + flutter-version: ${{ matrix.flutter-version }} + channel: ${{ matrix.flutter-channel }} - name: Set up Java uses: actions/setup-java@v3 @@ -59,6 +62,8 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest] + flutter-version: ['3.17.0-5.0.pre.26'] + flutter-channel: ['master'] defaults: run: @@ -71,7 +76,8 @@ jobs: - name: Set up Flutter uses: subosito/flutter-action@v2 with: - flutter-version: '3.13.x' + flutter-version: ${{ matrix.flutter-version }} + channel: ${{ matrix.flutter-channel }} - name: Generate Gradle wrapper working-directory: packages/patrol/example @@ -103,6 +109,8 @@ jobs: fail-fast: false matrix: os: [macos-latest] + flutter-version: ['3.17.0-5.0.pre.26'] + flutter-channel: ['master'] defaults: run: @@ -136,7 +144,8 @@ jobs: - name: Set up Flutter uses: subosito/flutter-action@v2 with: - flutter-version: '3.13.x' + flutter-version: ${{ matrix.flutter-version }} + channel: ${{ matrix.flutter-channel }} - name: Generate iOS build files working-directory: packages/patrol/example @@ -170,7 +179,8 @@ jobs: strategy: fail-fast: false matrix: - flutter-version: ['3.3.x', '3.7.x', '3.10.x', '3.13.x'] + flutter-version: ['3.17.0-5.0.pre.26'] + flutter-channel: ['master'] defaults: run: @@ -184,6 +194,7 @@ jobs: uses: subosito/flutter-action@v2 with: flutter-version: ${{ matrix.flutter-version }} + channel: ${{ matrix.flutter-channel }} - name: flutter pub get run: flutter pub get diff --git a/.github/workflows/patrol_cli-prepare.yaml b/.github/workflows/patrol_cli-prepare.yaml index e5af71889..554130bed 100644 --- a/.github/workflows/patrol_cli-prepare.yaml +++ b/.github/workflows/patrol_cli-prepare.yaml @@ -15,7 +15,8 @@ jobs: fail-fast: false matrix: os: [ubuntu-latest, windows-latest] - flutter-version: ['3.3.x', '3.7.x', '3.10.x', '3.13.x'] + flutter-version: ['3.17.0-5.0.pre.26'] + flutter-channel: ['master'] defaults: run: @@ -29,6 +30,7 @@ jobs: uses: subosito/flutter-action@v2 with: flutter-version: ${{ matrix.flutter-version }} + channel: ${{ matrix.flutter-channel }} - name: Run flutter tool (to dismiss the first run experience) run: flutter diff --git a/.github/workflows/patrol_devtools_extension-prepare.yaml b/.github/workflows/patrol_devtools_extension-prepare.yaml index d29b5e7de..765018816 100644 --- a/.github/workflows/patrol_devtools_extension-prepare.yaml +++ b/.github/workflows/patrol_devtools_extension-prepare.yaml @@ -14,7 +14,8 @@ jobs: strategy: fail-fast: false matrix: - flutter-version: ['3.3.x', '3.7.x', '3.10.x', '3.13.x'] + flutter-version: ['3.17.0-5.0.pre.26'] + flutter-channel: ['master'] defaults: run: @@ -28,6 +29,7 @@ jobs: uses: subosito/flutter-action@v2 with: flutter-version: ${{ matrix.flutter-version }} + channel: ${{ matrix.flutter-channel }} - name: flutter pub get run: flutter pub get diff --git a/.github/workflows/patrol_finders-prepare.yaml b/.github/workflows/patrol_finders-prepare.yaml index b9513f64b..04b6737e1 100644 --- a/.github/workflows/patrol_finders-prepare.yaml +++ b/.github/workflows/patrol_finders-prepare.yaml @@ -14,7 +14,8 @@ jobs: strategy: fail-fast: false matrix: - flutter-version: ['3.3.x', '3.7.x', '3.10.x', '3.13.x'] + flutter-version: ['3.17.0-5.0.pre.26'] + flutter-channel: ['master'] defaults: run: @@ -28,6 +29,7 @@ jobs: uses: subosito/flutter-action@v2 with: flutter-version: ${{ matrix.flutter-version }} + channel: ${{ matrix.flutter-channel }} - name: flutter pub get run: flutter pub get diff --git a/.github/workflows/test-android-device.yaml b/.github/workflows/test-android-device.yaml index e53ea4a75..f6660333a 100644 --- a/.github/workflows/test-android-device.yaml +++ b/.github/workflows/test-android-device.yaml @@ -7,11 +7,11 @@ on: jobs: run_tests: - name: Flutter ${{ matrix.flutter_version }} on ${{ matrix.os }} ${{ matrix.os_version }} + name: Flutter ${{ matrix.flutter-version }} on ${{ matrix.os }} ${{ matrix.os_version }} runs-on: ubuntu-latest timeout-minutes: 30 outputs: - SLACK_MESSAGE_TITLE: Flutter ${{ matrix.flutter_version }} on ${{ matrix.os }} ${{ matrix.os_version }} + SLACK_MESSAGE_TITLE: Flutter ${{ matrix.flutter-version }} on ${{ matrix.os }} ${{ matrix.os_version }} TESTS_EXIT_CODE: ${{ steps.tests_step.outputs.TESTS_EXIT_CODE }} EXCLUDED_TESTS: ${{ steps.set_excluded_tests.outputs.EXCLUDED_TESTS }} URL_TO_DETAILS: ${{ steps.tests_step.outputs.URL_TO_DETAILS }} @@ -19,7 +19,8 @@ jobs: strategy: fail-fast: false matrix: - flutter_version: ['3.13.x'] + flutter-version: ['3.17.0-5.0.pre.26'] + flutter-channel: ['master'] device_model: ['oriole'] os: ['Android API'] os_version: ['33'] @@ -54,7 +55,8 @@ jobs: - name: Set up Flutter uses: subosito/flutter-action@v2 with: - flutter-version: ${{ matrix.flutter_version }} + flutter-version: ${{ matrix.flutter-version }} + channel: ${{ matrix.flutter-channel }} - name: Preload Flutter artifacts run: flutter precache diff --git a/.github/workflows/test-android-emulator-webview.yaml b/.github/workflows/test-android-emulator-webview.yaml index f3e06d921..8b1fdeb79 100644 --- a/.github/workflows/test-android-emulator-webview.yaml +++ b/.github/workflows/test-android-emulator-webview.yaml @@ -7,18 +7,19 @@ on: jobs: run_tests: - name: Flutter ${{ matrix.flutter_version }} webview on emulator.wtf + name: Flutter ${{ matrix.flutter-version }} webview on emulator.wtf runs-on: ubuntu-latest timeout-minutes: 30 outputs: - SLACK_MESSAGE_TITLE: Flutter ${{ matrix.flutter_version }} webview on emulator.wtf + SLACK_MESSAGE_TITLE: Flutter ${{ matrix.flutter-version }} webview on emulator.wtf TESTS_EXIT_CODE: ${{ steps.tests_step.outputs.TESTS_EXIT_CODE }} URL_TO_DETAILS: ${{ steps.tests_step.outputs.URL_TO_DETAILS }} strategy: fail-fast: false matrix: - flutter_version: ['3.13.x'] + flutter-version: ['3.17.0-5.0.pre.26'] + flutter-channel: ['master'] defaults: run: @@ -42,7 +43,8 @@ jobs: - name: Set up Flutter uses: subosito/flutter-action@v2 with: - flutter-version: ${{ matrix.flutter_version }} + flutter-version: ${{ matrix.flutter-version }} + channel: ${{ matrix.flutter-channel }} - name: Preload Flutter artifacts run: flutter precache diff --git a/.github/workflows/test-android-emulator.yaml b/.github/workflows/test-android-emulator.yaml index d40fa265b..ae12461f5 100644 --- a/.github/workflows/test-android-emulator.yaml +++ b/.github/workflows/test-android-emulator.yaml @@ -7,11 +7,11 @@ on: jobs: run_tests: - name: Flutter ${{ matrix.flutter_version }} on emulator.wtf + name: Flutter ${{ matrix.flutter-version }} on emulator.wtf runs-on: ubuntu-latest timeout-minutes: 30 outputs: - SLACK_MESSAGE_TITLE: Flutter ${{ matrix.flutter_version }} on emulator.wtf + SLACK_MESSAGE_TITLE: Flutter ${{ matrix.flutter-version }} on emulator.wtf TESTS_EXIT_CODE: ${{ steps.tests_step.outputs.TESTS_EXIT_CODE }} EXCLUDED_TESTS: ${{ steps.set_excluded_tests.outputs.EXCLUDED_TESTS }} URL_TO_DETAILS: ${{ steps.tests_step.outputs.URL_TO_DETAILS }} @@ -19,7 +19,8 @@ jobs: strategy: fail-fast: false matrix: - flutter_version: ['3.13.x'] + flutter-version: ['3.17.0-5.0.pre.26'] + flutter-channel: ['master'] defaults: run: @@ -43,7 +44,8 @@ jobs: - name: Set up Flutter uses: subosito/flutter-action@v2 with: - flutter-version: ${{ matrix.flutter_version }} + flutter-version: ${{ matrix.flutter-version }} + channel: ${{ matrix.flutter-channel }} - name: Preload Flutter artifacts run: flutter precache diff --git a/.github/workflows/test-ios-device.yaml b/.github/workflows/test-ios-device.yaml index 09dcff662..d7f144e9a 100644 --- a/.github/workflows/test-ios-device.yaml +++ b/.github/workflows/test-ios-device.yaml @@ -7,11 +7,11 @@ on: jobs: run_tests: - name: Flutter ${{ matrix.flutter_version }} on ${{ matrix.device_model }} ${{ matrix.os }} ${{ matrix.os_version }} on FTL + name: Flutter ${{ matrix.flutter-version }} on ${{ matrix.device_model }} ${{ matrix.os }} ${{ matrix.os_version }} on FTL runs-on: macos-latest timeout-minutes: 40 outputs: - SLACK_MESSAGE_TITLE: Flutter ${{ matrix.flutter_version }} on ${{ matrix.os }} ${{ matrix.os_version }} + SLACK_MESSAGE_TITLE: Flutter ${{ matrix.flutter-version }} on ${{ matrix.os }} ${{ matrix.os_version }} TESTS_EXIT_CODE: ${{ steps.tests_step.outputs.TESTS_EXIT_CODE }} EXCLUDED_TESTS: ${{ steps.set_excluded_tests.outputs.EXCLUDED_TESTS }} URL_TO_DETAILS: ${{ steps.tests_step.outputs.URL_TO_DETAILS }} @@ -19,7 +19,8 @@ jobs: strategy: fail-fast: false matrix: - flutter_version: ['3.13.x'] + flutter-version: ['3.17.0-5.0.pre.26'] + flutter-channel: ['master'] device_model: ['iphone14pro'] os_version: ['16.6'] os: [iOS] @@ -69,7 +70,8 @@ jobs: - name: Set up Flutter uses: subosito/flutter-action@v2 with: - flutter-version: ${{ matrix.flutter_version }} + flutter-version: ${{ matrix.flutter-version }} + channel: ${{ matrix.flutter-channel }} - name: Preload Flutter artifacts run: flutter precache diff --git a/.github/workflows/test-ios-simulator-webview.yaml b/.github/workflows/test-ios-simulator-webview.yaml index dbbf59bb1..9275e1ff3 100644 --- a/.github/workflows/test-ios-simulator-webview.yaml +++ b/.github/workflows/test-ios-simulator-webview.yaml @@ -7,11 +7,11 @@ on: jobs: run_tests: - name: Flutter ${{ matrix.flutter_version }} webview on ${{ matrix.device_model }} (${{ matrix.os_version }}) simulator + name: Flutter ${{ matrix.flutter-version }} webview on ${{ matrix.device_model }} (${{ matrix.os_version }}) simulator runs-on: macos-latest timeout-minutes: 40 outputs: - SLACK_MESSAGE_TITLE: Flutter ${{ matrix.flutter_version }} on ${{ matrix.os }} ${{ matrix.os_version }} simulator + SLACK_MESSAGE_TITLE: Flutter ${{ matrix.flutter-version }} on ${{ matrix.os }} ${{ matrix.os_version }} simulator TESTS_EXIT_CODE: ${{ steps.tests_step.outputs.TESTS_EXIT_CODE }} FAILURE_STATUS: ${{ steps.status_step.outputs.FAILURE_STATUS }} ERROR_STATUS: ${{ steps.status_step.outputs.ERROR_STATUS }} @@ -19,7 +19,8 @@ jobs: strategy: fail-fast: false matrix: - flutter_version: ['3.13.x'] + flutter-version: ['3.17.0-5.0.pre.26'] + flutter-channel: ['master'] device_model: [iPhone 14] os: [iOS] os_version: ['16.2'] @@ -35,7 +36,8 @@ jobs: - name: Set up Flutter uses: subosito/flutter-action@v2 with: - flutter-version: ${{ matrix.flutter_version }} + flutter-version: ${{ matrix.flutter-version }} + channel: ${{ matrix.flutter-channel }} - name: Preload Flutter artifacts run: flutter precache diff --git a/.github/workflows/test-ios-simulator.yaml b/.github/workflows/test-ios-simulator.yaml index 556affeb0..8d2b50bdd 100644 --- a/.github/workflows/test-ios-simulator.yaml +++ b/.github/workflows/test-ios-simulator.yaml @@ -7,11 +7,11 @@ on: jobs: run_tests: - name: Flutter ${{ matrix.flutter_version }} on ${{ matrix.device_model }} (${{ matrix.os_version }}) simulator + name: Flutter ${{ matrix.flutter-version }} on ${{ matrix.device_model }} (${{ matrix.os_version }}) simulator runs-on: macos-latest timeout-minutes: 40 outputs: - SLACK_MESSAGE_TITLE: Flutter ${{ matrix.flutter_version }} on ${{ matrix.os }} ${{ matrix.os_version }} simulator + SLACK_MESSAGE_TITLE: Flutter ${{ matrix.flutter-version }} on ${{ matrix.os }} ${{ matrix.os_version }} simulator TESTS_EXIT_CODE: ${{ steps.tests_step.outputs.TESTS_EXIT_CODE }} FAILURE_STATUS: ${{ steps.status_step.outputs.FAILURE_STATUS }} ERROR_STATUS: ${{ steps.status_step.outputs.ERROR_STATUS }} @@ -20,7 +20,8 @@ jobs: strategy: fail-fast: false matrix: - flutter_version: ['3.13.x'] + flutter-version: ['3.17.0-5.0.pre.26'] + flutter-channel: ['master'] device_model: [iPhone 8, iPhone 14, iPad (9th generation)] os: [iOS] os_version: ['16.2'] @@ -36,7 +37,8 @@ jobs: - name: Set up Flutter uses: subosito/flutter-action@v2 with: - flutter-version: ${{ matrix.flutter_version }} + flutter-version: ${{ matrix.flutter-version }} + channel: ${{ matrix.flutter-channel }} - name: Preload Flutter artifacts run: flutter precache diff --git a/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/Automator.kt b/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/Automator.kt index 0e4fb8e3b..544602259 100644 --- a/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/Automator.kt +++ b/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/Automator.kt @@ -58,7 +58,7 @@ class Automator private constructor() { uiDevice = UiDevice.getInstance(instrumentation) } if (!this::uiAutomation.isInitialized) { - uiAutomation = instrumentation.uiAutomation; + uiAutomation = instrumentation.uiAutomation } } diff --git a/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/AutomatorServer.kt b/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/AutomatorServer.kt index e24e1dfee..c2edb6640 100644 --- a/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/AutomatorServer.kt +++ b/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/AutomatorServer.kt @@ -3,13 +3,13 @@ package pl.leancode.patrol import pl.leancode.patrol.contracts.Contracts.ConfigureRequest import pl.leancode.patrol.contracts.Contracts.DarkModeRequest import pl.leancode.patrol.contracts.Contracts.EnterTextRequest +import pl.leancode.patrol.contracts.Contracts.GetNativeUITreeRequest +import pl.leancode.patrol.contracts.Contracts.GetNativeUITreeRespone import pl.leancode.patrol.contracts.Contracts.GetNativeViewsRequest import pl.leancode.patrol.contracts.Contracts.GetNativeViewsResponse import pl.leancode.patrol.contracts.Contracts.GetNotificationsRequest import pl.leancode.patrol.contracts.Contracts.GetNotificationsResponse import pl.leancode.patrol.contracts.Contracts.HandlePermissionRequest -import pl.leancode.patrol.contracts.Contracts.GetNativeUITreeRespone -import pl.leancode.patrol.contracts.Contracts.GetNativeUITreeRequest import pl.leancode.patrol.contracts.Contracts.HandlePermissionRequestCode import pl.leancode.patrol.contracts.Contracts.OpenAppRequest import pl.leancode.patrol.contracts.Contracts.OpenQuickSettingsRequest diff --git a/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/UITreeUtils.kt b/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/UITreeUtils.kt index 928d77d26..f61da87f3 100644 --- a/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/UITreeUtils.kt +++ b/packages/patrol/android/src/main/kotlin/pl/leancode/patrol/UITreeUtils.kt @@ -27,8 +27,10 @@ private fun getWindowRoots(uiDevice: UiDevice, uiAutomation: UiAutomation): Arra } // Support multi-window searches for API level 21 and up. - val apiLevelActual = (Build.VERSION.SDK_INT - + if ("REL" == Build.VERSION.CODENAME) 0 else 1) + val apiLevelActual = ( + Build.VERSION.SDK_INT + + if ("REL" == Build.VERSION.CODENAME) 0 else 1 + ) if (apiLevelActual >= Build.VERSION_CODES.LOLLIPOP) { for (window in uiAutomation.windows) { val root = window.root @@ -61,4 +63,4 @@ private fun fromUiAccessibilityNodeInfo(obj: AccessibilityNodeInfo): NativeView applicationPackage = obj.packageName?.toString(), children = children ) -} \ No newline at end of file +} From 201997418a10a8655efcc585bcf6ea1930b61d9d Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Thu, 9 Nov 2023 15:19:17 +0100 Subject: [PATCH 2/5] `patrol_finders`: fix most failing tests --- .../patrol_finders/lib/src/custom_finders/patrol_finder.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/patrol_finders/lib/src/custom_finders/patrol_finder.dart b/packages/patrol_finders/lib/src/custom_finders/patrol_finder.dart index 2012a2787..65d7b590f 100644 --- a/packages/patrol_finders/lib/src/custom_finders/patrol_finder.dart +++ b/packages/patrol_finders/lib/src/custom_finders/patrol_finder.dart @@ -509,7 +509,7 @@ class PatrolFinder extends MatchFinder { String get description => finder.description; @override - String toString({bool describeSelf = true}) { + String toString({bool describeSelf = false}) { return finder.toString(describeSelf: describeSelf); } } From 08a11b6df057a33c02ff2d911b7e34d0d94c6b04 Mon Sep 17 00:00:00 2001 From: Mateusz Wojtczak Date: Fri, 10 Nov 2023 17:10:59 +0100 Subject: [PATCH 3/5] Fix naming of NativeView properties in the extension UI --- packages/patrol_devtools_extension/lib/api/contracts.dart | 2 ++ .../lib/native_inspector/native_view_details.dart | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/patrol_devtools_extension/lib/api/contracts.dart b/packages/patrol_devtools_extension/lib/api/contracts.dart index 6d058d781..6bd6bd882 100644 --- a/packages/patrol_devtools_extension/lib/api/contracts.dart +++ b/packages/patrol_devtools_extension/lib/api/contracts.dart @@ -300,7 +300,9 @@ class NativeView with EquatableMixin { final bool focused; final bool enabled; final int? childCount; + //TODO: rename to "resourceId" for consistency final String? resourceName; + //TODO: rename to "pkg" for consistency final String? applicationPackage; final List children; diff --git a/packages/patrol_devtools_extension/lib/native_inspector/native_view_details.dart b/packages/patrol_devtools_extension/lib/native_inspector/native_view_details.dart index 05433e741..4ced99338 100644 --- a/packages/patrol_devtools_extension/lib/native_inspector/native_view_details.dart +++ b/packages/patrol_devtools_extension/lib/native_inspector/native_view_details.dart @@ -102,13 +102,13 @@ class _NodeDetails extends HookWidget { final view = node.nativeView; final rows = [ - _KeyValueItem('applicationPackage:', view.applicationPackage), + _KeyValueItem('pkg:', view.applicationPackage), _KeyValueItem('childCount:', view.childCount), _KeyValueItem('className:', view.className), _KeyValueItem('contentDescription:', view.contentDescription), _KeyValueItem('enabled:', view.enabled), _KeyValueItem('focused:', view.focused), - _KeyValueItem('resourceName:', view.resourceName), + _KeyValueItem('resourceId:', view.resourceName), _KeyValueItem('text:', view.text), ]; From a0891717b809adb29c0173e37069f7624d70e563 Mon Sep 17 00:00:00 2001 From: Piotr Maszota <37781044+piotruela@users.noreply.github.com> Date: Mon, 13 Nov 2023 10:26:15 +0100 Subject: [PATCH 4/5] Remove concurrency from iOS code (#1891) * Remove concurrency from iOS code * Format Co-authored-by: Bartek Pacia Co-authored-by: Mateusz Wojtczak --- .../Classes/AutomatorServer/Automator.swift | 38 ++++++++++--------- .../AutomatorServer/AutomatorServer.swift | 10 ++--- .../AutomatorServer/ElementTypeUtils.swift | 15 ++++---- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/packages/patrol/ios/Classes/AutomatorServer/Automator.swift b/packages/patrol/ios/Classes/AutomatorServer/Automator.swift index d62def8cc..0dc94fa45 100644 --- a/packages/patrol/ios/Classes/AutomatorServer/Automator.swift +++ b/packages/patrol/ios/Classes/AutomatorServer/Automator.swift @@ -395,27 +395,27 @@ return views } } - - func getUITreeRoots(installedApps: [String]) async throws -> [NativeView] { - try await runAction("getting ui tree roots") { - let foregroundApp = self.getForegroundApp(installedApps: installedApps) - let snapshot = try foregroundApp.snapshot() - return [NativeView.fromXCUIElementSnapshot(snapshot, foregroundApp.identifier)] + + func getUITreeRoots(installedApps: [String]) throws -> [NativeView] { + try runAction("getting ui tree roots") { + let foregroundApp = self.getForegroundApp(installedApps: installedApps) + let snapshot = try foregroundApp.snapshot() + return [NativeView.fromXCUIElementSnapshot(snapshot, foregroundApp.identifier)] } } - + private func getForegroundApp(installedApps: [String]) -> XCUIApplication { let app = XCUIApplication() if app.state == .runningForeground { - return app + return app } else { - for bundleIdentifier in installedApps { - let app = XCUIApplication(bundleIdentifier: bundleIdentifier) - if app.state == .runningForeground { - return app - } + for bundleIdentifier in installedApps { + let app = XCUIApplication(bundleIdentifier: bundleIdentifier) + if app.state == .runningForeground { + return app } - return self.springboard + } + return self.springboard } } @@ -849,12 +849,14 @@ return NativeView.fromXCUIElement(child, bundleId) }) } - - static func fromXCUIElementSnapshot(_ xcuielement: XCUIElementSnapshot, _ bundleId: String) -> NativeView { + + static func fromXCUIElementSnapshot(_ xcuielement: XCUIElementSnapshot, _ bundleId: String) + -> NativeView + { return NativeView( className: getElementTypeName(elementType: xcuielement.elementType), text: xcuielement.label, - contentDescription: "", // TODO: Separate request + contentDescription: "", // TODO: Separate request focused: xcuielement.hasFocus, enabled: xcuielement.isEnabled, resourceName: xcuielement.identifier, @@ -863,6 +865,6 @@ return NativeView.fromXCUIElementSnapshot(child, bundleId) }) } -} + } #endif diff --git a/packages/patrol/ios/Classes/AutomatorServer/AutomatorServer.swift b/packages/patrol/ios/Classes/AutomatorServer/AutomatorServer.swift index 8127664af..e28e4b3a0 100644 --- a/packages/patrol/ios/Classes/AutomatorServer/AutomatorServer.swift +++ b/packages/patrol/ios/Classes/AutomatorServer/AutomatorServer.swift @@ -2,7 +2,7 @@ import Foundation -final class AutomatorServer: NativeAutomatorServer { + final class AutomatorServer: NativeAutomatorServer { private let automator: Automator private let onAppReady: (Bool) -> Void @@ -70,11 +70,11 @@ final class AutomatorServer: NativeAutomatorServer { return GetNativeViewsResponse(nativeViews: nativeViews) } } - - func getNativeUITree(request: GetNativeUITreeRequest) async throws -> GetNativeUITreeRespone { - let roots = try await automator.getUITreeRoots(installedApps: request.iosInstalledApps ?? []) - return GetNativeUITreeRespone(roots: roots) + func getNativeUITree(request: GetNativeUITreeRequest) throws -> GetNativeUITreeRespone { + let roots = try automator.getUITreeRoots(installedApps: request.iosInstalledApps ?? []) + + return GetNativeUITreeRespone(roots: roots) } func tap(request: TapRequest) throws { diff --git a/packages/patrol/ios/Classes/AutomatorServer/ElementTypeUtils.swift b/packages/patrol/ios/Classes/AutomatorServer/ElementTypeUtils.swift index 7dfc6aec9..ecfe11b68 100644 --- a/packages/patrol/ios/Classes/AutomatorServer/ElementTypeUtils.swift +++ b/packages/patrol/ios/Classes/AutomatorServer/ElementTypeUtils.swift @@ -1,9 +1,9 @@ #if PATROL_ENABLED -import Foundation -import XCTest + import Foundation + import XCTest -private let elementTypeNames = [ + private let elementTypeNames = [ XCUIElement.ElementType.any: "any", XCUIElement.ElementType.other: "other", XCUIElement.ElementType.application: "application", @@ -86,12 +86,11 @@ private let elementTypeNames = [ XCUIElement.ElementType.stepper: "stepper", XCUIElement.ElementType.tab: "tab", XCUIElement.ElementType.touchBar: "touchBar", - XCUIElement.ElementType.statusItem: "statusItem" -] - + XCUIElement.ElementType.statusItem: "statusItem", + ] -func getElementTypeName(elementType: XCUIElement.ElementType) -> String? { + func getElementTypeName(elementType: XCUIElement.ElementType) -> String? { return elementTypeNames[elementType] -} + } #endif From 5cf10a1996d9ac15eb382b7cb5920f9d81581b2e Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Mon, 13 Nov 2023 10:45:49 +0100 Subject: [PATCH 5/5] patrol-prepare: use Melos to fix `flutter test` crashing --- .github/workflows/patrol-prepare.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/patrol-prepare.yaml b/.github/workflows/patrol-prepare.yaml index c803506d4..95d856273 100644 --- a/.github/workflows/patrol-prepare.yaml +++ b/.github/workflows/patrol-prepare.yaml @@ -196,6 +196,12 @@ jobs: flutter-version: ${{ matrix.flutter-version }} channel: ${{ matrix.flutter-channel }} + - name: Set up Melos + run: dart pub global activate melos + + - name: Activate Melos workspace + run: cd ../.. && melos bootstrap + - name: flutter pub get run: flutter pub get