Skip to content

Commit

Permalink
Merge pull request #2302 from leancodepl/noThrowOnSelectFineLocation
Browse files Browse the repository at this point in the history
No throw error on select already selected location
  • Loading branch information
pdenert authored Aug 27, 2024
2 parents bbbc126 + fe36e33 commit 9db9449
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/patrol/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 3.11.0
## Unreleased

- No throw error in `selectFineLocation` when it's already selected. (#2302)
- Add Option to select tap Location in enterText and enterTextByIndex (#2312)

## 3.10.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,11 @@
return
}

if isFineLocationEnabled() {
Logger.shared.i("Fine location is already enabled")
return
}

try runAction("selecting fine location") {
let alerts = self.springboard.alerts
let button = alerts.buttons["Precise: Off"]
Expand All @@ -807,12 +812,30 @@
}
}

func isFineLocationEnabled() -> Bool {
if iOS13orOlder() {
Logger.shared.i("Ignored call to isFineLocationEnabled() (iOS < 14)")
return false
}

let alerts = self.springboard.alerts
let button = alerts.buttons["Precise: On"]
let exists = button.waitForExistence(timeout: self.timeout)

return exists
}

func selectCoarseLocation() throws {
if iOS13orOlder() {
Logger.shared.i("Ignored call to selectCoarseLocation() (iOS < 14)")
return
}

if !isFineLocationEnabled() {
Logger.shared.i("Coarse location is already enabled")
return
}

try runAction("selecting coarse location") {
let alerts = self.springboard.alerts
let button = alerts.buttons["Precise: On"]
Expand Down

0 comments on commit 9db9449

Please sign in to comment.