forked from SeleniumHQ/selenium
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreatesessiondialog_test.html
More file actions
122 lines (103 loc) · 3.87 KB
/
createsessiondialog_test.html
File metadata and controls
122 lines (103 loc) · 3.87 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
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
<!DOCTYPE html>
<!--
Copyright 2012 Software Freedom Conservancy. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<title>createsessiondialog_test.html</title>
<script src="test_bootstrap.js"></script>
<link href="../style.css" rel="stylesheet">
<script>
goog.require('bot.Keyboard.Keys');
goog.require('bot.action');
goog.require('bot.dom');
goog.require('goog.events');
goog.require('goog.testing.jsunit');
goog.require('goog.testing.recordFunction');
goog.require('goog.ui.Component.EventType');
goog.require('remote.ui.CreateSessionDialog');
</script>
<script>
var dialog;
function setUp() {
dialog = new remote.ui.CreateSessionDialog([
'chrome',
'firefox',
'internet explorer'
]);
}
function tearDown() {
dialog.dispose();
}
function assertDialogIsVisible() {
assertTrue('Expected dialog to be visible', dialog.isVisible());
}
function assertDialogNotVisible() {
assertFalse('Expected dialog not to be visible', dialog.isVisible());
}
function testShouldNotCloseDialogWhenEscapingFromSelect() {
dialog.setVisible(true);
dialog.browserSelect_.focus();
assertDialogIsVisible();
bot.action.type(bot.dom.getActiveElement(window), bot.Keyboard.Keys.ESC);
assertDialogIsVisible();
}
function testShouldCloseDialogWhenEscapingFromButtonSet_ok() {
dialog.setVisible(true);
assertDialogIsVisible();
bot.action.type(dialog.getButtonSet().getButton('ok'),
bot.Keyboard.Keys.ESC);
assertDialogNotVisible();
}
function testShouldCloseDialogWhenEscapingFromButtonSet_cancel() {
dialog.setVisible(true);
assertDialogIsVisible();
bot.action.type(dialog.getButtonSet().getButton('cancel'),
bot.Keyboard.Keys.ESC);
assertDialogNotVisible();
}
function testShouldNotFireActionEventIfCancelled() {
var onAction = goog.testing.recordFunction();
goog.events.listen(dialog, goog.ui.Component.EventType.ACTION, onAction);
dialog.setVisible(true);
bot.action.click(dialog.getButtonSet().getButton('cancel'));
assertDialogNotVisible();
assertEquals(0, onAction.getCallCount());
}
function testShouldNotFireActionEventIfSelectingOkWithoutSelection() {
var onAction = goog.testing.recordFunction();
goog.events.listen(dialog, goog.ui.Component.EventType.ACTION, onAction);
dialog.setVisible(true);
assertFalse(dialog.hasUserSelection());
bot.action.click(dialog.getButtonSet().getButton('ok'));
assertDialogNotVisible();
assertEquals(0, onAction.getCallCount());
}
function testShouldResetSelectionEachTimeDialogIsShown() {
dialog.setVisible(true);
assertFalse(dialog.hasUserSelection());
dialog.browserSelect_.selectedIndex = 2;
assertTrue(dialog.hasUserSelection());
assertEquals('firefox', dialog.getUserSelection()['browserName']);
dialog.setVisible(false);
dialog.setVisible(true);
assertFalse(dialog.hasUserSelection());
}
function testFiresActionEventOnOkWithSelection() {
var onAction = goog.testing.recordFunction();
goog.events.listen(dialog, goog.ui.Component.EventType.ACTION, onAction);
dialog.setVisible(true);
dialog.getBrowserSelectElement().selectedIndex = 2;
bot.action.click(dialog.getButtonSet().getButton('ok'));
assertDialogNotVisible();
assertEquals('firefox', dialog.getUserSelection()['browserName']);
assertEquals(1, onAction.getCallCount());
}
</script>