rubinium 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (161) hide show
  1. data/CHANGES +7 -0
  2. data/MIT-LICENSE +21 -0
  3. data/README +137 -0
  4. data/Rakefile +139 -0
  5. data/TODO +7 -0
  6. data/doc/examples/rtc_site_live.rb +12 -0
  7. data/doc/examples/rts_main.rb +9 -0
  8. data/doc/examples/rts_shared_code.rb +25 -0
  9. data/lib/rubinium.rb +9 -0
  10. data/lib/rubinium/string.rb +3 -0
  11. data/lib/rubinium/test_base.rb +80 -0
  12. data/lib/rubinium/test_suite.rb +53 -0
  13. data/lib/rubinium/validator.rb +16 -0
  14. data/test/selenium_tests/test_click.rb +22 -0
  15. data/test/selenium_tests/test_open.rb +11 -0
  16. data/test/tc_file_creation.rb +60 -0
  17. data/test/ts_rubinium.rb +1 -0
  18. data/vendor/selenium-0.6.0/install-readme.txt +9 -0
  19. data/vendor/selenium-0.6.0/selenium/SeleneseRunner.html +253 -0
  20. data/vendor/selenium-0.6.0/selenium/SeleniumLog.html +61 -0
  21. data/vendor/selenium-0.6.0/selenium/TestRunner-splash.html +55 -0
  22. data/vendor/selenium-0.6.0/selenium/TestRunner.hta +146 -0
  23. data/vendor/selenium-0.6.0/selenium/TestRunner.html +146 -0
  24. data/vendor/selenium-0.6.0/selenium/devtests/TestClickInFrame.html +58 -0
  25. data/vendor/selenium-0.6.0/selenium/devtests/TestOpenInFrame.html +48 -0
  26. data/vendor/selenium-0.6.0/selenium/devtests/TestOpenInNewWindow.html +78 -0
  27. data/vendor/selenium-0.6.0/selenium/devtests/TestOpenMeta.html +43 -0
  28. data/vendor/selenium-0.6.0/selenium/devtests/TestSuite.html +39 -0
  29. data/vendor/selenium-0.6.0/selenium/devtests/meta/page.html +5 -0
  30. data/vendor/selenium-0.6.0/selenium/dom-images/butmin.gif +0 -0
  31. data/vendor/selenium-0.6.0/selenium/dom-images/butplus.gif +0 -0
  32. data/vendor/selenium-0.6.0/selenium/dom-styles/default.css +298 -0
  33. data/vendor/selenium-0.6.0/selenium/domviewer.html +16 -0
  34. data/vendor/selenium-0.6.0/selenium/html-xpath/carnation.jpg +0 -0
  35. data/vendor/selenium-0.6.0/selenium/html-xpath/example.html +75 -0
  36. data/vendor/selenium-0.6.0/selenium/html-xpath/html-xpath-patched.js +657 -0
  37. data/vendor/selenium-0.6.0/selenium/html-xpath/html-xpath.js +610 -0
  38. data/vendor/selenium-0.6.0/selenium/html-xpath/license.txt +504 -0
  39. data/vendor/selenium-0.6.0/selenium/html-xpath/rainbow.jpg +0 -0
  40. data/vendor/selenium-0.6.0/selenium/htmlutils.js +283 -0
  41. data/vendor/selenium-0.6.0/selenium/index.html +60 -0
  42. data/vendor/selenium-0.6.0/selenium/jsmock/mock-tests.html +205 -0
  43. data/vendor/selenium-0.6.0/selenium/jsmock/mock.js +124 -0
  44. data/vendor/selenium-0.6.0/selenium/selenium-api.js +683 -0
  45. data/vendor/selenium-0.6.0/selenium/selenium-browserbot.js +930 -0
  46. data/vendor/selenium-0.6.0/selenium/selenium-commandhandlers.js +286 -0
  47. data/vendor/selenium-0.6.0/selenium/selenium-domviewer.js +188 -0
  48. data/vendor/selenium-0.6.0/selenium/selenium-executionloop.js +250 -0
  49. data/vendor/selenium-0.6.0/selenium/selenium-fitrunner.js +597 -0
  50. data/vendor/selenium-0.6.0/selenium/selenium-logging.js +88 -0
  51. data/vendor/selenium-0.6.0/selenium/selenium-logo.png +0 -0
  52. data/vendor/selenium-0.6.0/selenium/selenium-tableparser.js +50 -0
  53. data/vendor/selenium-0.6.0/selenium/selenium.css +211 -0
  54. data/vendor/selenium-0.6.0/selenium/tests/ErrorCheckingTestSuite.html +36 -0
  55. data/vendor/selenium-0.6.0/selenium/tests/GoogleTestSearch.html +69 -0
  56. data/vendor/selenium-0.6.0/selenium/tests/GoogleTestSuite.html +32 -0
  57. data/vendor/selenium-0.6.0/selenium/tests/JsUnitSuite.html +38 -0
  58. data/vendor/selenium-0.6.0/selenium/tests/TestClick.html +128 -0
  59. data/vendor/selenium-0.6.0/selenium/tests/TestClickJavascriptHref.html +115 -0
  60. data/vendor/selenium-0.6.0/selenium/tests/TestCommandError.html +79 -0
  61. data/vendor/selenium-0.6.0/selenium/tests/TestConfirmations.html +77 -0
  62. data/vendor/selenium-0.6.0/selenium/tests/TestErrorChecking.html +71 -0
  63. data/vendor/selenium-0.6.0/selenium/tests/TestFailingAssert.html +59 -0
  64. data/vendor/selenium-0.6.0/selenium/tests/TestFailingVerifications.html +198 -0
  65. data/vendor/selenium-0.6.0/selenium/tests/TestFocusOnBlur.html +53 -0
  66. data/vendor/selenium-0.6.0/selenium/tests/TestGoBack.html +81 -0
  67. data/vendor/selenium-0.6.0/selenium/tests/TestImplicitLocators.html +81 -0
  68. data/vendor/selenium-0.6.0/selenium/tests/TestJavascriptParameters.html +91 -0
  69. data/vendor/selenium-0.6.0/selenium/tests/TestLocators.html +161 -0
  70. data/vendor/selenium-0.6.0/selenium/tests/TestModalDialog.html +58 -0
  71. data/vendor/selenium-0.6.0/selenium/tests/TestModalDialogDialog.html +48 -0
  72. data/vendor/selenium-0.6.0/selenium/tests/TestOpen.html +66 -0
  73. data/vendor/selenium-0.6.0/selenium/tests/TestPatternMatching.html +127 -0
  74. data/vendor/selenium-0.6.0/selenium/tests/TestPause.html +78 -0
  75. data/vendor/selenium-0.6.0/selenium/tests/TestPrompting.html +82 -0
  76. data/vendor/selenium-0.6.0/selenium/tests/TestProxy.html +62 -0
  77. data/vendor/selenium-0.6.0/selenium/tests/TestSelect.html +111 -0
  78. data/vendor/selenium-0.6.0/selenium/tests/TestSelectWindow.html +106 -0
  79. data/vendor/selenium-0.6.0/selenium/tests/TestStore.html +165 -0
  80. data/vendor/selenium-0.6.0/selenium/tests/TestSuite-InternetExplorer.html +79 -0
  81. data/vendor/selenium-0.6.0/selenium/tests/TestSuite-Konqueror.html +75 -0
  82. data/vendor/selenium-0.6.0/selenium/tests/TestSuite-Safari.html +75 -0
  83. data/vendor/selenium-0.6.0/selenium/tests/TestSuite.html +75 -0
  84. data/vendor/selenium-0.6.0/selenium/tests/TestType.html +79 -0
  85. data/vendor/selenium-0.6.0/selenium/tests/TestUserExtensions.html +81 -0
  86. data/vendor/selenium-0.6.0/selenium/tests/TestVerifications.html +164 -0
  87. data/vendor/selenium-0.6.0/selenium/tests/TestVerifyAlerts.html +80 -0
  88. data/vendor/selenium-0.6.0/selenium/tests/TestVerifyAlertsFailures.html +108 -0
  89. data/vendor/selenium-0.6.0/selenium/tests/TestVerifyConfirmationFailures.html +86 -0
  90. data/vendor/selenium-0.6.0/selenium/tests/TestVerifyEditable.html +70 -0
  91. data/vendor/selenium-0.6.0/selenium/tests/TestVerifyEditableFailures.html +95 -0
  92. data/vendor/selenium-0.6.0/selenium/tests/TestVisibility.html +91 -0
  93. data/vendor/selenium-0.6.0/selenium/tests/TestVisibilityFailures.html +131 -0
  94. data/vendor/selenium-0.6.0/selenium/tests/TestWait.html +112 -0
  95. data/vendor/selenium-0.6.0/selenium/tests/TestWaitFor.html +63 -0
  96. data/vendor/selenium-0.6.0/selenium/tests/TestWaitInPopupWindow.html +94 -0
  97. data/vendor/selenium-0.6.0/selenium/tests/TestXPathLocators.html +98 -0
  98. data/vendor/selenium-0.6.0/selenium/tests/browserbot/alert-handling-tests.html +79 -0
  99. data/vendor/selenium-0.6.0/selenium/tests/browserbot/assert-tests.html +113 -0
  100. data/vendor/selenium-0.6.0/selenium/tests/browserbot/browserbot-tests.html +123 -0
  101. data/vendor/selenium-0.6.0/selenium/tests/browserbot/command-factory-tests.html +290 -0
  102. data/vendor/selenium-0.6.0/selenium/tests/browserbot/command-handler-tests.html +115 -0
  103. data/vendor/selenium-0.6.0/selenium/tests/browserbot/confirm-handling-tests.html +97 -0
  104. data/vendor/selenium-0.6.0/selenium/tests/browserbot/error-checking-command-tests.html +198 -0
  105. data/vendor/selenium-0.6.0/selenium/tests/browserbot/event-bubble-tests.html +106 -0
  106. data/vendor/selenium-0.6.0/selenium/tests/browserbot/optionlocator-tests.html +180 -0
  107. data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-accessor-tests.html +65 -0
  108. data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-action-tests.html +200 -0
  109. data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-attribute-tests.html +98 -0
  110. data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-locator-tests-include.html +33 -0
  111. data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-locator-tests.html +258 -0
  112. data/vendor/selenium-0.6.0/selenium/tests/browserbot/pagebot-property-tests.html +49 -0
  113. data/vendor/selenium-0.6.0/selenium/tests/browserbot/pattern-matcher-tests.html +66 -0
  114. data/vendor/selenium-0.6.0/selenium/tests/browserbot/selenium-api-tests.html +412 -0
  115. data/vendor/selenium-0.6.0/selenium/tests/browserbot/selenium-parameter-tests.html +98 -0
  116. data/vendor/selenium-0.6.0/selenium/tests/browserbot/suite.html +52 -0
  117. data/vendor/selenium-0.6.0/selenium/tests/browserbot/testloop-handle-error-tests.html +74 -0
  118. data/vendor/selenium-0.6.0/selenium/tests/events/TestButtonEvents.html +72 -0
  119. data/vendor/selenium-0.6.0/selenium/tests/events/TestCheckboxEvents.html +107 -0
  120. data/vendor/selenium-0.6.0/selenium/tests/events/TestFireEvents.html +75 -0
  121. data/vendor/selenium-0.6.0/selenium/tests/events/TestLinkEvents.html +43 -0
  122. data/vendor/selenium-0.6.0/selenium/tests/events/TestRadioEvents.html +149 -0
  123. data/vendor/selenium-0.6.0/selenium/tests/events/TestSelectEvents.html +122 -0
  124. data/vendor/selenium-0.6.0/selenium/tests/events/TestTextEvents.html +87 -0
  125. data/vendor/selenium-0.6.0/selenium/tests/events/readme.txt +26 -0
  126. data/vendor/selenium-0.6.0/selenium/tests/html/banner.gif +0 -0
  127. data/vendor/selenium-0.6.0/selenium/tests/html/test_async_event.html +36 -0
  128. data/vendor/selenium-0.6.0/selenium/tests/html/test_click_javascript_page.html +34 -0
  129. data/vendor/selenium-0.6.0/selenium/tests/html/test_click_page1.html +31 -0
  130. data/vendor/selenium-0.6.0/selenium/tests/html/test_click_page2.html +30 -0
  131. data/vendor/selenium-0.6.0/selenium/tests/html/test_confirm.html +34 -0
  132. data/vendor/selenium-0.6.0/selenium/tests/html/test_dummy_page.html +26 -0
  133. data/vendor/selenium-0.6.0/selenium/tests/html/test_editable.html +36 -0
  134. data/vendor/selenium-0.6.0/selenium/tests/html/test_focus_on_blur.html +33 -0
  135. data/vendor/selenium-0.6.0/selenium/tests/html/test_form_events.html +98 -0
  136. data/vendor/selenium-0.6.0/selenium/tests/html/test_framed_page.html +7 -0
  137. data/vendor/selenium-0.6.0/selenium/tests/html/test_just_text.html +22 -0
  138. data/vendor/selenium-0.6.0/selenium/tests/html/test_locators.html +34 -0
  139. data/vendor/selenium-0.6.0/selenium/tests/html/test_modal_dialog.html +29 -0
  140. data/vendor/selenium-0.6.0/selenium/tests/html/test_modal_dialog_dialog.html +35 -0
  141. data/vendor/selenium-0.6.0/selenium/tests/html/test_open.html +23 -0
  142. data/vendor/selenium-0.6.0/selenium/tests/html/test_prompt.html +34 -0
  143. data/vendor/selenium-0.6.0/selenium/tests/html/test_reload_onchange_page.html +32 -0
  144. data/vendor/selenium-0.6.0/selenium/tests/html/test_select.html +35 -0
  145. data/vendor/selenium-0.6.0/selenium/tests/html/test_select_window.html +29 -0
  146. data/vendor/selenium-0.6.0/selenium/tests/html/test_select_window_popup.html +28 -0
  147. data/vendor/selenium-0.6.0/selenium/tests/html/test_slowloading_page.html +27 -0
  148. data/vendor/selenium-0.6.0/selenium/tests/html/test_store_value.html +23 -0
  149. data/vendor/selenium-0.6.0/selenium/tests/html/test_type_page1.html +37 -0
  150. data/vendor/selenium-0.6.0/selenium/tests/html/test_type_page2.html +61 -0
  151. data/vendor/selenium-0.6.0/selenium/tests/html/test_verifications.html +42 -0
  152. data/vendor/selenium-0.6.0/selenium/tests/html/test_verify_alert.html +46 -0
  153. data/vendor/selenium-0.6.0/selenium/tests/html/test_visibility.html +53 -0
  154. data/vendor/selenium-0.6.0/selenium/tests/readme.txt +1 -0
  155. data/vendor/selenium-0.6.0/selenium/tests/tableparser/tableparser-tests.html +122 -0
  156. data/vendor/selenium-0.6.0/selenium/tests/tinyWebServer.py +70 -0
  157. data/vendor/selenium-0.6.0/selenium/user-extensions.js.sample +62 -0
  158. data/vendor/selenium-0.6.0/selenium/version.txt +1 -0
  159. data/vendor/selenium-0.6.0/selenium/xmlextras.js +153 -0
  160. data/vendor/selenium-0.6.0/selenium/xpath.js +3910 -0
  161. metadata +216 -0
@@ -0,0 +1,283 @@
1
+ /*
2
+ * Copyright 2004 ThoughtWorks, Inc
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ // This script contains some HTML utility functions that
19
+ // make it possible to handle elements in a way that is
20
+ // compatible with both IE-like and Mozilla-like browsers
21
+
22
+ String.prototype.trim = function() {
23
+ var result = this.replace( /^\s+/g, "" );// strip leading
24
+ return result.replace( /\s+$/g, "" );// strip trailing
25
+ };
26
+ String.prototype.lcfirst = function() {
27
+ return this.charAt(0).toLowerCase() + this.substr(1);
28
+ };
29
+ String.prototype.ucfirst = function() {
30
+ return this.charAt(0).toUpperCase() + this.substr(1);
31
+ };
32
+ String.prototype.startsWith = function(str) {
33
+ return this.indexOf(str) == 0;
34
+ };
35
+
36
+ // Returns the text in this element
37
+ function getText(element) {
38
+ text = "";
39
+
40
+ if(element.textContent) {
41
+ text = element.textContent;
42
+ } else if(element.innerText) {
43
+ text = element.innerText;
44
+ }
45
+ // Replace   with a space
46
+ // TODO - should this be in the match() code instead?
47
+ text = text.replace(/\240/g, " ");
48
+ return text.trim();
49
+ }
50
+
51
+ // Sets the text in this element
52
+ function setText(element, text) {
53
+ if(element.textContent) {
54
+ element.textContent = text;
55
+ } else if(element.innerText) {
56
+ element.innerText = text;
57
+ }
58
+ }
59
+
60
+ // Get the value of an <input> element
61
+ function getInputValue(inputElement) {
62
+ if (inputElement.type.toUpperCase() == 'CHECKBOX' ||
63
+ inputElement.type.toUpperCase() == 'RADIO')
64
+ {
65
+ return (inputElement.checked ? 'on' : 'off');
66
+ }
67
+ return inputElement.value;
68
+ }
69
+
70
+ /* Fire an event in a browser-compatible manner */
71
+ function triggerEvent(element, eventType, canBubble) {
72
+ canBubble = (typeof(canBubble) == undefined) ? true : canBubble;
73
+ if (element.fireEvent) {
74
+ element.fireEvent('on' + eventType);
75
+ }
76
+ else {
77
+ var evt = document.createEvent('HTMLEvents');
78
+ evt.initEvent(eventType, canBubble, true);
79
+ element.dispatchEvent(evt);
80
+ }
81
+ }
82
+
83
+ /* Fire a mouse event in a browser-compatible manner */
84
+ function triggerMouseEvent(element, eventType, canBubble) {
85
+ canBubble = (typeof(canBubble) == undefined) ? true : canBubble;
86
+ if (element.fireEvent) {
87
+ element.fireEvent('on' + eventType);
88
+ }
89
+ else {
90
+ var evt = document.createEvent('MouseEvents');
91
+ evt.initMouseEvent(eventType, canBubble, true, document.defaultView, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
92
+ element.dispatchEvent(evt);
93
+ }
94
+ }
95
+
96
+ function removeLoadListener(element, command) {
97
+ if (window.removeEventListener)
98
+ element.removeEventListener("load", command, true);
99
+ else if (window.detachEvent)
100
+ element.detachEvent("onload", command);
101
+ }
102
+
103
+ function addLoadListener(element, command) {
104
+ if (window.addEventListener)
105
+ element.addEventListener("load",command, true);
106
+ else if (window.attachEvent)
107
+ element.attachEvent("onload",command);
108
+ }
109
+
110
+ function addUnloadListener(element, command) {
111
+ if (window.addEventListener)
112
+ element.addEventListener("unload",command, true);
113
+ else if (window.attachEvent)
114
+ element.attachEvent("onunload",command);
115
+ }
116
+
117
+ /**
118
+ * Override the broken getFunctionName() method from JsUnit
119
+ * This file must be loaded _after_ the jsunitCore.js
120
+ */
121
+ function getFunctionName(aFunction) {
122
+ var regexpResult = aFunction.toString().match(/function (\w*)/);
123
+ if (regexpResult && regexpResult[1]) {
124
+ return regexpResult[1];
125
+ }
126
+ return 'anonymous';
127
+ }
128
+
129
+ function describe(object, delimiter) {
130
+ var props = new Array();
131
+ for (var prop in object) {
132
+ props.push(prop + " -> " + object[prop]);
133
+ }
134
+ return props.join(delimiter || '\n');
135
+ }
136
+
137
+ PatternMatcher = function(pattern) {
138
+ this.selectStrategy(pattern);
139
+ };
140
+ PatternMatcher.prototype = {
141
+
142
+ selectStrategy: function(pattern) {
143
+ this.pattern = pattern;
144
+ var strategyName = 'glob'; // by default
145
+ if (/^([a-zA-Z]+):(.*)/.test(pattern)) {
146
+ strategyName = RegExp.$1;
147
+ pattern = RegExp.$2;
148
+ }
149
+ var matchStrategy = PatternMatcher.strategies[strategyName];
150
+ if (!matchStrategy) {
151
+ throw new SeleniumError("cannot find PatternMatcher.strategies." + strategyName);
152
+ }
153
+ this.matcher = new matchStrategy(pattern);
154
+ },
155
+
156
+ matches: function(actual) {
157
+ return this.matcher.matches(actual + '');
158
+ // Note: appending an empty string avoids a Konqueror bug
159
+ }
160
+
161
+ };
162
+
163
+ /**
164
+ * A "static" convenience method for easy matching
165
+ */
166
+ PatternMatcher.matches = function(pattern, actual) {
167
+ return new PatternMatcher(pattern).matches(actual);
168
+ };
169
+
170
+ PatternMatcher.strategies = {
171
+
172
+ /**
173
+ * Exact matching, e.g. "exact:***"
174
+ */
175
+ exact: function(expected) {
176
+ this.expected = expected;
177
+ this.matches = function(actual) {
178
+ return actual == this.expected;
179
+ };
180
+ },
181
+
182
+ /**
183
+ * Match by regular expression, e.g. "regexp:^[0-9]+$"
184
+ */
185
+ regexp: function(regexpString) {
186
+ this.regexp = new RegExp(regexpString);
187
+ this.matches = function(actual) {
188
+ return this.regexp.test(actual);
189
+ };
190
+ },
191
+
192
+ /**
193
+ * "glob" (aka "wildmat") patterns, e.g. "glob:one,two,*"
194
+ */
195
+ glob: function(globString) {
196
+ this.regexp = new RegExp(PatternMatcher.regexpFromGlob(globString));
197
+ this.matches = function(actual) {
198
+ return this.regexp.test(actual);
199
+ };
200
+ }
201
+
202
+ };
203
+
204
+ PatternMatcher.regexpFromGlob = function(glob) {
205
+ var re = glob;
206
+ re = re.replace(/([.^$+(){}\[\]\\|])/g, "\\$1");
207
+ re = re.replace(/\?/g, "(.|[\r\n])");
208
+ re = re.replace(/\*/g, "(.|[\r\n])*");
209
+ return "^" + re + "$";
210
+ };
211
+
212
+ var Assert = {
213
+
214
+ fail: function(message) {
215
+ throw new AssertionFailedError(message);
216
+ },
217
+
218
+ /*
219
+ * Assert.equals(comment?, expected, actual)
220
+ */
221
+ equals: function() {
222
+ var args = new AssertionArguments(arguments);
223
+ if (args.expected === args.actual) {
224
+ return;
225
+ }
226
+ Assert.fail(args.comment +
227
+ "Expected '" + args.expected +
228
+ "' but was '" + args.actual + "'");
229
+ },
230
+
231
+ /*
232
+ * Assert.matches(comment?, pattern, actual)
233
+ */
234
+ matches: function() {
235
+ var args = new AssertionArguments(arguments);
236
+ if (PatternMatcher.matches(args.expected, args.actual)) {
237
+ return;
238
+ }
239
+ Assert.fail(args.comment +
240
+ "Actual value '" + args.actual +
241
+ "' did not match '" + args.expected + "'");
242
+ },
243
+
244
+ /*
245
+ * Assert.notMtches(comment?, pattern, actual)
246
+ */
247
+ notMatches: function() {
248
+ var args = new AssertionArguments(arguments);
249
+ if (!PatternMatcher.matches(args.expected, args.actual)) {
250
+ return;
251
+ }
252
+ Assert.fail(args.comment +
253
+ "Actual value '" + args.actual +
254
+ "' did match '" + args.expected + "'");
255
+ }
256
+
257
+ };
258
+
259
+ // Preprocess the arguments to allow for an optional comment.
260
+ function AssertionArguments(args) {
261
+ if (args.length == 2) {
262
+ this.comment = "";
263
+ this.expected = args[0];
264
+ this.actual = args[1];
265
+ } else {
266
+ this.comment = args[0] + "; ";
267
+ this.expected = args[1];
268
+ this.actual = args[2];
269
+ }
270
+ }
271
+
272
+
273
+
274
+ function AssertionFailedError(message) {
275
+ this.isAssertionFailedError = true;
276
+ this.failureMessage = message;
277
+ }
278
+
279
+ function SeleniumError(message) {
280
+ var error = new Error(message);
281
+ error.isSeleniumError = true;
282
+ return error;
283
+ };
@@ -0,0 +1,60 @@
1
+ <html>
2
+ <head>
3
+ <title>Selenium starting points</title>
4
+ <script language="Javascript">
5
+ function fixUnitTestLink() {
6
+ baseurl = document.location + "";
7
+ baseurl = baseurl.replace(/[^\/]*$/, '');
8
+ jsunitLink = document.getElementById("unitTestLink");
9
+ jsunitLink['href'] = jsunitLink['href'].replace('BASEURL', baseurl);
10
+ }
11
+ </script>
12
+ <style>
13
+ li { margin-top: 6pt; }
14
+ </style>
15
+ </head>
16
+ <body onload="fixUnitTestLink();">
17
+
18
+ <h1>Selenium</h1>
19
+
20
+ <p>
21
+ <b>Acceptance tests:</b> These test-suites demonstrate/exercise the
22
+ functionality of Selenium.
23
+ </p>
24
+
25
+ <ul>
26
+
27
+ <li>
28
+ <a href="TestRunner.html">Main TestSuite</a> - tests for all of the features that we consider core to Selenium
29
+ </li>
30
+ <li>
31
+ <a href="TestRunner.html?test=tests/TestSuite-InternetExplorer.html">Internet Explorer TestSuite</a> - tests for all core features, plus IE specific features
32
+ </li>
33
+ <li>
34
+ <a href="TestRunner.html?test=tests/TestSuite-Konqueror.html">Konqueror TestSuite</a> - tests that currently pass on Konqueror
35
+ </li>
36
+ <li>
37
+ <a href="TestRunner.html?test=tests/TestSuite-Safari.html">Safari TestSuite</a> - tests that currently pass on Safari
38
+ </li>
39
+ <li>
40
+ <a href="TestRunner.html?test=devtests/TestSuite.html"><i>devtests</i></a>
41
+ - experimental features
42
+ </li>
43
+ <li>
44
+ <a href="TestRunner.html?test=tests/ErrorCheckingTestSuite.html">Error Checking TestSuite</a> - tests for the error verification commands
45
+ </li>
46
+ </ul>
47
+
48
+ <p><b>Unit-tests:</b> Use JsUnit to test Selenium internals.</p>
49
+
50
+ <ul>
51
+
52
+ <li>
53
+ <a id="unitTestLink" href="jsunit/testRunner.html?testPage=BASEURLtests/JsUnitSuite.html">BrowserBot unit-tests</a>
54
+ <br />
55
+ </li>
56
+
57
+ </ul>
58
+
59
+ </body>
60
+ </html>
@@ -0,0 +1,205 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2
+ "http://www.w3.org/TR/html4/loose.dtd">
3
+
4
+ <!--
5
+ Copyright 2004 ThoughtWorks, Inc
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
18
+ -->
19
+ <html>
20
+ <head>
21
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
22
+ <title>JsMock Tests</title>
23
+ <link rel="stylesheet" type="text/css" href="/jsunit/css/jsUnitStyle.css">
24
+ <script language="JavaScript" type="text/javascript" src="/jsunit/app/jsUnitCore.js"></script>
25
+ <script language="JavaScript" type="text/javascript" src="/jsmock/mock.js"></script>
26
+ <script language="JavaScript" type="text/javascript">
27
+
28
+ function testCallingExpectedFunctionShouldPass() {
29
+ var myMock = new Mock()
30
+ myMock.expects("aslak")
31
+ myMock.aslak()
32
+ myMock.verify()
33
+ }
34
+
35
+ function testAccessingExpectedPropertyShouldPass() {
36
+ var myMock = new Mock()
37
+ myMock.expectsProperty("hello").returns("world")
38
+ assertEquals("world", myMock.hello)
39
+ }
40
+
41
+ function testAccessingExpectedPropertyWithObjectShouldPass() {
42
+ var myMock = new Mock()
43
+ ob = [1,2]
44
+ myMock.expectsProperty("hello").returns(ob)
45
+ assertEquals(ob, myMock.hello)
46
+ }
47
+
48
+ function testCallingUnexpectedFunctionShouldFail() {
49
+ var myMock = new Mock()
50
+ try {
51
+ myMock.someMethod()
52
+ } catch(expected) {
53
+ return
54
+ }
55
+ fail("Should fail because someMethod wasn't expected!")
56
+ }
57
+
58
+ function testNotCallingExpectedFunctionShouldFail() {
59
+ var myMock = new Mock()
60
+ myMock.expects("someMethod")
61
+ try {
62
+ myMock.verify()
63
+ } catch(expected) {
64
+ return
65
+ }
66
+ fail("Should fail because someMethod wasn't called!")
67
+ }
68
+
69
+ function testCallingExpectedFunctionWithBadArgumentsShouldFail() {
70
+ var myMock = new Mock()
71
+ myMock.expects("someMethod", "foo")
72
+ try {
73
+ myMock.someMethod("bar")
74
+ } catch(expected) {
75
+ return
76
+ }
77
+ fail("Should fail because bar wasn't the expected arg!")
78
+ }
79
+
80
+ function testCallingExpectedFunctionWithExpectedArgumentsShouldPass() {
81
+ var myMock = new Mock()
82
+ myMock.expects("someMethod", "foo")
83
+ myMock.expects("anotherMethod", "bar", "zap")
84
+ assertUndefined(myMock.someMethod("foo"))
85
+ assertUndefined(myMock.anotherMethod("bar", "zap"))
86
+ }
87
+
88
+ function testCallingExpectedFunctionWithTooFewArgumentsShouldFail() {
89
+ var myMock = new Mock()
90
+ myMock.expects("someMethod", "foo", "bar")
91
+ try {
92
+ myMock.someMethod("foo")
93
+ } catch(expected) {
94
+ return
95
+ }
96
+ fail("Should fail because too few arguments were passed!")
97
+ }
98
+
99
+ function testCallingExpectedFunctionWithTooManyArgumentsShouldFail() {
100
+ var myMock = new Mock()
101
+ myMock.expects("someMethod", "foo")
102
+ try {
103
+ myMock.someMethod("foo", "bar")
104
+ } catch(expected) {
105
+ return
106
+ }
107
+ fail("Should fail because too many arguments were passed!")
108
+ }
109
+
110
+ function testShouldCreateMockInstancesWithoutSideffects() {
111
+ var foo = new Mock()
112
+ var bar = new Mock()
113
+
114
+ foo.expects("foo")
115
+ bar.expects("bar")
116
+
117
+ try {
118
+ bar.foo()
119
+ } catch(expected) {
120
+ return
121
+ }
122
+ fail("Should fail because an unexpected bar was called!")
123
+ }
124
+
125
+ function testCallingExpectedFunctionWithReturnShouldReturnValue() {
126
+ var myMock = new Mock()
127
+ myMock.expects("someMethod", "bar").returns("foo")
128
+ myMock.expects("theOtherMethod", "zap", "ping", "pong").returns("bang")
129
+ assertEquals("foo", myMock.someMethod("bar"))
130
+ assertEquals("bang", myMock.theOtherMethod("zap", "ping", "pong"))
131
+ myMock.verify()
132
+ }
133
+
134
+ function testCallingExpectedFunctionWithThrowsShouldThrowError() {
135
+ var myMock = new Mock();
136
+ myMock.expects("someMethod", "bar").andThrows("failure")
137
+ try {
138
+ myMock.someMethod("bar")
139
+ } catch (e) {
140
+ assertEquals("failure", e.message);
141
+ return
142
+ }
143
+ fail("Mock did not throw exception when required");
144
+ }
145
+
146
+ function testSettingExpectedPropertyShouldPass() {
147
+ var myMock = new Mock()
148
+ myMock.expectsProperty("foo", "bar")
149
+ myMock.foo = "bar"
150
+ myMock.verify()
151
+ }
152
+
153
+ function TODO_testSettingUnexpectedPropertyShouldFail() {
154
+ var myMock = new Mock()
155
+ myMock.foo = "bar"
156
+
157
+ try {
158
+ myMock.verify()
159
+ } catch(expected) {
160
+ return
161
+ }
162
+ fail("Should fail because an unexpected property was set!")
163
+ }
164
+
165
+ function TODO_testShouldAllowExpectationOfSameFunctionWithDifferentArguments() {
166
+ var myMock = new Mock()
167
+ myMock.expects("aslak", "hello").returns("world")
168
+ myMock.expects("aslak", "bonjour").returns("monde")
169
+ assertEquals("world", myMock.aslak("hello"))
170
+ assertEquals("monde", myMock.aslak("bonjour"))
171
+ myMock.verify()
172
+ }
173
+
174
+ function TODO_testNotSettingExpectedPropertyShouldFail() {
175
+ var myMock = new Mock()
176
+ myMock.expectsProperty("foo", "bar")
177
+ try {
178
+ myMock.verify()
179
+ } catch(expected) {
180
+ return
181
+ }
182
+ fail("Should fail because an expected property was not set!")
183
+ }
184
+
185
+ function TODO_testSettingExpectedPropertyWithUnexpectedValueShouldFail() {
186
+ var myMock = new Mock()
187
+ myMock.expectsProperty("foo", "bar")
188
+ myMock.foo="zap"
189
+ try {
190
+ myMock.verify()
191
+ } catch(expected) {
192
+ return
193
+ }
194
+ fail("Should fail because an expected property was set with unexpected value!")
195
+ }
196
+
197
+ </script>
198
+ </head>
199
+
200
+ <body>
201
+ <h1>JsMock Tests</h1>
202
+
203
+ <p>This page contains tests for JsMock. To see them, take a look at the source. To run them, load this file via JsUnit's testRunner.html</p>
204
+ </body>
205
+ </html>