Skip to content

Commit

Permalink
Bugfix FXIOS-10780 - [Toolbar design][Accessibility] Accessible name …
Browse files Browse the repository at this point in the history
…of tabs icon button should match annotations (mozilla-mobile#23531)

* Add a11y label for toolbar redesign tabs button

* Change key version

* Automation tests updates

---------

Co-authored-by: dragosb01 <[email protected]>
  • Loading branch information
PARAIPAN9 and dragosb01 authored Dec 11, 2024
1 parent b07583b commit bc1a8c1
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 39 deletions.
7 changes: 7 additions & 0 deletions BrowserKit/Sources/Shared/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6704,6 +6704,13 @@ extension String {
tableName: "Toolbar",
value: "New Tab",
comment: "Accessibility label for the new tab button that can be displayed in the navigation or address toolbar.")

public static let TabsButtonAccessibilityLabel = MZLocalizedString(
key: "Toolbar.Tabs.Button.A11y.Label.v135",
tableName: "Toolbar",
value: "Tabs open",
comment: "Accessibility label for the tabs button in the toolbar, specifing the number of tabs open.")

public struct TabToolbarLongPressActionsMenu {
public static let CloseThisTabButton = MZLocalizedString(
key: "Toolbar.Tab.CloseThisTab.Button.v130",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ struct AddressBarState: StateType, Equatable {
maskImageName: isPrivateMode ? ImageIdentifiers.badgeMask : nil,
numberOfTabs: numberOfTabs,
isEnabled: true,
a11yLabel: .TabsButtonShowTabsAccessibilityLabel,
a11yLabel: .Toolbars.TabsButtonAccessibilityLabel,
a11yId: AccessibilityIdentifiers.Toolbar.tabsButton)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ struct NavigationBarState: StateType, Equatable {
maskImageName: isPrivateMode ? ImageIdentifiers.badgeMask : nil,
numberOfTabs: numberOfTabs,
isEnabled: true,
a11yLabel: .TabsButtonShowTabsAccessibilityLabel,
a11yLabel: .Toolbars.TabsButtonAccessibilityLabel,
a11yId: AccessibilityIdentifiers.Toolbar.tabsButton)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ final class ExperimentIntegrationTests: BaseTestCase {
navigator.goto(NewTabScreen)
waitForTabsButton()

let tabsOpen = app.buttons["Show Tabs"].value
let tabsOpen = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value
XCTAssertEqual("1", tabsOpen as? String)
}

Expand Down Expand Up @@ -125,7 +125,7 @@ final class ExperimentIntegrationTests: BaseTestCase {
navigator.goto(NewTabScreen)
waitForTabsButton()

let tabsOpen = app.buttons["Show Tabs"].value
let tabsOpen = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value
XCTAssertEqual("1", tabsOpen as? String)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ class NavigationTest: BaseTestCase {
value: "localhost")
mozWaitForElementToExist(app.webViews.staticTexts["Blocked Element"])

let numTabs = app.buttons["Show Tabs"].value
let numTabs = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value
XCTAssertEqual("1", numTabs as? String, "There should be only on tab")

// Now disable the Block PopUps option
Expand All @@ -375,7 +375,7 @@ class NavigationTest: BaseTestCase {
waitUntilPageLoad()
mozWaitForValueContains(app.textFields[AccessibilityIdentifiers.Browser.AddressToolbar.searchTextField],
value: "example.com")
let numTabsAfter = app.buttons["Show Tabs"].value
let numTabsAfter = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value
XCTAssertNotEqual("1", numTabsAfter as? String, "Several tabs are open")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,10 @@ class PrivateBrowsingTestIphone: IphoneOnlyTestCase {
waitForElementsToExist(
[
app.links["RFC 2606"],
app.buttons["Show Tabs"]
app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton]
]
)
let numPrivTab = app.buttons["Show Tabs"].value as? String
let numPrivTab = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value as? String
XCTAssertEqual("2", numPrivTab)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class ReadingListTests: BaseTestCase {

// https://mozilla.testrail.io/index.php?/cases/view/2307000
func testOpenSavedForReadingLongPressInNewTab() {
let numTab = app.buttons["Show Tabs"].value as? String
let numTab = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value as? String
XCTAssertEqual(numTab, "1")

// Add item to Reading List
Expand All @@ -193,7 +193,7 @@ class ReadingListTests: BaseTestCase {
// Now there should be two tabs open
navigator.goto(HomePanelsScreen)
// Disabling validation of tab count until https://github.com/mozilla-mobile/firefox-ios/issues/17579 is fixed
// let numTabAfter = app.buttons["Show Tabs"].value as? String
// let numTabAfter = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value as? String
// XCTAssertEqual(numTabAfter, "2")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class SearchTests: BaseTestCase {
let url = app.textFields[AccessibilityIdentifiers.Browser.AddressToolbar.searchTextField]
mozWaitForValueContains(url, value: "google")
// Now there should be two tabs open
let numTab = app.buttons["Show Tabs"].value as? String
let numTab = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value as? String
XCTAssertEqual("2", numTab)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SettingsTests: BaseTestCase {
mozWaitForValueContains(url, value: "support.mozilla.org")
mozWaitForElementToExist(app.webViews.staticTexts["Firefox for iOS Support"])

let numTabs = app.buttons["Show Tabs"].value
let numTabs = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value
XCTAssertEqual("2", numTabs as? String, "Sume should be open in a different tab")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TabCounterTests: BaseTestCase {
navigator.nowAt(NewTabScreen)
waitForTabsButton()

var tabsOpen = app.buttons["Show Tabs"].value
var tabsOpen = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value
XCTAssertEqual("1", tabsOpen as? String)

navigator.createNewTab()
Expand All @@ -21,7 +21,7 @@ class TabCounterTests: BaseTestCase {
}
waitForTabsButton()

tabsOpen = app.buttons["Show Tabs"].value
tabsOpen = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value
XCTAssertEqual("2", tabsOpen as? String)

// Check only for iPhone, for iPad there is not counter in tab tray
Expand All @@ -40,7 +40,7 @@ class TabCounterTests: BaseTestCase {
navigator.nowAt(NewTabScreen)
waitForTabsButton()

var tabsOpen = app.buttons["Show Tabs"].value
var tabsOpen = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value
XCTAssertEqual("1", tabsOpen as? String)

navigator.createNewTab()
Expand All @@ -51,7 +51,7 @@ class TabCounterTests: BaseTestCase {
}
waitForTabsButton()

tabsOpen = app.buttons["Show Tabs"].value
tabsOpen = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value
XCTAssertEqual("2", tabsOpen as? String)

navigator.goto(TabTray)
Expand All @@ -75,7 +75,7 @@ class TabCounterTests: BaseTestCase {
navigator.nowAt(NewTabScreen)
waitForTabsButton()

tabsOpen = app.buttons["Show Tabs"].value
tabsOpen = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value
XCTAssertEqual("1", tabsOpen as? String)

navigator.goto(TabTray)
Expand Down
44 changes: 22 additions & 22 deletions firefox-ios/firefox-ios-tests/Tests/XCUITests/TopTabsTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TopTabsTest: BaseTestCase {
waitUntilPageLoad()
waitForTabsButton()
// The tabs counter shows the correct number
let tabsOpen = app.buttons["Show Tabs"].value
let tabsOpen = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value
XCTAssertEqual("2", tabsOpen as? String)

// The tab tray shows the correct tabs
Expand All @@ -49,7 +49,7 @@ class TopTabsTest: BaseTestCase {
navigator.nowAt(NewTabScreen)
navigator.openURL(urlExample)
// Initially there is only one tab open
let tabsOpenInitially = app.buttons["Show Tabs"].value
let tabsOpenInitially = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value
XCTAssertEqual("1", tabsOpenInitially as? String)

// Open link in a different tab and switch to it
Expand Down Expand Up @@ -268,8 +268,8 @@ class TopTabsTest: BaseTestCase {
if !iPad() {
// Long tap on Tab Counter should show the correct options
navigator.nowAt(NewTabScreen)
mozWaitForElementToExist(app.buttons["Show Tabs"])
app.buttons["Show Tabs"].press(forDuration: 1)
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton])
app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].press(forDuration: 1)
waitForElementsToExist(
[
app.cells.otherElements[StandardImageIdentifiers.Large.plus],
Expand All @@ -292,8 +292,8 @@ class TopTabsTest: BaseTestCase {
navigator.nowAt(HomePanelsScreen)
navigator.nowAt(NewTabScreen)

mozWaitForElementToExist(app.buttons["Show Tabs"])
app.buttons["Show Tabs"].press(forDuration: 1)
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton])
app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].press(forDuration: 1)
mozWaitForElementToExist(app.tables.cells.otherElements[StandardImageIdentifiers.Large.plus])
app.tables.cells.otherElements[StandardImageIdentifiers.Large.cross].tap()
navigator.nowAt(NewTabScreen)
Expand All @@ -306,8 +306,8 @@ class TopTabsTest: BaseTestCase {
)
navigator.nowAt(HomePanelsScreen)
navigator.nowAt(NewTabScreen)
mozWaitForElementToExist(app.buttons["Show Tabs"])
app.buttons["Show Tabs"].press(forDuration: 1)
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton])
app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].press(forDuration: 1)
app.tables.cells.otherElements["New Private Tab"].waitAndTap()
let tabsButton = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton]
mozWaitForElementToExist(tabsButton)
Expand All @@ -329,7 +329,7 @@ class TopTabsTest: BaseTestCase {
navigator.performAction(Action.CloseURLBarOpen)
}
}
let numTab = app.buttons["Show Tabs"].value as? String
let numTab = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value as? String
XCTAssertEqual("11", numTab, "The number of counted tabs is not equal to \(String(describing: numTab))")
// Scroll down to view all open tabs thumbnails
navigator.goto(TabTray)
Expand Down Expand Up @@ -390,7 +390,7 @@ class TopTabsTest: BaseTestCase {
navigator.goto(TabTray)
let tabsTrayCell = app.otherElements["Tabs Tray"].cells
if !iPad() {
let numTab = app.buttons["Show Tabs"].value as? String
let numTab = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value as? String
XCTAssertEqual(Int(numTab!), tabsTrayCell.count)
} else {
XCTAssertEqual(tabsTrayCell.count, 2)
Expand All @@ -404,7 +404,7 @@ class TopTabsTest: BaseTestCase {
app.buttons["Undo"].tap()
// Only the latest tab closed is restored
if !iPad() {
let numTab = app.buttons["Show Tabs"].value as? String
let numTab = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value as? String
let tabsTrayCell = app.otherElements["Tabs Tray"].cells
XCTAssertEqual(Int(numTab!), tabsTrayCell.count)
}
Expand Down Expand Up @@ -452,7 +452,7 @@ class TopTabsTest: BaseTestCase {
navigator.performAction(Action.CloseURLBarOpen)
}
}
let numTab = app.buttons["Show Tabs"].value as? String
let numTab = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value as? String
XCTAssertEqual("4", numTab, "The number of counted tabs is not equal to \(String(describing: numTab))")
navigator.goto(TabTray)
// Long press on the tab tray to open the context menu
Expand Down Expand Up @@ -581,9 +581,9 @@ class TopTabsTestIphone: IphoneOnlyTestCase {
waitUntilPageLoad()
mozWaitForValueContains(app.textFields[AccessibilityIdentifiers.Browser.AddressToolbar.searchTextField],
value: "iana")
XCTAssertTrue(app.links["RFC 2606"].exists)
mozWaitForElementToExist(app.buttons["Show Tabs"])
let numTab = app.buttons["Show Tabs"].value as? String
mozWaitForElementToExist(app.links["RFC 2606"])
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton])
let numTab = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value as? String
XCTAssertEqual("2", numTab)
}

Expand Down Expand Up @@ -621,7 +621,7 @@ class TopTabsTestIpad: IpadOnlyTestCase {
app.buttons[AccessibilityIdentifiers.Toolbar.addNewTabButton].tap()
app.buttons[AccessibilityIdentifiers.Toolbar.addNewTabButton].tap()
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton])
let numTab = app.buttons["Show Tabs"].value as? String
let numTab = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value as? String
XCTAssertEqual("3", numTab)
// Remove one tab by tapping on 'x' button
app.collectionViews["Top Tabs View"]
Expand All @@ -630,19 +630,19 @@ class TopTabsTestIpad: IpadOnlyTestCase {
.element(boundBy: 1).buttons["Remove page — Homepage"]
.tap()
waitForTabsButton()
mozWaitForElementToNotExist(app.buttons["Show Tabs"].staticTexts["3"])
mozWaitForElementToExist(app.buttons["Show Tabs"].staticTexts["2"])
let numTabAfterRemovingThirdTab = app.buttons["Show Tabs"].value as? String
mozWaitForElementToNotExist(app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].staticTexts["3"])
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].staticTexts["2"])
let numTabAfterRemovingThirdTab = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value as? String
XCTAssertEqual("2", numTabAfterRemovingThirdTab)
app.collectionViews["Top Tabs View"]
.children(matching: .cell)
.element(boundBy: 1)
.buttons["Remove page — Homepage"]
.tap()
waitForTabsButton()
mozWaitForElementToNotExist(app.buttons["Show Tabs"].staticTexts["2"])
mozWaitForElementToExist(app.buttons["Show Tabs"].staticTexts["1"])
let numTabAfterRemovingSecondTab = app.buttons["Show Tabs"].value as? String
mozWaitForElementToNotExist(app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].staticTexts["2"])
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].staticTexts["1"])
let numTabAfterRemovingSecondTab = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value as? String
XCTAssertEqual("1", numTabAfterRemovingSecondTab)
}
}

0 comments on commit bc1a8c1

Please sign in to comment.