From 454970cd181bb99303d1f04a06dff7f12490439e 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 | 3 ++- .github/workflows/patrol_cli-prepare.yaml | 4 +++- .github/workflows/patrol_devtools_extension-prepare.yaml | 4 +++- .github/workflows/patrol_finders-prepare.yaml | 4 +++- .../src/main/kotlin/pl/leancode/patrol/Automator.kt | 2 +- .../src/main/kotlin/pl/leancode/patrol/AutomatorServer.kt | 4 ++-- .../src/main/kotlin/pl/leancode/patrol/UITreeUtils.kt | 8 +++++--- 7 files changed, 19 insertions(+), 10 deletions(-) diff --git a/.github/workflows/patrol-prepare.yaml b/.github/workflows/patrol-prepare.yaml index 6b669996d..c4ee92f95 100644 --- a/.github/workflows/patrol-prepare.yaml +++ b/.github/workflows/patrol-prepare.yaml @@ -27,7 +27,8 @@ jobs: - name: Set up Flutter uses: subosito/flutter-action@v2 with: - flutter-version: '3.13.x' + flutter-version: '3.17.0-5.0.pre.20' + channel: master - name: Set up Java uses: actions/setup-java@v3 diff --git a/.github/workflows/patrol_cli-prepare.yaml b/.github/workflows/patrol_cli-prepare.yaml index e5af71889..1d56dc4d4 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.20'] + 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..abb0ea0bc 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.20'] + 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..dfd92fafb 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.20'] + 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/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 309ed157e70fb2be738739b2366bf3dd10669a87 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 29c0246689df557922c9c649238e5a7b66b9c63c 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 920eae4eccc366815cbf21bbc91d7b6c011a2974 Mon Sep 17 00:00:00 2001 From: Piotr Maszota Date: Mon, 13 Nov 2023 08:32:49 +0100 Subject: [PATCH 4/5] Remove concurrency from iOS code --- packages/patrol/ios/Classes/AutomatorServer/Automator.swift | 4 ++-- .../patrol/ios/Classes/AutomatorServer/AutomatorServer.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/patrol/ios/Classes/AutomatorServer/Automator.swift b/packages/patrol/ios/Classes/AutomatorServer/Automator.swift index d62def8cc..92a501b68 100644 --- a/packages/patrol/ios/Classes/AutomatorServer/Automator.swift +++ b/packages/patrol/ios/Classes/AutomatorServer/Automator.swift @@ -396,8 +396,8 @@ } } - func getUITreeRoots(installedApps: [String]) async throws -> [NativeView] { - try await runAction("getting ui tree roots") { + 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)] diff --git a/packages/patrol/ios/Classes/AutomatorServer/AutomatorServer.swift b/packages/patrol/ios/Classes/AutomatorServer/AutomatorServer.swift index 8127664af..3575e64ea 100644 --- a/packages/patrol/ios/Classes/AutomatorServer/AutomatorServer.swift +++ b/packages/patrol/ios/Classes/AutomatorServer/AutomatorServer.swift @@ -71,8 +71,8 @@ final class AutomatorServer: NativeAutomatorServer { } } - func getNativeUITree(request: GetNativeUITreeRequest) async throws -> GetNativeUITreeRespone { - let roots = try await automator.getUITreeRoots(installedApps: request.iosInstalledApps ?? []) + func getNativeUITree(request: GetNativeUITreeRequest) throws -> GetNativeUITreeRespone { + let roots = try automator.getUITreeRoots(installedApps: request.iosInstalledApps ?? []) return GetNativeUITreeRespone(roots: roots) } From 084fafc7496fbbed27818a06a06b131807480e13 Mon Sep 17 00:00:00 2001 From: Piotr Maszota Date: Mon, 13 Nov 2023 09:31:31 +0100 Subject: [PATCH 5/5] Format --- .../Classes/AutomatorServer/Automator.swift | 34 ++++++++++--------- .../AutomatorServer/AutomatorServer.swift | 8 ++--- .../AutomatorServer/ElementTypeUtils.swift | 15 ++++---- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/packages/patrol/ios/Classes/AutomatorServer/Automator.swift b/packages/patrol/ios/Classes/AutomatorServer/Automator.swift index 92a501b68..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]) 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)] + 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 3575e64ea..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) throws -> GetNativeUITreeRespone { - let roots = try automator.getUITreeRoots(installedApps: request.iosInstalledApps ?? []) + let roots = try automator.getUITreeRoots(installedApps: request.iosInstalledApps ?? []) - return GetNativeUITreeRespone(roots: roots) + 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