rubinium 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,115 @@
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>Test for the CommandHandler</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" src="/selenium-commandhandlers.js"></script>
27
+ <script language="JavaScript" type="text/javascript" src="/htmlutils.js"></script>
28
+ <script language="JavaScript" type="text/javascript">
29
+
30
+ function testCommandHandlerExecuteCallsTheExecutorFunction() {
31
+ var called = false;
32
+ var executor = function() { called = true;};
33
+ var handler = new CommandHandler("name", false, executor);
34
+ handler.execute("selenium", "command");
35
+
36
+ assertTrue(called);
37
+ }
38
+
39
+
40
+ function testShouldFailActionCommandsIfAlertPresent() {
41
+
42
+ mockBrowserBot = new Mock();
43
+
44
+ function MockSelenium() {
45
+ this.browserbot = mockBrowserBot;
46
+ }
47
+
48
+ mockBrowserBot.expects("hasAlerts").returns(true);
49
+ mockBrowserBot.expects("getNextAlert").returns("The Alert");
50
+
51
+ var executorCalled = false;
52
+ var executor = function() { executorCalled = true;};
53
+ var handler = new ActionHandler(executor, false);
54
+ try {
55
+ handler.execute(new MockSelenium(), "command");
56
+ fail("Command Should have failed");
57
+ } catch ( e ) {
58
+ assertTrue(e.isSeleniumError);
59
+ assertEquals("There was an unexpected Alert! [The Alert]", e.message);
60
+ }
61
+
62
+ assertFalse(executorCalled);
63
+ mockBrowserBot.verify();
64
+ }
65
+
66
+ function testShouldFailActionCommandsIfConfirmPresent() {
67
+
68
+ mockBrowserBot = new Mock();
69
+
70
+ function MockSelenium() {
71
+ this.browserbot = mockBrowserBot;
72
+ }
73
+
74
+ mockBrowserBot.expects("hasAlerts").returns(false);
75
+ mockBrowserBot.expects("hasConfirmations").returns(true);
76
+ mockBrowserBot.expects("getNextConfirmation").returns("The Confirmation");
77
+
78
+ var executorCalled = false;
79
+ var executor = function() { executorCalled = true;};
80
+ var handler = new ActionHandler(executor, false);
81
+ try {
82
+ handler.execute(new MockSelenium(), "command");
83
+ fail("Command Should have failed");
84
+ } catch ( e ) {
85
+ assertTrue(e.isSeleniumError);
86
+ assertEquals("There was an unexpected Confirmation! [The Confirmation]", e.message);
87
+ }
88
+
89
+ assertFalse(executorCalled);
90
+ mockBrowserBot.verify();
91
+ }
92
+
93
+ function testAccessorHandlerShouldReturnResultInCommandResult() {
94
+ function MockSelenium() {
95
+ }
96
+
97
+ var executorCalled = false;
98
+ var executor = function() { executorCalled = true; return "foo"; };
99
+ var handler = new AccessorHandler(executor, false);
100
+
101
+ result = handler.execute(new MockSelenium(), "command");
102
+
103
+ assertTrue(executorCalled);
104
+ assertEquals("foo", result.result);
105
+ }
106
+
107
+ </script>
108
+ </head>
109
+
110
+ <body>
111
+ <h1>CommandHandler component tests</h1>
112
+
113
+ <p>This page contains tests for different components in the CommandHandler. To see them, take a look at the source. To run them, load this file via JsUnit's testRunner.html</p>
114
+ </body>
115
+ </html>
@@ -0,0 +1,97 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2
+ "http://www.w3.org/TR/html4/loose.dtd">
3
+ <!--
4
+ Copyright 2004 ThoughtWorks, Inc
5
+
6
+ Licensed under the Apache License, Version 2.0 (the "License");
7
+ you may not use this file except in compliance with the License.
8
+ You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing, software
13
+ distributed under the License is distributed on an "AS IS" BASIS,
14
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ See the License for the specific language governing permissions and
16
+ limitations under the License.
17
+ -->
18
+ <html>
19
+ <head>
20
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
21
+ <title>JsUnit Utility Tests</title>
22
+ <link rel="stylesheet" type="text/css" href="/jsunit/css/jsUnitStyle.css">
23
+ <script language="JavaScript" type="text/javascript" src="/jsunit/app/jsUnitCore.js"></script>
24
+ <script language="JavaScript" type="text/javascript" src="/jsmock/mock.js"></script>
25
+ <script language="JavaScript" type="text/javascript" src="/selenium-logging.js"></script>
26
+
27
+ <script language="JavaScript" type="text/javascript" src="/selenium-browserbot.js"></script>
28
+ <script language="JavaScript" type="text/javascript" src="/htmlutils.js"></script>
29
+ <script language="JavaScript" type="text/javascript">
30
+
31
+
32
+
33
+ function setUp() {
34
+ LOG = new DummyLogger();
35
+ testFrame = document.getElementById("frame");
36
+ testWindow = testFrame.contentWindow;
37
+ browserBot = BrowserBot.createForFrame(testFrame);
38
+ browserBot.getCurrentPage();
39
+ }
40
+
41
+ function testShouldConfirmConfirmationsByDefault() {
42
+ assertTrue( testWindow.confirm("Continue?"));
43
+ }
44
+
45
+ function testShouldCancelConfirmationIfPreviouslyInstructedTo() {
46
+ browserBot.cancelNextConfirmation();
47
+ assertFalse( testWindow.confirm("Continue?"));
48
+ }
49
+
50
+ function testShouldRevertToDefaultBehaviourAfterCancellingConfirmation() {
51
+ browserBot.cancelNextConfirmation();
52
+ testWindow.confirm("Continue?");
53
+ testShouldConfirmConfirmationsByDefault();
54
+ }
55
+
56
+ function testShouldNotReportAnyConfirmationsIfNoneHaveBeenGenerated() {
57
+ assertFalse(browserBot.hasConfirmations());
58
+ assertUndefined(browserBot.getNextConfirmation());
59
+ }
60
+
61
+ function testShouldReportSingleConfirmationIfGenerated() {
62
+ testWindow.confirm("Continue?");
63
+
64
+ assertTrue(browserBot.hasConfirmations());
65
+ assertEquals("Continue?", browserBot.getNextConfirmation());
66
+ }
67
+
68
+ function testShouldReportMultipleConfirmationsInOrderIfGenerated() {
69
+ testWindow.confirm("Continue?");
70
+ testWindow.confirm("Really Continue?");
71
+
72
+ assertTrue(browserBot.hasConfirmations());
73
+ assertEquals("Continue?", browserBot.getNextConfirmation());
74
+ assertTrue(browserBot.hasConfirmations());
75
+ assertEquals("Really Continue?", browserBot.getNextConfirmation());
76
+ assertFalse(browserBot.hasConfirmations());
77
+ }
78
+
79
+ function testShouldRemoveConfirmationWhenItIsRetreived() {
80
+ testWindow.confirm("Continue?");
81
+
82
+ assertTrue(browserBot.hasConfirmations());
83
+ assertNotUndefined(browserBot.getNextConfirmation());
84
+ assertFalse(browserBot.hasConfirmations());
85
+ assertUndefined(browserBot.getNextConfirmation());
86
+ }
87
+
88
+
89
+ </script>
90
+ </head>
91
+
92
+ <body>
93
+ <h1>Selenium PageBot Confirm Handling Tests</h1>
94
+ <iframe NAME="frame" ID="frame" SRC=""></iframe>
95
+
96
+ </body>
97
+ </html>
@@ -0,0 +1,198 @@
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>JsUnit Utility 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" src="/htmlutils.js"></script>
27
+ <script language="JavaScript" type="text/javascript" src="/selenium-api.js"></script>
28
+ <script language="JavaScript" type="text/javascript" src="/selenium-executionloop.js"></script>
29
+ <script language="JavaScript" type="text/javascript" src="/selenium-commandhandlers.js"></script>
30
+ <script language="JavaScript" type="text/javascript">
31
+ function setUp() {
32
+ commandFactory = new Mock();
33
+ testLoop = new TestLoop(commandFactory);
34
+
35
+ selenium = new Selenium();
36
+ };
37
+
38
+ function verifyMocks() {
39
+ commandFactory.verify();
40
+ }
41
+
42
+ function testMustProvideMessageToExpectFailure() {
43
+ try {
44
+ selenium.assertFailureOnNext();
45
+ }
46
+ catch (expected) {
47
+ return;
48
+ }
49
+ fail("Message is a required parameter");
50
+ };
51
+
52
+ function testCommandFactoryIsTemporarilyReplacedByExpectFailureOnNext() {
53
+ var failingCommand = new Mock();
54
+ failingCommand.expects("execute").returns({failed:true, failureMessage: "Expected failure message"});
55
+ commandFactory.expects("getCommandHandler", "cmd").returns(failingCommand);
56
+
57
+ selenium.assertFailureOnNext("Expected failure message");
58
+
59
+ assertTrue(commandFactory != testLoop.commandFactory);
60
+
61
+ testLoop.commandFactory.getCommandHandler("cmd").execute();
62
+
63
+ assertTrue(commandFactory === testLoop.commandFactory);
64
+
65
+ verifyMocks();
66
+ };
67
+
68
+ function testExpectFailureSucceedsWhenSubsequentCommandFails() {
69
+ var failingCommand = new Mock();
70
+ failingCommand.expects("execute").returns({failed:true, failureMessage: "Expected failure message"});
71
+ commandFactory.expects("getCommandHandler", "cmd").returns(failingCommand);
72
+
73
+ selenium.assertFailureOnNext("Expected failure message");
74
+ var result = testLoop.commandFactory.getCommandHandler("cmd").execute();
75
+ assertTrue(result.passed);
76
+ verifyMocks();
77
+ };
78
+
79
+ function testExpectFailureFailsWhenSubsequentCommandFailsWithTheWrongMessage() {
80
+ var failingCommand = new Mock();
81
+ failingCommand.expects("execute").returns({failed:true, failureMessage: "foo"});
82
+ var originalCommandFactory = testLoop.commandFactory;
83
+ originalCommandFactory.expects("getCommandHandler", "cmd").returns(failingCommand);
84
+
85
+ selenium.assertFailureOnNext("bar");
86
+ var result = testLoop.commandFactory.getCommandHandler("cmd").execute();
87
+ assertTrue(result.failed);
88
+ assertEquals("Expected failure message 'bar' but was 'foo'", result.failureMessage);
89
+ verifyMocks();
90
+ };
91
+
92
+ function testExpectFailureFailsWhenSubsequentCommandPasses() {
93
+ var successCommand = new Mock();
94
+ successCommand.expects("execute").returns({passed:true});
95
+ var originalCommandFactory = testLoop.commandFactory;
96
+ originalCommandFactory.expects("getCommandHandler", "foo").returns(successCommand);
97
+
98
+ selenium.assertFailureOnNext("Expected failure message");
99
+ var result = testLoop.commandFactory.getCommandHandler("foo").execute();
100
+ assertTrue(result.failed);
101
+ assertEquals("Command should have failed.", result.failureMessage);
102
+ verifyMocks();
103
+ };
104
+
105
+ function testExpectFailurePropogatesCommandErrors() {
106
+ var errorCommand = new Mock();
107
+ errorCommand.expects("execute").andThrows("error message");
108
+ commandFactory.expects("getCommandHandler", "foo").returns(errorCommand);
109
+
110
+ selenium.assertFailureOnNext("Expected failure message");
111
+ try {
112
+ testLoop.commandFactory.getCommandHandler("foo").execute();
113
+ }
114
+ catch (expected) {
115
+ verifyMocks();
116
+ return;
117
+ }
118
+ fail("Command error should not be caught by expect failure.");
119
+ };
120
+
121
+ function testMustProvideMessageToExpectError() {
122
+ try {
123
+ selenium.assertErrorOnNext();
124
+ }
125
+ catch (expected) {
126
+ return;
127
+ }
128
+ fail("Message is a required parameter");
129
+ };
130
+
131
+ function testCommandFactoryIsTemporarilyReplacedByExpectErrorOnNext() {
132
+ var errorCommand = new Mock();
133
+ errorCommand.expects("execute").andThrows("error message");
134
+ commandFactory.expects("getCommandHandler", "cmd").returns(errorCommand);
135
+
136
+ selenium.assertErrorOnNext("Error: error message");
137
+
138
+ assertTrue(commandFactory != testLoop.commandFactory);
139
+
140
+ testLoop.commandFactory.getCommandHandler("cmd").execute();
141
+
142
+ assertTrue(commandFactory === testLoop.commandFactory);
143
+ verifyMocks();
144
+ };
145
+
146
+ function testExpectErrorSucceedsWhenSubsequentCommandErrors() {
147
+ var errorCommand = new Mock();
148
+ errorCommand.expects("execute").andThrows("error message");
149
+ commandFactory.expects("getCommandHandler", "cmd").returns(errorCommand);
150
+
151
+ selenium.assertErrorOnNext("error message");
152
+ var result = testLoop.commandFactory.getCommandHandler("cmd").execute();
153
+ assertTrue(result.passed);
154
+ verifyMocks();
155
+ };
156
+
157
+ function testExpectErrorFailsWhenSubsequentCommandErrorsWithTheWrongMessage() {
158
+ var errorCommand = new Mock();
159
+ errorCommand.expects("execute").andThrows("Error: foo");
160
+ commandFactory.expects("getCommandHandler", "cmd").returns(errorCommand);
161
+
162
+ selenium.assertErrorOnNext("Error: bar");
163
+ var result = testLoop.commandFactory.getCommandHandler("cmd").execute();
164
+ assertTrue(result.failed);
165
+ assertEquals("Expected failure message 'Error: bar' but was 'Error: foo'", result.failureMessage);
166
+ verifyMocks();
167
+ };
168
+
169
+ function testExpectErrorFailsWhenSubsequentCommandPasses() {
170
+ var successCommand = new Mock();
171
+ successCommand.expects("execute").returns({passed:true});
172
+ commandFactory.expects("getCommandHandler", "foo").returns(successCommand);
173
+
174
+ selenium.assertErrorOnNext("Expected failure message");
175
+ var result = testLoop.commandFactory.getCommandHandler("foo").execute();
176
+ assertTrue(result.failed);
177
+ assertEquals("Command should have failed.", result.failureMessage);
178
+ verifyMocks();
179
+ };
180
+
181
+ function testExpectErrorFailsWhenSubsequentCommandFails() {
182
+ var failingCommand = new Mock();
183
+ failingCommand.expects("execute").returns({failed:true, failureMessage: "Expected failure message"});
184
+ commandFactory.expects("getCommandHandler", "cmd").returns(failingCommand);
185
+
186
+ selenium.assertErrorOnNext("Expected failure message");
187
+ var result = testLoop.commandFactory.getCommandHandler("cmd").execute();
188
+ assertTrue(result.failed);
189
+ assertEquals("Command should have failed.", result.failureMessage);
190
+ verifyMocks();
191
+ };
192
+ </script>
193
+ </head>
194
+
195
+ <body>
196
+ <p>This page contains tests for the ExpectFailureCommandFactory object. To see them, take a look at the source. To run them, load this file via JsUnit's testRunner.html</p>
197
+ </body>
198
+ </html>
@@ -0,0 +1,106 @@
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>JsUnit Utility 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
+
27
+ <script language="JavaScript" type="text/javascript" src="/selenium-browserbot.js"></script>
28
+ <script language="JavaScript" type="text/javascript" src="/htmlutils.js"></script>
29
+ <script language="JavaScript" type="text/javascript">
30
+
31
+ function setUp() {
32
+ pageBot = PageBot.createForWindow(window);
33
+
34
+ theForm = document.getElementById("theFormElement");
35
+ theTextbox = document.getElementById("theTextboxElement");
36
+ }
37
+
38
+ function testFocusEventNeverBubbles() {
39
+ var textboxFocus = false;
40
+ var formFocus = false;
41
+ theTextbox.onfocus = function() {textboxFocus = true};
42
+ theForm.onfocus = function() {formFocus = true};
43
+
44
+ pageBot.replaceText(theTextbox, 'foo1');
45
+
46
+ assertTrue(textboxFocus);
47
+ assertFalse(formFocus);
48
+ }
49
+
50
+ function testSelectEventCanBubbleInFirefoxButNotInIE() {
51
+ assertTrue(true);
52
+ var textboxSelect = false;
53
+ var formSelect = false;
54
+ theTextbox.onselect = function() {textboxSelect = true};
55
+ theForm.onselect = function() {formSelect = true};
56
+
57
+ pageBot.replaceText(theTextbox, 'foo1');
58
+
59
+ assertTrue(textboxSelect);
60
+ if (isIE) {
61
+ assertFalse(formSelect);
62
+ } else {
63
+ assertTrue(formSelect);
64
+ }
65
+ }
66
+
67
+ function testChangeEventCanBubbleInFirefoxButNotInIE() {
68
+ var textboxChange = false;
69
+ var formChange = false;
70
+ theTextbox.onchange = function() {textboxChange = true};
71
+ theForm.onchange = function() {formChange = true};
72
+
73
+ pageBot.replaceText(theTextbox, 'foo2');
74
+
75
+ assertTrue(textboxChange);
76
+ if (isIE) {
77
+ assertFalse(formChange);
78
+ } else {
79
+ assertTrue(formChange);
80
+ }
81
+ }
82
+
83
+ function testClickEventAlwaysBubbles() {
84
+ var buttonClick = false;
85
+ var formClick = false;
86
+ var theButton = document.getElementById("theButtonElement")
87
+ theButton.onclick = function() {buttonClick = true};
88
+ theForm.onclick = function() {formClick = true};
89
+
90
+ pageBot.clickElement(theButton);
91
+
92
+ assertTrue(buttonClick);
93
+ assertTrue(formClick);
94
+ }
95
+ </script>
96
+ </head>
97
+
98
+ <body>
99
+ <h1>Selenium Browserbot Tests</h1>
100
+
101
+ <form id="theFormElement" name="theFormElement">
102
+ <input name="theTextboxElement" id="theTextboxElement" type="text" value="theTextbox"/>
103
+ <input name="theButtonElement" id="theButtonElement" type="button" value="theButton"/>
104
+ </form>
105
+ </body>
106
+ </html>