Skip to content

Commit

Permalink
Preliminary changes for toolbar redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
dragosb01 committed Nov 12, 2024
1 parent 9dd918d commit 3ff22d3
Show file tree
Hide file tree
Showing 26 changed files with 163 additions and 186 deletions.
4 changes: 2 additions & 2 deletions firefox-ios/Client/Application/AccessibilityIdentifiers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public struct AccessibilityIdentifiers {
static let urlBarBorder = "TabToolbar.urlBarBorder"
static let settingsMenuButton = "TabToolbar.menuButton"
static let homeButton = "TabToolbar.homeButton"
static let trackingProtection = "TabLocationView.trackingProtectionButton"
static let trackingProtection = "AddressToolbar.lockIcon"
static let readerModeButton = "TabLocationView.readerModeButton"
static let reloadButton = "TabLocationView.reloadButton"
static let shareButton = "TabLocationView.shareButton"
Expand All @@ -44,7 +44,7 @@ public struct AccessibilityIdentifiers {
static let scanQRCodeButton = "urlBar-scanQRCode"
static let cancelButton = "urlBar-cancel"
static let searchTextField = "address"
static let url = "url"
static let url = "AddressToolbar.address"
}

struct KeyboardAccessory {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import XCTest
let page1 = "http://localhost:\(serverPort)/test-fixture/find-in-page-test.html"
let page2 = "http://localhost:\(serverPort)/test-fixture/test-example.html"
let serverPort = ProcessInfo.processInfo.environment["WEBSERVER_PORT"] ?? "\(Int.random(in: 1025..<65000))"
let urlBarAddress = XCUIApplication().textFields[AccessibilityIdentifiers.Browser.UrlBar.searchTextField]
let urlBarAddress = XCUIApplication().textFields[AccessibilityIdentifiers.Browser.UrlBar.url]

func path(forTestPage page: String) -> String {
return "http://localhost:\(serverPort)/test-fixture/\(page)"
Expand Down Expand Up @@ -270,8 +270,10 @@ class BaseTestCase: XCTestCase {

func checkBookmarksUpdated() {
waitForTabsButton()
let numberOfRecentlyVisitedBookmarks = app.scrollViews
let bookmarksCell = app.scrollViews
.cells[AccessibilityIdentifiers.FirefoxHomepage.Bookmarks.itemCell]
scrollToElement(bookmarksCell)
let numberOfRecentlyVisitedBookmarks = bookmarksCell
.otherElements
.otherElements
.otherElements
Expand Down Expand Up @@ -408,6 +410,7 @@ class BaseTestCase: XCTestCase {
let result = XCTWaiter().wait(for: [expectation], timeout: timeout)
XCTAssertEqual(result, .completed, "Element did not become hittable in time.")
}

func switchThemeToDarkOrLight(theme: String) {
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.settingsMenuButton])
navigator.nowAt(BrowserTab)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import Common

let PDF_website = [
"url": "https://storage.googleapis.com/mobile_test_assets/public/pdf-test.pdf",
"pdfValue": "storage.googleapis.com/mobile_test_assets/public/pdf-test.pdf",
"urlValue": "yukon.ca/en/education-and-schools",
"pdfValue": "storage.googleapis.com",
"urlValue": "yukon.ca",
"bookmarkLabel": "https://storage.googleapis.com/mobile_test_assets/public/pdf-test.pdf",
"longUrlValue": "http://www.education.gov.yk.ca/"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@ class ClipBoardTests: BaseTestCase {
// Check for test url in the browser
func checkUrl() {
let urlTextField = app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url]
mozWaitForValueContains(urlTextField, value: "www.example")
mozWaitForValueContains(urlTextField, value: "example.com")
}

// Copy url from the browser
func copyUrl() {
navigator.goto(URLBarOpen)
urlBarAddress.waitAndTap()
if iPad() {
urlBarAddress.press(forDuration: 1)
app.menuItems["Select All"].tap()
}
app.menuItems["Copy"].waitAndTap()
Expand Down Expand Up @@ -61,8 +60,8 @@ class ClipBoardTests: BaseTestCase {
navigator.nowAt(NewTabScreen)
navigator.goto(URLBarOpen)
urlBarAddress.press(forDuration: 3)
app.menuItems["Paste"].tap()
mozWaitForValueContains(urlBarAddress, value: "www.example.com")
app.otherElements["Paste"].tap()
mozWaitForValueContains(urlBarAddress, value: "http://www.example.com/")
}

// https://mozilla.testrail.io/index.php?/cases/view/2307051
Expand All @@ -81,7 +80,7 @@ class ClipBoardTests: BaseTestCase {
app.otherElements[AccessibilityIdentifiers.Photon.pasteAndGoAction].tap()
// The URL is pasted and the page is correctly loaded
mozWaitForElementToExist(urlBar)
waitForValueContains(urlBar, value: "test-example.html")
waitForValueContains(urlBar, value: "localhost")
mozWaitForElementToExist(app.staticTexts["Example Domain"])
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class DomainAutocompleteTests: BaseTestCase {

// Check that the address field is empty and that the home panels are shown
let value = urlBarAddress.value
XCTAssertEqual(value as? String, "", "The url has not been removed correctly")
XCTAssertEqual(value as? String, "Search or enter address", "The url has not been removed correctly")

mozWaitForElementToExist(app.cells[AccessibilityIdentifiers.FirefoxHomepage.TopSites.itemCell])
}
Expand All @@ -122,7 +122,7 @@ class DomainAutocompleteTests: BaseTestCase {
navigator.goto(URLBarOpen)
urlBarAddress.typeText("ex")
if #available(iOS 16, *) {
mozWaitForValueContains(app.otherElements.textFields["Address Bar"], value: "www.example.com/")
mozWaitForValueContains(urlBarAddress, value: "example.com")
let value = urlBarAddress.value
XCTAssertEqual(value as? String, "example.com", "Wrong autocompletion")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ func createScreenGraph(for test: XCTestCase, with app: XCUIApplication) -> MMScr
transitionTo: HomePanelsScreen
)
screenState.tap(
app.otherElements[StandardImageIdentifiers.Large.tab],
app.otherElements[StandardImageIdentifiers.Large.privateMode],
forAction: Action.OpenPrivateTabLongPressTabsButton,
transitionTo: NewTabScreen
) { userState in
Expand Down Expand Up @@ -960,7 +960,7 @@ func createScreenGraph(for test: XCTestCase, with app: XCUIApplication) -> MMScr
)

screenState.tap(
app.buttons[AccessibilityIdentifiers.Toolbar.homeButton],
app.buttons[AccessibilityIdentifiers.Toolbar.addNewTabButton],
forAction: Action.GoToHomePage
) { userState in
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ class HistoryTests: BaseTestCase {
urlBarForwardButton.press(forDuration: 1)
app.tables.staticTexts["The Book of Mozilla"].waitAndTap()
let url = app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url]
mozWaitForValueContains(url, value: "test-fixture/test-mozilla-book.html")
mozWaitForValueContains(url, value: "localhost")
}

// Private function created to select desired option from the "Clear Recent History" list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,30 @@ class HomeButtonTests: BaseTestCase {

// https://mozilla.testrail.io/index.php?/cases/view/2306925
func testGoHome() throws {
if iPad() {
waitForTabsButton()
navigator.nowAt(NewTabScreen)
}
navigator.openURL(path(forTestPage: "test-mozilla-org.html"), waitForLoading: true)
app.buttons[AccessibilityIdentifiers.Toolbar.homeButton].waitAndTap()
app.buttons[AccessibilityIdentifiers.Toolbar.addNewTabButton].waitAndTap()
navigator.nowAt(NewTabScreen)
waitForTabsButton()
XCTAssertEqual(app.buttons[AccessibilityIdentifiers.Toolbar.searchButton].label, "Search")
if iPad() {
navigator.nowAt(NewTabScreen)
if !iPad() {
XCTAssertEqual(app.buttons[AccessibilityIdentifiers.Toolbar.searchButton].label, "Search")
}
navigator.openURL(path(forTestPage: "test-mozilla-book.html"), waitForLoading: true)
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.homeButton])
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.addNewTabButton])

XCUIDevice.shared.orientation = .landscapeRight
XCTAssertTrue(app.buttons["Home"].exists)
app.buttons["Home"].tap()
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.addNewTabButton])
app.buttons[AccessibilityIdentifiers.Toolbar.addNewTabButton].tap()
navigator.nowAt(NewTabScreen)
}

// https://mozilla.testrail.io/index.php?/cases/view/2306883
func testSwitchHomepageKeyboardNotRaisedUp() {
func testSwitchHomepageKeyboardRaisedUp() {
// Open a new tab and load a web page
navigator.openURL("http://localhost:\(serverPort)/test-fixture/find-in-page-test.html")
waitUntilPageLoad()

// Switch to Homepage by taping the home button
app.buttons[AccessibilityIdentifiers.Toolbar.homeButton].waitAndTap()
app.buttons[AccessibilityIdentifiers.Toolbar.addNewTabButton].waitAndTap()

validateHomePageAndKeyboardNotRaisedUp()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class HomePageSettingsUITests: BaseTestCase {
waitUntilPageLoad()

// Now check open home page should load the previously saved home page
let homePageMenuItem = app.buttons[AccessibilityIdentifiers.Toolbar.homeButton]
let homePageMenuItem = app.buttons[AccessibilityIdentifiers.Toolbar.addNewTabButton]
homePageMenuItem.waitAndTap()
waitUntilPageLoad()
mozWaitForValueContains(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url], value: "example")
Expand Down Expand Up @@ -138,11 +138,16 @@ class HomePageSettingsUITests: BaseTestCase {
mozWaitForElementToExist(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url])

// Now after setting History, make sure FF home is set
app.buttons[AccessibilityIdentifiers.Browser.UrlBar.cancelButton].tap()
navigator.goto(SettingsScreen)
navigator.goto(NewTabSettings)
navigator.performAction(Action.SelectHomeAsFirefoxHomePage)
navigator.performAction(Action.GoToHomePage)
mozWaitForElementToExist(app.cells[AccessibilityIdentifiers.FirefoxHomepage.TopSites.itemCell])
if iPad() {
let homepage = AccessibilityIdentifiers.Settings.Homepage.self
mozWaitForElementToExist(app.cells[homepage.CustomizeFirefox.Shortcuts.settingsPage])
} else {
mozWaitForElementToExist(app.cells[AccessibilityIdentifiers.FirefoxHomepage.TopSites.itemCell])
}
}

// https://mozilla.testrail.io/index.php?/cases/view/2307031
Expand Down Expand Up @@ -258,8 +263,16 @@ class HomePageSettingsUITests: BaseTestCase {
// Preconditons: Create 6 bookmarks & add 1 items to reading list
bookmarkPages()
addContentToReaderView()
navigator.performAction(Action.GoToHomePage)
if iPad() {
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton])
app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].tap()
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.TabTray.newTabButton])
app.buttons[AccessibilityIdentifiers.TabTray.newTabButton].tap()
} else {
navigator.performAction(Action.GoToHomePage)
}
mozWaitForElementToExist(app.staticTexts["Bookmarks"])
app.buttons[AccessibilityIdentifiers.Browser.UrlBar.cancelButton].tap()
navigator.performAction(Action.ToggleRecentlySaved)
// On iPad we have the homepage button always present,
// on iPhone we have the search button instead when we're on a new tab page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,19 @@ class MultiWindowTests: IpadOnlyTestCase {
if skipPlatform { return }
splitViewFromHomeScreen()
// Access hamburger menu and tap on "new tab"
let menuButton = AccessibilityIdentifiers.Toolbar.settingsMenuButton
let newTab = StandardImageIdentifiers.Large.plus
let tabsButtonIdentifier = AccessibilityIdentifiers.Toolbar.tabsButton
let topSites = AccessibilityIdentifiers.FirefoxHomepage.TopSites.itemCell
let homeButtom = AccessibilityIdentifiers.Toolbar.homeButton
let homeButtom = AccessibilityIdentifiers.Toolbar.addNewTabButton
// A new tab is opened in the same window
app.collectionViews.cells.matching(identifier: topSites).firstMatch.waitAndTap()
mozWaitForElementToExist(app.buttons[homeButtom])
app.buttons.matching(identifier: menuButton).element(boundBy: 0).tap()
mozWaitForElementToExist(app.tables.otherElements[newTab])
app.tables.otherElements[newTab].tap()
app.buttons[AccessibilityIdentifiers.Browser.UrlBar.cancelButton].tap()
app.buttons[homeButtom].firstMatch.tap()
app.buttons[AccessibilityIdentifiers.Browser.UrlBar.cancelButton].firstMatch.tap()
let tabButtonSecondWindow = app.buttons.matching(identifier: tabsButtonIdentifier).element(boundBy: 0)
XCTAssertEqual(tabButtonSecondWindow.value as! String, "2", "Number of tabs opened should be equal to 2")
// A new tab is opened in the same window
app.collectionViews.cells.matching(identifier: topSites).element(boundBy: 6).waitAndTap()
mozWaitForElementToExist(app.buttons[homeButtom])
app.buttons.matching(identifier: menuButton).element(boundBy: 1).tap()
app.tables.otherElements[newTab].tap()
app.buttons[AccessibilityIdentifiers.Browser.UrlBar.cancelButton].tap()
app.buttons[homeButtom].firstMatch.tap()
app.buttons[AccessibilityIdentifiers.Browser.UrlBar.cancelButton].firstMatch.tap()
let tabButtonFirstWindow = app.buttons.matching(identifier: tabsButtonIdentifier).element(boundBy: 1)
XCTAssertEqual(tabButtonFirstWindow.value as! String, "2", "Number of tabs opened should be equal to 2")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@ class NavigationTest: BaseTestCase {
navigator.openURL(path(forTestPage: "test-example.html"))
waitUntilPageLoad()
let url = app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url]
mozWaitForValueContains(url, value: "test-example.html")
mozWaitForValueContains(url, value: "localhost")
XCTAssertTrue(app.buttons[AccessibilityIdentifiers.Toolbar.backButton].isEnabled)
XCTAssertFalse(app.buttons[AccessibilityIdentifiers.Toolbar.forwardButton].isEnabled)

// Once a second url is open, back button is enabled but not the forward one till we go back to url_1
navigator.openURL(path(forTestPage: "test-mozilla-org.html"))
waitUntilPageLoad()
mozWaitForValueContains(url, value: "test-mozilla-org.html")
mozWaitForValueContains(url, value: "localhost")
XCTAssertTrue(app.buttons[AccessibilityIdentifiers.Toolbar.backButton].isEnabled)
XCTAssertFalse(app.buttons[AccessibilityIdentifiers.Toolbar.forwardButton].isEnabled)
// Go back to previous visited web site
app.buttons[AccessibilityIdentifiers.Toolbar.backButton].tap()

waitUntilPageLoad()
mozWaitForValueContains(url, value: "test-example.html")
mozWaitForValueContains(url, value: "localhost")

if iPad() {
app.buttons[AccessibilityIdentifiers.Toolbar.forwardButton].tap()
Expand All @@ -64,7 +64,7 @@ class NavigationTest: BaseTestCase {
app.buttons[AccessibilityIdentifiers.Toolbar.forwardButton].waitAndTap()
}
waitUntilPageLoad()
mozWaitForValueContains(url, value: "test-mozilla-org")
mozWaitForValueContains(url, value: "localhost")
}

// https://mozilla.testrail.io/index.php?/cases/view/2441489
Expand Down Expand Up @@ -446,7 +446,7 @@ class NavigationTest: BaseTestCase {
XCTAssert(app.keyboards.count > 0, "The keyboard is not shown")
app.typeText("example.com\n")

mozWaitForValueContains(urlBar, value: "example.com/")
mozWaitForValueContains(urlBar, value: "example.com")
XCTAssertFalse(app.keyboards.count > 0, "The keyboard is shown")
// swiftlint:enable empty_count
}
Expand Down Expand Up @@ -517,7 +517,7 @@ class NavigationTest: BaseTestCase {
waitUntilPageLoad()
if #available(iOS 16, *) {
let url = app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url]
mozWaitForValueContains(url, value: "test-example.html")
mozWaitForValueContains(url, value: "localhost")
XCTAssertTrue(backButton.isHittable, "Back button is not hittable")
XCTAssertTrue(backButton.isEnabled, "Back button is disabled")
backButton.tap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,24 +191,26 @@ class OnboardingTests: BaseTestCase {
navigator.goto(BrowserTabMenu)
navigator.performAction(Action.OpenWhatsNewPage)
waitUntilPageLoad()
app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url].tap()

// Extract version number from url
let url = app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url].value
let textUrl = String(describing: url)
let start = textUrl.index(textUrl.startIndex, offsetBy: 43)
let end = textUrl.index(textUrl.startIndex, offsetBy: 48)
let start = textUrl.index(textUrl.startIndex, offsetBy: 51)
let end = textUrl.index(textUrl.startIndex, offsetBy: 56)
let range = start..<end
let mySubstring = textUrl[range]
let releaseVersion = String(mySubstring)

mozWaitForElementToExist(app.staticTexts[releaseVersion])
mozWaitForValueContains(
app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url],
value: "www.mozilla.org/en-US/firefox/ios/" + releaseVersion + "/releasenotes/"
value: "https://www.mozilla.org/en-US/firefox/ios/" + releaseVersion + "/releasenotes/"
)
mozWaitForElementToExist(app.staticTexts["Release Notes"])
app.buttons[AccessibilityIdentifiers.Browser.UrlBar.cancelButton].tap()
waitForElementsToExist(
[
app.staticTexts["Release Notes"],
app.staticTexts["Firefox for iOS Release"],
app.staticTexts["\(releaseVersion)"],
app.staticTexts["Get the most recent version"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class OpeningScreenTests: BaseTestCase {
closeFromAppSwitcherAndRelaunch()
// After re-launching the app, the last visited page is displayed
let url = app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url]
mozWaitForValueContains(url, value: "test-mozilla-org")
mozWaitForValueContains(url, value: "localhost")
// Background and restore Firefox
restartInBackground()
// After re-launching the app, the last visited page is displayed
mozWaitForValueContains(url, value: "test-mozilla-org")
mozWaitForValueContains(url, value: "localhost")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,6 @@ class PhotonActionSheetTests: BaseTestCase {
// User is back to the BrowserTab where the sharesheet was launched
let url = app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url]
mozWaitForElementToExist(url)
mozWaitForValueContains(url, value: "example.com/")
mozWaitForValueContains(url, value: "example.com")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PrivateBrowsingTest: BaseTestCase {
navigator.toggleOn(userState.isPrivate, withAction: Action.TogglePrivateMode)

navigator.openURL(url2)
mozWaitForValueContains(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url], value: "mozilla")
mozWaitForValueContains(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url], value: "localhost")
navigator.goto(LibraryPanel_History)
waitForElementsToExist(
[
Expand Down Expand Up @@ -76,7 +76,7 @@ class PrivateBrowsingTest: BaseTestCase {
waitUntilPageLoad()
navigator.openURL(url3)
let url = app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url]
mozWaitForValueContains(url, value: "test-example")
mozWaitForValueContains(url, value: "localhost")
navigator.nowAt(NewTabScreen)
waitForTabsButton()
navigator.goto(TabTray)
Expand Down
Loading

0 comments on commit 3ff22d3

Please sign in to comment.