/
NoImageTests.swift
76 lines (62 loc) · 2.59 KB
/
NoImageTests.swift
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
/* 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 XCTest
class NoImageTests: BaseTestCase {
var navigator: Navigator!
var app: XCUIApplication!
override func setUp() {
super.setUp()
app = XCUIApplication()
navigator = createScreenGraph(app).navigator(self)
}
override func tearDown() {
navigator = nil
app = nil
super.tearDown()
}
private func showImages() {
app.buttons["TabToolbar.menuButton"].tap()
app.collectionViews.containing(.cell, identifier:"FindInPageMenuItem").element.swipeLeft()
let collectionViewsQuery = app.collectionViews
collectionViewsQuery.cells["ShowImageModeMenuItem"].tap()
}
private func hideImages() {
app.buttons["TabToolbar.menuButton"].tap()
app.collectionViews.containing(.cell, identifier:"FindInPageMenuItem").element.swipeLeft()
let collectionViewsQuery = app.collectionViews
collectionViewsQuery.cells["HideImageModeMenuItem"].tap()
}
private func checkShowImages() {
navigator.goto(BrowserTabMenu)
app.collectionViews.containing(.cell, identifier:"FindInPageMenuItem").element.swipeLeft()
waitforExistence(app.collectionViews.cells["ShowImageModeMenuItem"])
navigator.goto(BrowserTab)
}
private func checkHideImages() {
navigator.goto(BrowserTabMenu)
app.collectionViews.containing(.cell, identifier:"FindInPageMenuItem").element.swipeLeft()
waitforExistence(app.collectionViews.cells["HideImageModeMenuItem"])
navigator.goto(BrowserTab)
}
func testImageOnOff() {
let url1 = "www.google.com"
// Go to a webpage, and select no images or hide images, check it's hidden or not
navigator.openNewURL(urlString: url1)
XCTAssertTrue(app.images.count > 1)
hideImages()
//After image is hidden, only image detected is the lock icon in the UI
if iPad() {
XCTAssertTrue(app.images.count == 2)
} else {
XCTAssertTrue(app.images.count == 1)
}
checkShowImages()
// Load a same page on a new tab, check images are hidden
navigator.openURL(urlString: url1)
// Open it, then select show images it, and check it's showing the images
showImages()
XCTAssertTrue(app.images.count > 1)
checkHideImages()
}
}