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/ThemeTests.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@MainActor91final class ThemeTests: ORIXUITestCase {92 private let builtIn = ["orix.day", "orix.midnight", "orix.terrain", "orix.minimal", "orix.transit", "orix.topographic", "orix.explorer", "orix.highcontrast"]9394 func testEveryBuiltInThemeRenders() {95 launch(region: true)96 var captures: [Data] = []97 for id in builtIn {98 require(app.buttons["map.layers"]).tap()99 let button = require(app.buttons["theme.\(id)"], "theme \(id) is offered")100 button.tap()101 wait("theme \(id) is selected") { self.app.buttons["theme.\(id)"].isSelected }102 closeModal()103 require(map)104 sleep(2) // tiles are redrawn with the new style105 let shot = XCUIScreen.main.screenshot()106 let attachment = XCTAttachment(screenshot: shot)107 attachment.name = "docs-\(isPad ? "ipad" : "iphone")-theme-\(id.replacingOccurrences(of: "orix.", with: ""))"108 attachment.lifetime = .keepAlways109 add(attachment)110 captures.append(shot.pngRepresentation)111 XCTAssertEqual(app.state, .runningForeground)112 }113 // Each theme draws a different map: no two captures are identical.114 XCTAssertEqual(Set(captures).count, builtIn.count, "two themes produced the same picture")115 }116117 func testThemeNoticesForTerrainAndTransit() {118 launch(region: true)119 app.buttons["map.layers"].tap()120 require(app.buttons["theme.orix.terrain"]).tap()121 app.swipeUp()122 require(text(containing: "Relief shading and contour lines appear only in regions that include terrain data."))123 app.swipeDown()124 require(app.buttons["theme.orix.transit"]).tap()125 app.swipeUp()126 require(text(containing: "Transit shows the railways and stations present in the map data."))127 }128129 func testMapStudioDuplicateEditAndDeleteATheme() {130 launch(region: true)131 openMenu(.studio)132 require(app.navigationBars["Map Studio"])133 require(text(containing: "Duplicate a built-in theme to make your own"))134 require(app.buttons["studio.duplicate.orix.day"]).tap()135 let custom = require(element("studio.custom.ORIX Day copy"), "the copy appears under My themes")136 screenshot("studio-list")137 custom.tap()138139 // Edit: rename and switch a content option.140 require(app.navigationBars["ORIX Day copy"])141 let name = require(app.textFields.firstMatch)142 name.tap()143 name.typeText(" 2")144 let buildings = require(app.switches["Buildings"])145 XCTAssertEqual(buildings.value as? String, "1")146 buildings.switches.firstMatch.exists ? buildings.switches.firstMatch.tap() : buildings.tap()147 wait("the Buildings option is turned off") { (self.app.switches["Buildings"].value as? String) == "0" }148 require(app.navigationBars["ORIX Day copy 2"], "the title follows the new name")149 screenshot("studio-editor")150 app.navigationBars.buttons.firstMatch.tap()151 require(element("studio.custom.ORIX Day copy 2"), "the renamed theme is listed")152153 // The edited theme is the one drawn, and it is offered in the theme picker.154 closeModal()155 app.buttons["map.layers"].tap()156 require(app.buttons.containing(NSPredicate(format: "label == %@", "ORIX Day copy 2")).firstMatch)157 closeModal()158159 // Delete from the editor.160 openMenu(.studio)161 require(element("studio.custom.ORIX Day copy 2")).tap()162 scrollTo(app.buttons["Delete this theme"], maxSwipes: 30).tap()163 require(app.navigationBars["Map Studio"])164 waitGone(element("studio.custom.ORIX Day copy 2"))165 require(text(containing: "Duplicate a built-in theme to make your own"))166 }167168 func testImportingAnInvalidThemeFileShowsTheError() {169 launch(extra: ["-ORIXImportTheme", "invalid"])170 openMenu(.studio)171 require(app.alerts["Import failed"], "an invalid theme file is refused with an explanation")172 require(app.alerts.staticTexts["This file is not an ORIX Maps theme."])173 screenshot("studio-import-error")174 app.alerts.buttons["OK"].tap()175 require(text(containing: "Duplicate a built-in theme to make your own"), "nothing was imported")176 }177178 func testImportingAValidThemeFileAddsIt() {179 launch(extra: ["-ORIXImportTheme", "valid"])180 openMenu(.studio)181 require(element("studio.custom.Imported test theme"), "the imported theme is listed and selected")182 XCTAssertFalse(app.alerts.firstMatch.exists)183 }184}185