Skip to content

Commit

Permalink
Fix test for iPad and check status before reload protection
Browse files Browse the repository at this point in the history
  • Loading branch information
mdotb-moz committed Sep 25, 2024
1 parent db12be5 commit 6742ec4
Showing 1 changed file with 47 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,27 @@ class TrackingProtectionTests: BaseTestCase {
)
}
app.otherElements.element(matching: .any, identifier: reloadWithWithoutProtectionButton).tap()
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.trackingProtection], timeout: 5)
}

private func enableStrictMode() {
navigator.performAction(Action.EnableStrictMode)
app.buttons[buttonSettings].tap()
app.buttons[buttonDone].tap()
}

func checkTrackingProtectionOn() -> Bool {
var trackingProtection = true
if iPad() {
sleep(1)
}
if app.buttons[AccessibilityIdentifiers.Toolbar.trackingProtection].label
== secureTrackingProtectionOffLabel {
trackingProtection = false
}
return trackingProtection
}

// https://mozilla.testrail.io/index.php?/cases/view/2307059
// Smoketest
func testStandardProtectionLevel() {
Expand Down Expand Up @@ -229,24 +243,38 @@ class TrackingProtectionTests: BaseTestCase {
navigator.nowAt(BrowserTab)
navigator.openURL(trackingProtectionTestUrl)

// Check Tracking Protection On
XCTAssertEqual(
app.buttons[AccessibilityIdentifiers.Toolbar.trackingProtection].label,
secureTrackingProtectionOnLabel
)

reloadWithWithoutTrackingProtection(label: "Without Tracking Protection")

XCTAssertEqual(
app.buttons[AccessibilityIdentifiers.Toolbar.trackingProtection].label,
secureTrackingProtectionOffLabel
)

reloadWithWithoutTrackingProtection(label: "With Tracking Protection")

XCTAssertEqual(
app.buttons[AccessibilityIdentifiers.Toolbar.trackingProtection].label,
secureTrackingProtectionOnLabel
)
if checkTrackingProtectionOn() {
XCTAssertEqual(
app.buttons[AccessibilityIdentifiers.Toolbar.trackingProtection].label,
secureTrackingProtectionOnLabel
)
navigator.nowAt(BrowserTab)
reloadWithWithoutTrackingProtection(label: "Without Tracking Protection")
XCTAssertEqual(
app.buttons[AccessibilityIdentifiers.Toolbar.trackingProtection].label,
secureTrackingProtectionOffLabel
)
reloadWithWithoutTrackingProtection(label: "With Tracking Protection")
XCTAssertEqual(
app.buttons[AccessibilityIdentifiers.Toolbar.trackingProtection].label,
secureTrackingProtectionOnLabel
)
} else {
XCTAssertEqual(
app.buttons[AccessibilityIdentifiers.Toolbar.trackingProtection].label,
secureTrackingProtectionOffLabel
)
navigator.nowAt(BrowserTab)
reloadWithWithoutTrackingProtection(label: "With Tracking Protection")
XCTAssertEqual(
app.buttons[AccessibilityIdentifiers.Toolbar.trackingProtection].label,
secureTrackingProtectionOnLabel
)
reloadWithWithoutTrackingProtection(label: "Without Tracking Protection")
XCTAssertEqual(
app.buttons[AccessibilityIdentifiers.Toolbar.trackingProtection].label,
secureTrackingProtectionOffLabel
)
}
}
}

0 comments on commit 6742ec4

Please sign in to comment.