Skip to content

Commit b54a6c3

Browse files
committed
Merge branch 'add-end-to-end-connection-tests-for-multihop-ios-778'
2 parents 65bdbb5 + 8b1e180 commit b54a6c3

File tree

7 files changed

+83
-25
lines changed

7 files changed

+83
-25
lines changed

ios/MullvadVPN.xcodeproj/project.pbxproj

-8
Original file line numberDiff line numberDiff line change
@@ -2361,13 +2361,6 @@
23612361
/* End PBXFrameworksBuildPhase section */
23622362

23632363
/* Begin PBXGroup section */
2364-
014449932CA1B55200C0C2F2 /* EncryptedDnsProxy */ = {
2365-
isa = PBXGroup;
2366-
children = (
2367-
);
2368-
path = EncryptedDnsProxy;
2369-
sourceTree = "<group>";
2370-
};
23712364
062B45A228FD4C0F00746E77 /* Assets */ = {
23722365
isa = PBXGroup;
23732366
children = (
@@ -4191,7 +4184,6 @@
41914184
F0DC77A02B2223290087F09D /* Transport */ = {
41924185
isa = PBXGroup;
41934186
children = (
4194-
014449932CA1B55200C0C2F2 /* EncryptedDnsProxy */,
41954187
F0164ED02B4F2DCB0020268D /* AccessMethodIterator.swift */,
41964188
F0DC77A32B2315800087F09D /* Direct */,
41974189
F0E5B2F62C9C689C0007F78C /* EncryptedDNS */,

ios/MullvadVPN/Classes/AccessbilityIdentifier.swift

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public enum AccessibilityIdentifier: String {
2121
case appLogsShareButton
2222
case applyButton
2323
case cancelButton
24-
case connectionPanelButton
2524
case continueWithLoginButton
2625
case collapseButton
2726
case expandButton

ios/MullvadVPN/View controllers/Tunnel/ConnectionPanelView.swift

+18-13
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,14 @@ class ConnectionPanelView: UIView {
4848
}
4949

5050
private let collapseView: ConnectionPanelCollapseView = {
51-
let button = ConnectionPanelCollapseView()
52-
button.translatesAutoresizingMaskIntoConstraints = false
53-
button.tintColor = .white
54-
return button
51+
let collapseView = ConnectionPanelCollapseView()
52+
collapseView.axis = .horizontal
53+
collapseView.alignment = .top
54+
collapseView.distribution = .fill
55+
collapseView.translatesAutoresizingMaskIntoConstraints = false
56+
collapseView.tintColor = .white
57+
collapseView.isAccessibilityElement = false
58+
return collapseView
5559
}()
5660

5761
private let inAddressRow = ConnectionPanelAddressRow()
@@ -294,24 +298,25 @@ class ConnectionPanelCollapseView: UIStackView {
294298
}()
295299

296300
private(set) var imageView: UIImageView = {
297-
return UIImageView()
301+
let imageView = UIImageView()
302+
imageView.contentMode = .scaleAspectFit
303+
return imageView
298304
}()
299305

300306
override init(frame: CGRect) {
301307
super.init(frame: frame)
302308

303-
let imageContainer = UIStackView()
304-
imageContainer.axis = .vertical
305-
imageContainer.addArrangedSubview(imageView)
306-
imageContainer.addArrangedSubview(UIView()) // Pushes content up.
307-
308309
addArrangedSubview(title)
309-
addArrangedSubview(imageContainer)
310+
addArrangedSubview(imageView)
311+
312+
title.setContentHuggingPriority(.defaultLow, for: .horizontal)
313+
title.setContentCompressionResistancePriority(.defaultLow, for: .horizontal)
314+
315+
imageView.setContentHuggingPriority(.defaultHigh, for: .horizontal)
316+
imageView.setContentCompressionResistancePriority(.defaultHigh, for: .horizontal)
310317
addArrangedSubview(UIView()) // Pushes content left.
311318

312319
updateImage()
313-
314-
accessibilityIdentifier = .connectionPanelButton
315320
}
316321

317322
required init(coder: NSCoder) {

ios/MullvadVPN/View controllers/Tunnel/TunnelControlView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ final class TunnelControlView: UIView {
4444
private let locationContainerView: UIStackView = {
4545
let view = UIStackView()
4646
view.translatesAutoresizingMaskIntoConstraints = false
47-
view.isAccessibilityElement = true
47+
view.isAccessibilityElement = false
4848
view.accessibilityTraits = .summaryElement
4949
view.axis = .vertical
5050
view.spacing = 8

ios/MullvadVPNUITests/Pages/TunnelControlPage.swift

+9-2
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ class TunnelControlPage: Page {
121121
}
122122

123123
@discardableResult func tapRelayStatusExpandCollapseButton() -> Self {
124-
app.buttons[AccessibilityIdentifier.relayStatusCollapseButton].tap()
124+
app.otherElements[AccessibilityIdentifier.relayStatusCollapseButton].press(forDuration: .leastNonzeroMagnitude)
125125
return self
126126
}
127127

@@ -202,6 +202,13 @@ class TunnelControlPage: Page {
202202
return self
203203
}
204204

205+
/// Verify that the app attempts to connect over Multihop.
206+
@discardableResult func verifyConnectingOverMultihop() -> Self {
207+
let relayName = getCurrentRelayName().lowercased()
208+
XCTAssertTrue(relayName.contains("via"))
209+
return self
210+
}
211+
205212
func getInIPAddressFromConnectionStatus() -> String {
206213
let inAddressRow = app.otherElements[AccessibilityIdentifier.connectionPanelInAddressRow]
207214

@@ -215,7 +222,7 @@ class TunnelControlPage: Page {
215222
}
216223

217224
func getCurrentRelayName() -> String {
218-
let relayExpandButton = app.buttons[.relayStatusCollapseButton]
225+
let relayExpandButton = app.otherElements[.relayStatusCollapseButton]
219226

220227
guard let relayName = relayExpandButton.value as? String else {
221228
XCTFail("Failed to read relay name from tunnel control page")

ios/MullvadVPNUITests/Pages/VPNSettingsPage.swift

+18
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,22 @@ class VPNSettingsPage: Page {
205205
XCTAssertEqual(switchValue, "1")
206206
return self
207207
}
208+
209+
@discardableResult func tapDaitaSwitchIfOn() -> Self {
210+
let switchElement = app.cells[.daitaSwitch].switches[AccessibilityIdentifier.customSwitch]
211+
212+
if switchElement.value as? String == "1" {
213+
tapDaitaSwitch()
214+
}
215+
return self
216+
}
217+
218+
@discardableResult func tapMultihopSwitchIfOn() -> Self {
219+
let switchElement = app.cells[.multihopSwitch].switches[AccessibilityIdentifier.customSwitch]
220+
221+
if switchElement.value as? String == "1" {
222+
tapMultihopSwitch()
223+
}
224+
return self
225+
}
208226
}

ios/MullvadVPNUITests/RelayTests.swift

+37
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,43 @@ class RelayTests: LoggedInWithTimeUITestCase {
245245
.tapDisconnectButton()
246246
}
247247

248+
func testMultihopSettings() throws {
249+
// Undo enabling Multihop in teardown
250+
addTeardownBlock {
251+
HeaderBar(self.app)
252+
.tapSettingsButton()
253+
254+
SettingsPage(self.app)
255+
.tapVPNSettingsCell()
256+
257+
VPNSettingsPage(self.app)
258+
.tapMultihopSwitchIfOn()
259+
}
260+
261+
HeaderBar(app)
262+
.tapSettingsButton()
263+
264+
SettingsPage(app)
265+
.tapVPNSettingsCell()
266+
267+
VPNSettingsPage(app)
268+
.tapMultihopSwitch()
269+
.tapBackButton()
270+
271+
SettingsPage(app)
272+
.tapDoneButton()
273+
274+
TunnelControlPage(app)
275+
.tapSecureConnectionButton()
276+
277+
allowAddVPNConfigurationsIfAsked()
278+
279+
TunnelControlPage(app)
280+
.waitForSecureConnectionLabel()
281+
.verifyConnectingOverMultihop()
282+
.tapDisconnectButton()
283+
}
284+
248285
/// Connect to a relay in the default country and city, get name and IP address of the relay the app successfully connects to. Assumes user is logged on and at tunnel control page.
249286
private func getDefaultRelayInfo() -> RelayInfo {
250287
TunnelControlPage(app)

0 commit comments

Comments
 (0)