blob: 17e1380f30ea4bad2b94d15c8c4ad40940bdaf89 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
//
// DAITAPage.swift
// MullvadVPN
//
// Created by Jon Petersson on 2024-11-25.
// Copyright © 2025 Mullvad VPN AB. All rights reserved.
//
import XCTest
class DAITAPage: Page {
@discardableResult override init(_ app: XCUIApplication) {
super.init(app)
self.pageElement = app.otherElements[.daitaView]
waitForPageToBeShown()
}
@discardableResult func tapBackButton() -> Self {
// Workaround for setting accessibility identifier on navigation bar button being non-trivial
app.buttons.matching(identifier: "Settings").allElementsBoundByIndex.last?.tap()
return self
}
@discardableResult func tapEnableDirectOnlyDialogButtonIfPresent() -> Self {
let buttonElement = app.buttons[AccessibilityIdentifier.daitaConfirmAlertEnableButton]
if buttonElement.exists {
buttonElement.tap()
}
return self
}
@discardableResult func verifyTwoPages() -> Self {
XCTAssertEqual(app.pageIndicators.firstMatch.value as? String, "page 1 of 2")
return self
}
@discardableResult func tapEnableSwitch() -> Self {
app.switches[AccessibilityIdentifier.daitaSwitch].tap()
return self
}
@discardableResult func tapEnableSwitchIfOn() -> Self {
let switchElement = app.switches[AccessibilityIdentifier.daitaSwitch]
if switchElement.value as? String == "1" {
tapEnableSwitch()
}
return self
}
@discardableResult func tapEnableSwitchIfOff() -> Self {
let switchElement = app.switches[AccessibilityIdentifier.daitaSwitch]
if switchElement.value as? String == "0" {
tapEnableSwitch()
}
return self
}
@discardableResult func verifyDirectOnlySwitchIsEnabled() -> Self {
XCTAssertTrue(app.switches[AccessibilityIdentifier.daitaDirectOnlySwitch].isEnabled)
return self
}
@discardableResult func verifyDirectOnlySwitchIsDisabled() -> Self {
XCTAssertFalse(app.switches[AccessibilityIdentifier.daitaDirectOnlySwitch].isEnabled)
return self
}
@discardableResult func tapDirectOnlySwitch() -> Self {
app.switches[AccessibilityIdentifier.daitaDirectOnlySwitch].tap()
return self
}
@discardableResult func tapDirectOnlySwitchIfOn() -> Self {
let switchElement = app.switches[AccessibilityIdentifier.daitaDirectOnlySwitch]
if switchElement.value as? String == "1" {
tapDirectOnlySwitch()
}
return self
}
@discardableResult func tapDirectOnlySwitchIfOff() -> Self {
let switchElement = app.switches[AccessibilityIdentifier.daitaDirectOnlySwitch]
if switchElement.value as? String == "0" {
tapDirectOnlySwitch()
}
return self
}
@discardableResult func verifyDirectOnlySwitchOn() -> Self {
let switchElement = app.switches[AccessibilityIdentifier.daitaDirectOnlySwitch]
guard let switchValue = switchElement.value as? String else {
XCTFail("Failed to read switch state")
return self
}
XCTAssertEqual(switchValue, "1")
return self
}
}
|