testloop-handle-error-tests.html 4.05 KB
Newer Older
Rafael Monnerat's avatar
Rafael Monnerat committed
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">

<!--
Copyright 2004 ThoughtWorks, Inc

 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.
-->
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JsUnit Utility Tests</title>
    <link rel="stylesheet" type="text/css" href="jsunit/css/jsUnitStyle.css">
    <script language="JavaScript" type="text/javascript" src="../../jsunit/app/jsUnitCore.js"></script>
    <script language="JavaScript" type="text/javascript" src="../jsmock/mock.js"></script>
    <script language="JavaScript" type="text/javascript" src="../../core/lib/prototype.js"></script>
    <script language="JavaScript" type="text/javascript" src="../../core/scripts/htmlutils.js"></script>
    <script language="JavaScript" type="text/javascript" src="../../core/scripts/selenium-api.js"></script>
    <script language="JavaScript" type="text/javascript" src="../../core/scripts/selenium-browserdetect.js"></script>
    <script language="JavaScript" type="text/javascript" src="../../core/scripts/selenium-browserbot.js"></script>
    <script language="JavaScript" type="text/javascript" src="../../core/scripts/selenium-executionloop.js"></script>
    <script language="JavaScript" type="text/javascript" src="../../core/scripts/selenium-testrunner.js"></script>
    <script language="JavaScript" type="text/javascript" src="../../core/scripts/selenium-commandhandlers.js"></script>
    <script language="JavaScript" type="text/javascript">
        function setUp() {
            commandFactory = new Mock();
            // DGF We want to do assertions on the LOG, but only after setup
            LOG = { info: function() {} };
            
            selenium = new Selenium();
            global = new Object();
            htmlTestCase = new Object();
            htmlTestCase.reset = function() {
            };
            htmlTestCase.testDocument = document;
            seleniumTest = new HtmlRunnerTestLoop(htmlTestCase, false, commandFactory);
            // We want to verify that testLoop.commandError() function is called appropriately
            // by testLoop.handleCommandError()
            LOG = new Mock();   
            commandErrorHandler = new Mock();
            seleniumTest.commandError = function(message) {
                commandErrorHandler.handleError(message);
            };
        };

        function verifyMocks() {
            commandFactory.verify();
            LOG.verify();
            commandErrorHandler.verify();
        }

        function testOrdinaryCommandError() {
            var error = new SeleniumError("Test Error");
            LOG.expects("error", "Test Error");
            commandErrorHandler.expects("handleError", "Test Error");
            seleniumTest._handleCommandError(error);
        };

        function testSeleniumMalfunction() {
            var error = new Error("Test Error");
            LOG.expects("exception", error);
            commandErrorHandler.expects("handleError", "Selenium failure. Please report to the Selenium Users forum at http://forums.openqa.org, with error details from the log window.  The error message is: Test Error");
            seleniumTest._handleCommandError(error);
        };

    </script>
</head>

<body>
<a href="#" id="testLink">Test Link</a>

<p>
    This page contains tests for the SeleniumTest : handleCommandError()
    To see them, take a look at the source. To run them, load this file via JsUnit's testRunner.html
</p>
</body>
</html>