forked from qodo-benchmark/firefox-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabaseFixtureTest.swift
More file actions
78 lines (65 loc) · 3.31 KB
/
Copy pathDatabaseFixtureTest.swift
File metadata and controls
78 lines (65 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/
import Common
import XCTest
class DatabaseFixtureTest: BaseTestCase {
let fixtures = [
"testBookmarksDatabaseFixture": "testBookmarksDatabase1000-places.db",
"testHistoryDatabaseFixture": "testHistoryDatabase100-places.db"
]
override func setUp() async throws {
// Test name looks like: "[Class testFunc]", parse out the function name
let parts = name.replacingOccurrences(of: "]", with: "").split(separator: " ")
let key = String(parts[1])
launchArguments = [LaunchArguments.SkipIntro,
LaunchArguments.SkipWhatsNew,
LaunchArguments.SkipETPCoverSheet,
LaunchArguments.LoadDatabasePrefix + fixtures[key]!,
LaunchArguments.SkipContextualHints,
LaunchArguments.DisableAnimations]
try await super.setUp()
}
// https://mozilla.testrail.io/index.php?/cases/view/2458579
func testBookmarksDatabaseFixture() {
// Warning: Avoid using mozWaitForElementToExist as it is up to 25x less performant
let tabsButton = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton]
mozWaitForElementToExist(tabsButton)
navigator.goto(LibraryPanel_Bookmarks)
// Ensure 'Bookmarks List' exists before taking a snapshot to avoid expensive retries.
// Return firstMatch to avoid traversing the entire { Window, Window } element tree.
let bookmarksList = app.tables["Bookmarks List"].firstMatch
mozWaitForElementToExist(bookmarksList)
do {
// Take a custom snapshot to avoid unnecessary snapshots by xctrunner (~9s each).
let bookmarksListSnapshot = try bookmarksList.snapshot()
let bookmarksListCells = bookmarksListSnapshot.children.filter { $0.elementType == .cell }
XCTAssertEqual(bookmarksListCells.count, 1000, "There should be 1000 entries in the bookmarks list")
} catch {
XCTFail("Failed to take snapshot: \(error)")
}
// Handle termination ourselves as it sometimes hangs when given to xctrunner
app.terminate()
}
// https://mozilla.testrail.io/index.php?/cases/view/2459133
func testHistoryDatabaseFixture() throws {
let tabsButton = app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton]
mozWaitForElementToExist(tabsButton)
navigator.goto(LibraryPanel_History)
let historyList = app.tables["History List"].firstMatch
mozWaitForElementToExist(historyList)
do {
let snapshot = try app.tables["History List"].snapshot()
let historyList = snapshot.children.count
if #available(iOS 18, *) {
XCTAssertEqual(historyList, 105, "There should be 105 entries in the history list")
} else {
// For iOS 18, the scrollbars (vertical and horizontal) are included in the table
XCTAssertEqual(historyList, 103, "There should be 103 entries in the history list")
}
} catch {
XCTFail("Failed to take snapshot: \(error)")
}
app.terminate()
}
}