Skip to content

Commit

Permalink
Add quantum info to accessibility labels for connect{ing,ed} states
Browse files Browse the repository at this point in the history
  • Loading branch information
acb-mv committed May 6, 2024
1 parent 0d6de4c commit d0d8163
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 25 deletions.
64 changes: 42 additions & 22 deletions ios/MullvadVPN/TunnelManager/TunnelState+UI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ extension TunnelState {
)
}

// TODO: Is this the correct message here ?
case .negotiatingPostQuantumKey:
NSLocalizedString(
"TUNNEL_STATE_NEGOTIATING_KEY",
Expand All @@ -61,7 +60,7 @@ extension TunnelState {
case let .connected(_, isPostQuantum):
if isPostQuantum {
NSLocalizedString(
"TUNNEL_STATE_CONNECTED",
"TUNNEL_STATE_PQ_CONNECTED",
tableName: "Main",
value: "Quantum secure connection",
comment: ""
Expand Down Expand Up @@ -142,7 +141,6 @@ extension TunnelState {
comment: ""
)

// TODO: Is this correct ?
case .negotiatingPostQuantumKey:
NSLocalizedString(
"SWITCH_LOCATION_BUTTON_TITLE",
Expand All @@ -155,34 +153,56 @@ extension TunnelState {

var localizedAccessibilityLabel: String {
switch self {
case .connecting:
NSLocalizedString(
"TUNNEL_STATE_CONNECTING_ACCESSIBILITY_LABEL",
tableName: "Main",
value: "Creating secure connection",
comment: ""
)
case let .connecting(_, isPostQuantum):
if isPostQuantum {
NSLocalizedString(
"TUNNEL_STATE_PQ_CONNECTING_ACCESSIBILITY_LABEL",
tableName: "Main",
value: "Creating quantum secure connection",
comment: ""
)
} else {
NSLocalizedString(
"TUNNEL_STATE_CONNECTING_ACCESSIBILITY_LABEL",
tableName: "Main",
value: "Creating secure connection",
comment: ""
)
}

// TODO: Is this correct ?
case .negotiatingPostQuantumKey:
NSLocalizedString(
"TUNNEL_STATE_CONNECTING_ACCESSIBILITY_LABEL",
tableName: "Main",
value: "Creating secure connection",
value: "Creating quantum secure connection",
comment: ""
)

case let .connected(tunnelInfo, _):
String(
format: NSLocalizedString(
"TUNNEL_STATE_CONNECTED_ACCESSIBILITY_LABEL",
tableName: "Main",
value: "Secure connection. Connected to %@, %@",
comment: ""
),
tunnelInfo.location.city,
tunnelInfo.location.country
)
case let .connected(tunnelInfo, isPostQuantum):
if isPostQuantum {
String(
format: NSLocalizedString(
"TUNNEL_STATE_PQ_CONNECTED_ACCESSIBILITY_LABEL",
tableName: "Main",
value: "Quantum secure connection. Connected to %@, %@",
comment: ""
),
tunnelInfo.location.city,
tunnelInfo.location.country
)
} else {
String(
format: NSLocalizedString(
"TUNNEL_STATE_CONNECTED_ACCESSIBILITY_LABEL",
tableName: "Main",
value: "Secure connection. Connected to %@, %@",
comment: ""
),
tunnelInfo.location.city,
tunnelInfo.location.country
)
}

case .disconnected:
NSLocalizedString(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ final class TunnelStateTests: XCTestCase {
publicKey: Data()
),
hostname: "hostname-goes-here",
location: Location(country: "", countryCode: "", city: "", cityCode: "", latitude: 0, longitude: 0),
location: Location(country: "country", countryCode: "", city: "city", cityCode: "", latitude: 0, longitude: 0),
retryAttempts: 0
)

Expand Down Expand Up @@ -77,12 +77,12 @@ final class TunnelStateTests: XCTestCase {

func testLocalizedTitleForSecureLabel_Reconnecting() {
XCTAssertEqual(
TunnelState.connecting(nil, isPostQuantum: false).localizedTitleForSecureLabel,
TunnelState.reconnecting(arbitrarySelectedRelay, isPostQuantum: false).localizedTitleForSecureLabel,
"Creating secure connection"
)

XCTAssertEqual(
TunnelState.connecting(nil, isPostQuantum: true).localizedTitleForSecureLabel,
TunnelState.reconnecting(arbitrarySelectedRelay, isPostQuantum: true).localizedTitleForSecureLabel,
"Creating quantum secure connection"
)
}
Expand All @@ -98,4 +98,42 @@ final class TunnelStateTests: XCTestCase {
"Quantum secure connection"
)
}

// MARK: localizedAccessibilityLabel

func testLocalizedAccessibilityLabel_Connecting() {
XCTAssertEqual(
TunnelState.connecting(nil, isPostQuantum: false).localizedAccessibilityLabel,
"Creating secure connection"
)

XCTAssertEqual(
TunnelState.connecting(nil, isPostQuantum: true).localizedAccessibilityLabel,
"Creating quantum secure connection"
)
}

func testLocalizedAccessibilityLabel_Reconnecting() {
XCTAssertEqual(
TunnelState.reconnecting(arbitrarySelectedRelay, isPostQuantum: false).localizedAccessibilityLabel,
"Reconnecting to city, country"
)

XCTAssertEqual(
TunnelState.reconnecting(arbitrarySelectedRelay, isPostQuantum: true).localizedAccessibilityLabel,
"Reconnecting to city, country"
)
}

func testLocalizedAccessibilityLabel_Connected() {
XCTAssertEqual(
TunnelState.connected(arbitrarySelectedRelay, isPostQuantum: false).localizedAccessibilityLabel,
"Secure connection. Connected to city, country"
)

XCTAssertEqual(
TunnelState.connected(arbitrarySelectedRelay, isPostQuantum: true).localizedAccessibilityLabel,
"Quantum secure connection. Connected to city, country"
)
}
}

0 comments on commit d0d8163

Please sign in to comment.