Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

selectFineLocation throws on iOS if it's already selected #2171

Open
mvarendorff opened this issue Apr 2, 2024 · 2 comments
Open

selectFineLocation throws on iOS if it's already selected #2171

mvarendorff opened this issue Apr 2, 2024 · 2 comments
Labels
good first issue Good for newcomers package: patrol Related to the patrol package (native automation, test bundling) platform: ios iOS is affected

Comments

@mvarendorff
Copy link
Contributor

mvarendorff commented Apr 2, 2024

Steps to reproduce

  1. Write a test that uses $.native.selectFineLocation() (on an app that actually triggers the permission dialog)
  2. Note that the docs for selectFineLocation state "Throws if no permission request dialog is present."
  3. Run the test

Actual results

  1. The permission dialog shows up
  2. "Precise: On" is already set (by default?)
  3. Because the function only looks for a button with text "Precise: Off" to toggle it, it throws after timeout :(

Logs

Logs

Parts have been skipped for brevity; the relevant part is still included

Patrol (native): configure() succeeded
        Patrol (native): isPermissionDialogVisible() started
        2024-04-02 18:36:22.733331+0200 RunnerUITests-Runner[28268:3151778] PatrolServer: INFO: checking if permission dialog is visible...
            t =      nans Checking existence of `"OK" Button`
            t =      nans Checking existence of `"Allow" Button`
            t =      nans Checking existence of `"Allow once" Button`
            t =      nans Checking existence of `"Allow While Using App" Button`
            t =      nans Checking existence of `"Don’t Allow" Button`
        2024-04-02 18:36:23.829000+0200 RunnerUITests-Runner[28268:3151778] PatrolServer: INFO: done checking if permission dialog is visible
        2024-04-02 18:36:23.830221+0200 RunnerUITests-Runner[28268:3151778] PatrolServer: INFO: result: false
        Patrol (native): isPermissionDialogVisible() succeeded
        Patrol (native): selectFineLocation() started
        2024-04-02 18:36:23.838985+0200 RunnerUITests-Runner[28268:3151778] PatrolServer: INFO: selecting fine location...
            t =      nans Waiting 10.0s for "Precise: Off" Button to exist
            t =      nans     Checking `Expect predicate `exists == 1` for object "Precise: Off" Button`
            t =      nans         Checking existence of `"Precise: Off" Button`
            t =      nans         Capturing element debug description
            t =      nans     Checking `Expect predicate `exists == 1` for object "Precise: Off" Button`
            t =      nans         Checking existence of `"Precise: Off" Button`
            t =      nans         Capturing element debug description
            t =      nans     Checking `Expect predicate `exists == 1` for object "Precise: Off" Button`
            t =      nans         Checking existence of `"Precise: Off" Button`
            t =      nans         Capturing element debug description
            t =      nans     Checking `Expect predicate `exists == 1` for object "Precise: Off" Button`
            t =      nans         Checking existence of `"Precise: Off" Button`
            t =      nans         Capturing element debug description
            t =      nans     Checking `Expect predicate `exists == 1` for object "Precise: Off" Button`
            t =      nans         Checking existence of `"Precise: Off" Button`
            t =      nans         Capturing element debug description
            t =      nans     Checking `Expect predicate `exists == 1` for object "Precise: Off" Button`
            t =      nans         Checking existence of `"Precise: Off" Button`
            t =      nans         Capturing element debug description
        : Syncing files to device iPhone 15 Pro...                            8.8s
        : 
Hot Restart: attached to the app (press "r" to restart)
        : Flutter run key commands.
        : r Hot reload. 🔥🔥🔥
        : R Hot restart.
        : h List all available interactive commands.
        : d Detach (terminate "flutter run" but leave application running).
        : c Clear the screen
        : q Quit (terminate the application on the device).
        : 
        : A Dart VM Service on iPhone 15 Pro is available at: http://127.0.0.1:58088/4tj4ehFMtZU=/
Patrol DevTools extension is available at http://127.0.0.1:9100/patrol_ext?uri=http://127.0.0.1:58088/4tj4ehFMtZU=/
        : The Flutter DevTools debugger and profiler on iPhone 15 Pro is available at: http://127.0.0.1:9100?uri=http://127.0.0.1:58088/4tj4ehFMtZU=/
            t =      nans     Checking `Expect predicate `exists == 1` for object "Precise: Off" Button`
            t =      nans         Checking existence of `"Precise: Off" Button`
            t =      nans         Capturing element debug description
            t =      nans     Checking `Expect predicate `exists == 1` for object "Precise: Off" Button`
            t =      nans         Checking existence of `"Precise: Off" Button`
            t =      nans         Capturing element debug description
            t =      nans     Checking `Expect predicate `exists == 1` for object "Precise: Off" Button`
            t =      nans         Checking existence of `"Precise: Off" Button`
            t =      nans         Capturing element debug description
            t =      nans     Checking `Expect predicate `exists == 1` for object "Precise: Off" Button`
            t =      nans         Checking existence of `"Precise: Off" Button`
            t =      nans         Capturing element debug description
            t =      nans Checking existence of `"Precise: Off" Button`
            t =      nans Capturing debug information
            t =      nans     Requesting snapshot of accessibility hierarchy for app with pid 18251
        2024-04-02 18:36:33.947904+0200 RunnerUITests-Runner[28268:3151843] PatrolServer: ERROR: button to select fine location doesn't exist
        Patrol (native): selectFineLocation() failed
        ══╡ EXCEPTION CAUGHT BY FLUTTER TEST FRAMEWORK ╞════════════════════════════════════════════════════
        The following PatrolActionException was thrown running a test:
        Patrol action failed: NativeAutomatorClientException: selectFineLocation() failed with Invalid
        response: 400 The operation couldnât be completed. (patrol.PatrolError error 0.)
        flutter:
        When the exception was thrown, this was the stack:
        #0      NativeAutomator._wrapRequest (package:patrol/src/native/native_automator.dart:226:7)
        <asynchronous suspension>
        #1      NativeAutomator.selectFineLocation (package:patrol/src/native/native_automator.dart:838:5)
        <asynchronous suspension>
        #2      main.<anonymous closure> (file:///Volumes/external/projects/kommunalapp/app/integration_test/maengel_melder_test.dart:39:7)
        <asynchronous suspension>
        #3      patrolTest.<anonymous closure> (package:patrol/src/common.dart:134:7)
        <asynchronous suspension>
        #4      testWidgets.<anonymous closure>.<anonymous closure> (package:flutter_test/src/widget_tester.dart:183:15)
        <asynchronous suspension>
        #5      TestWidgetsFlutterBinding._runTestBody (package:flutter_test/src/binding.dart:1017:5)
        <asynchronous suspension>
        #6      TestWidgetsFlutterBinding._createTestCompletionHandler.<anonymous closure> (package:flutter_test/src/binding.dart:808:12)
        <asynchronous suspension>

Patrol version

patrol: ^3.6.0

Patrol Doctor output

Patrol Doctor output
Patrol doctor:
Patrol CLI version: 2.7.0
Flutter command: fvm flutter
  Flutter 3.19.1 • channel stable
Android: 
• Program adb not found (install with `export PATH="$ANDROID_HOME/platform-tools:$PATH"`)
• Env var $ANDROID_HOME is not set. (See the link: https://developer.android.com/tools/variables#set)
iOS / macOS: 
• Program xcodebuild found in /usr/bin/xcodebuild
• Program ideviceinstaller not found (install with `brew install ideviceinstaller`)

Flutter Doctor output

Flutter Doctor output
[✓] Flutter (Channel stable, 3.19.1, on macOS 14.4.1 23E224 darwin-arm64, locale en-DE)
    • Flutter version 3.19.1 on channel stable at /Users/thorstenthiel/fvm/versions/3.19.1
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision abb292a07e (6 weeks ago), 2024-02-20 14:35:05 -0800
    • Engine revision 04817c99c9
    • Dart version 3.3.0
    • DevTools version 2.31.1

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15C500b
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).

[✓] VS Code (version 1.87.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.84.0

[✓] Connected device (3 available)
    • iPhone 15 Pro (mobile) • 90B2D2DB-CF8F-4810-9FC5-E8009839343D • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-2 (simulator)
    • macOS (desktop)        • macos                                • darwin-arm64   • macOS 14.4.1 23E224 darwin-arm64
    • Chrome (web)           • chrome                               • web-javascript • Google Chrome 123.0.6312.87

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 2 categories.
@mvarendorff
Copy link
Contributor Author

Fwiw, a workaround for the time being is to just wrap a try/catch around the call but it would feel a lot safer if the function more generally "ensured" the setting instead of trying to set it and fail if it's already good to go.

For the record: The same issue (albeit with "On" instead of "Off") is also present for selectCoarseLocation.

@piotruela
Copy link
Collaborator

piotruela commented Apr 3, 2024

Thanks for reporting that. Using the enableWiFi method as an example of expected behaviour, we should log 'fine location already selected' instead of throwing an exception. And 'coarse location already selected' for the selectCoarseLocation method.

@piotruela piotruela added good first issue Good for newcomers package: patrol Related to the patrol package (native automation, test bundling) platform: ios iOS is affected labels Apr 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers package: patrol Related to the patrol package (native automation, test bundling) platform: ios iOS is affected
Projects
None yet
Development

No branches or pull requests

2 participants