Repository Public BSD-3-Clause
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : ORIX Maps9// File : Apps/ORIXMaps/Tests/ORIXMapsUITests/LocationDeniedTests.swift10// Module : ORIXMapsUITests11// Repository : https://git.spboucher.ai/orix-maps12// Created : 2026-11-2513// Last Modified : 2026-11-2514//15// =============================================================================16// AUTHOR & PROFESSIONAL AFFILIATION17// =============================================================================18//19// Author : Simon-Pierre Boucher20// Position : Professor of Finance21// Institution : Université du Québec en Outaouais (UQO)22// Department : Département des sciences administratives23// Organization : SP Boucher24//25// Website : https://spboucher.ai26// Git : https://git.spboucher.ai27//28// =============================================================================29// OFFICIAL CONTACT DIRECTORY30// =============================================================================31//32// General : info@spboucher.ai33// Professional : contact@spboucher.ai34// Direct : simon@spboucher.ai35// Research : research@spboucher.ai36// Development : dev@spboucher.ai37// Support : support@spboucher.ai38// Security/Admin : admin@spboucher.ai39// Notifications : notifications@spboucher.ai40//41// Preferred Contact: support@spboucher.ai42//43// =============================================================================44// COPYRIGHT & INTELLECTUAL PROPERTY45// =============================================================================46//47// Copyright (c) 202648// Simon-Pierre Boucher49//50// All rights reserved where applicable.51//52// This file is governed by the applicable project license,53// copyright notices, institutional agreements and relevant law.54//55// Unless expressly authorized by the applicable license or56// rights holder, copying, redistribution, sublicensing,57// publication and commercial exploitation are not permitted.58//59// Existing third-party rights and notices remain unaffected.60//61// =============================================================================62// CONFIDENTIALITY & SECURITY63// =============================================================================64//65// Classification : Public66// Distribution : Public repository; use is governed by the project license67// Security Contact : admin@spboucher.ai68//69// Access to this source does not independently grant permission70// to redistribute or disclose confidential materials.71//72// Do not embed credentials, private keys, access tokens,73// certificates or confidential personal information.74//75// =============================================================================76// LICENSE & MAINTENANCE77// =============================================================================78//79// License : Proprietary, all rights reserved (see license file)80// License File : LICENSE81// Maintainer : Simon-Pierre Boucher82// Technical Contact: dev@spboucher.ai83//84// =============================================================================85// END OF SP BOUCHER SOURCE HEADER86// =============================================================================8788import XCTest8990/// Position permission refused. scripts/uitest.sh revokes the permission before running this class91/// (`simctl privacy <udid> revoke location ai.spboucher.orix.maps`).92@MainActor93final class LocationDeniedTests: ORIXUITestCase {94 private func assertRunning(file: StaticString = #filePath, line: UInt = #line) {95 XCTAssertEqual(app.state, .runningForeground, "the application is still running", file: file, line: line)96 }9798 /// Fails with a clear message when the permission was not revoked before the run.99 private func requireDenied() {100 openMenu(.settings)101 scrollTo(element("settings.privacy")).tap()102 require(text(containing: "Refused"), "these tests need the position permission revoked — run them with scripts/uitest.sh")103 app.navigationBars.buttons.firstMatch.tap()104 closeModal()105 }106107 func testLocationButtonExplainsAndDoesNotLookActive() {108 launch(region: true)109 requireDenied()110 let button = require(app.buttons["map.location"])111 button.tap()112 require(text(containing: "Position access is off. Turn it on in Settings to see your position."), "the location button explains the refusal")113 XCTAssertFalse(button.isSelected, "the button must not look as if it were following a position")114 XCTAssertFalse(springboard.alerts.firstMatch.exists, "no system prompt once refused")115 screenshot("denied-location-button")116 assertRunning()117 }118119 func testDirectionsFromMyPositionExplain() {120 launch(region: true)121 search("Stade olympique")122 require(app.buttons.matching(identifier: "search.result").firstMatch).tap()123 require(app.buttons["place.directions"]).tap()124 require(app.staticTexts["My position"])125 require(element("directions.noposition.denied"), "the planner explains that the position is not available")126 require(text(containing: "Position access is off, so the route cannot start from your position."))127 XCTAssertFalse(app.buttons["directions.route.0"].exists)128 screenshot("denied-directions")129 assertRunning()130 }131132 func testCompassExplains() {133 launch(region: true)134 openMenu(.compass)135 require(app.staticTexts["Compass not available"])136 require(text(containing: "Position access is off. Turn it on in Settings to see coordinates, altitude and true north."))137 screenshot("denied-compass")138 closeModal()139 assertRunning()140 }141142 func testTrackRecordingExplains() {143 launch(region: true)144 openMenu(.tracks)145 require(app.buttons["tracks.record"]).tap()146 require(text(containing: "Position access is off: nothing can be recorded. Turn it on in Settings."))147 screenshot("denied-track-recording")148 // Stopping an empty recording says nothing was recorded.149 require(app.buttons["track.stop"]).tap()150 require(app.buttons["track.stop.confirm"].firstMatch).tap()151 require(text(containing: "Nothing recorded: the track had fewer than two points."))152 assertRunning()153 }154155 func testStartingRealGuidanceExplains() {156 launch(region: true, extra: ["-ORIXRouteFrom", Place.downtown, "-ORIXRouteTo", Place.olympicStadium])157 require(app.buttons["directions.route.0"], timeout: 60)158 app.swipeUp()159 require(app.buttons["directions.start"]).tap()160 require(text(containing: "Position access is off. Guidance cannot follow you; use the simulation or turn access on in Settings."))161 screenshot("denied-guidance")162 app.buttons["End"].firstMatch.tap()163 require(app.textFields["search.field"])164 assertRunning()165 }166167 func testPrivacyScreenShowsTheRefusal() {168 launch()169 openMenu(.settings)170 scrollTo(element("settings.privacy")).tap()171 require(text(containing: "Refused"))172 require(app.buttons["Open system settings"])173 }174}175