/
BrowserToolbarTest.swift.orig
147 lines (134 loc) · 7.12 KB
/
BrowserToolbarTest.swift.orig
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//
// BrowserToolbarTest.swift
// Client
//
// Created by Kiiza Joseph Bazaare on 12/19/16.
// Copyright © 2016 Mozilla. All rights reserved.
//
import XCTest
import KIF
class BrowserToolbarTest: KIFTestCase {
override func tearDown() {
if tester.viewExistsWithLabel("Back to safe site"){
tester.tapView(withAccessibilityLabel: "Back to safe site")
}
if tester.viewExistsWithLabel("Settings"){
tester.tapView(withAccessibilityLabel: "Settings")
}
if tester.viewExistsWithLabel("Done"){
tester.tapView(withAccessibilityLabel: "Done")
}
if tester.viewExistsWithLabel("cliqzBack"){
<<<<<<< HEAD
tester.tapViewWithAccessibilityLabel("closeTab")
=======
tester.tapView(withAccessibilityLabel: "closeTab")
tester.tapView(withAccessibilityLabel: "cliqzBack")
>>>>>>> Swift3 migration
}
super.tearDown()
}
func testToolBarStatusOnSearchPage(){
showToolBar()
let back = tester.waitForView(withAccessibilityLabel: "Back")as! UIButton
let forward = tester.waitForView(withAccessibilityLabel: "Forward")as! UIButton
let share = tester.waitForView(withAccessibilityLabel: "Share")as! UIButton
let bookmark = tester.waitForView(withAccessibilityLabel: "Bookmark")as! UIButton
let showtabs = tester.waitForView(withAccessibilityLabel: "Show Tabs")as! UIButton
XCTAssertFalse(back.isEnabled, "Back button should be Disabled")
XCTAssertFalse(forward.isEnabled, "Forward button should be Disabled")
XCTAssertFalse(share.isEnabled,"Share button should be Disabled")
XCTAssertFalse(bookmark.isEnabled, "Bookmark button should be Disabled")
XCTAssertTrue(showtabs.isEnabled, "Show Tabs button should be Enabled")
resetApp(["New Tab, Most visited sites and News"])
}
func testToolBarStatusOnWebpage(){
openWebPage("https://cdn.cliqz.com/mobile/browser/tests/forward_test.html")
let back = tester.waitForView(withAccessibilityLabel: "Back")as! UIButton
let forward = tester.waitForView(withAccessibilityLabel: "Forward")as! UIButton
let share = tester.waitForView(withAccessibilityLabel: "Share")as! UIButton
let bookmark = tester.waitForView(withAccessibilityLabel: "Bookmark")as! UIButton
let showtabs = tester.waitForView(withAccessibilityLabel: "Show Tabs")as! UIButton
XCTAssertTrue(back.isEnabled, "Back button should be enabled")
XCTAssertFalse(forward.isEnabled, "Forward button should be Disabled")
XCTAssertTrue(share.isEnabled, "Share button should be enabled")
XCTAssertTrue(bookmark.isEnabled, "Bookmark button should be enabled")
XCTAssertTrue(showtabs.isEnabled, "Show Tabs button should be enabled")
tester.tapView(withAccessibilityLabel: "Back")
resetApp(["New Tab, Most visited sites and News"])
}
func testForwardButton(){
openWebPage("https://cdn.cliqz.com/mobile/browser/tests/forward_test.html")
goToLinkInWebPage()
tester.tapView(withAccessibilityLabel: "Back")
tester.waitForView(withAccessibilityLabel: "https://cdn.cliqz.com/mobile/browser/tests/forward_test.html")
tester.tapView(withAccessibilityLabel: "Forward")
tester.waitForView(withAccessibilityLabel: "https://cdn.cliqz.com/mobile/browser/tests/testpage.html")
resetApp(["https://cdn.cliqz.com/mobile/browser/tests/testpage.html"])
}
func testForwardBackwardButtons(){
openWebPage("https://cdn.cliqz.com/mobile/browser/tests/testpage.html")
let back = tester.waitForView(withAccessibilityLabel: "Back")as! UIButton
let forward = tester.waitForView(withAccessibilityLabel: "Forward")as! UIButton
XCTAssertTrue(back.isEnabled, "Back button should be enabled")
XCTAssertFalse(forward.isEnabled, "Forward button should be Disabled")
tester.tapView(withAccessibilityLabel: "Back")
XCTAssertFalse(back.isEnabled, "Back button should be Disabled")
XCTAssertTrue(forward.isEnabled, "Forward button should be Enabled")
resetApp(["New Tab, Most visited sites and News"])
}
func testForgetTab(){
tester.waitForAnimationsToFinish()
showToolBar()
<<<<<<< HEAD
tester.longPressViewWithAccessibilityLabel("Show Tabs", duration: 1)
tester.tapViewWithAccessibilityLabel("Open New Forget Tab")
tester.waitForViewWithAccessibilityLabel("Forget Tab")
let darkview = tester.waitForViewWithAccessibilityLabel("Forget Mode Background")
XCTAssertEqual(darkview.backgroundColor, UIColor.grayColor(),"View is not expected color it is\(darkview.backgroundColor) ")
=======
tester.longPressView(withAccessibilityLabel: "Show Tabs", duration: 1)
tester.tapView(withAccessibilityLabel: "Open New Forget Tab")
tester.waitForView(withAccessibilityLabel: "Forget Tab")
XCTAssertTrue(tester.viewExistsWithLabel("Forget Tab"))
>>>>>>> Swift3 migration
resetApp(["New Tab, Most visited sites and News", "New Tab, Most visited sites and News"])
}
func testForgetTabInTabsOVerview(){
tester.waitForAnimationsToFinish()
showToolBar()
tester.tapViewWithAccessibilityLabel("Show Tabs")
tester.longPressViewWithAccessibilityLabel("+", duration: 1)
tester.tapViewWithAccessibilityLabel("Open New Forget Tab")
tester.waitForViewWithAccessibilityLabel("Forget Tab")
let darkview = tester.waitForViewWithAccessibilityLabel("Forget Mode Background")
XCTAssertEqual(darkview.backgroundColor, UIColor.grayColor(),"View is not expected color it is\(darkview.backgroundColor) ")
resetApp(["New Tab, Most visited sites and News", "New Tab, Most visited sites and News"])
}
func testForgetTabDeletionSwipeLeft(){
tester.waitForAnimationsToFinish()
showToolBar()
tester.longPressViewWithAccessibilityLabel("Show Tabs", duration: 1)
tester.tapViewWithAccessibilityLabel("Open New Forget Tab")
tester.waitForViewWithAccessibilityLabel("Forget Tab")
showToolBar()
tester.tapViewWithAccessibilityLabel("Show Tabs")
tester.swipeViewWithAccessibilityLabel("New Tab, Most visited sites and News", inDirection: KIFSwipeDirection.Left)
}
func testForgetTabDeletionSwipeRight(){
tester.waitForAnimationsToFinish()
showToolBar()
tester.longPressViewWithAccessibilityLabel("Show Tabs", duration: 1)
tester.tapViewWithAccessibilityLabel("Open New Forget Tab")
tester.waitForViewWithAccessibilityLabel("Forget Tab")
showToolBar()
tester.tapViewWithAccessibilityLabel("Show Tabs")
tester.swipeViewWithAccessibilityLabel("New Tab, Most visited sites and News", inDirection: KIFSwipeDirection.Right)
}
func testInitialTabCount(){
tester.waitForAnimationsToFinish()
showToolBar()
let showTabs = tester.waitForViewWithAccessibilityLabel("Show Tabs")as! UIButton
XCTAssertTrue(showTabs.accessibilityValue == "1", "Initial tab count is not one, it should be!")
}
}