// Copyright 2007 The Closure Library Authors. 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. /** * @fileoverview Utilities for working with JsUnit. Writes out the JsUnit file * that needs to be included in every unit test. * * Testing code should not have dependencies outside of goog.testing so as to * reduce the chance of masking missing dependencies. * */ goog.provide('goog.testing.jsunit'); goog.require('goog.testing.TestCase'); goog.require('goog.testing.TestRunner'); /** * Base path for JsUnit app files, relative to Closure's base path. * @type {string} */ goog.testing.jsunit.BASE_PATH = '../../third_party/java/jsunit/core/app/'; /** * Filename for the core JS Unit script. * @type {string} */ goog.testing.jsunit.CORE_SCRIPT = goog.testing.jsunit.BASE_PATH + 'jsUnitCore.js'; /** * @define {boolean} If this code is being parsed by JsTestC, we let it disable * the onload handler to avoid running the test in JsTestC. */ goog.define('goog.testing.jsunit.AUTO_RUN_ONLOAD', true); /** * @define {number} Sets a delay in milliseconds after the window onload event * and running the tests. Used to prevent interference with Selenium and give * tests with asynchronous operations time to finish loading. */ goog.define('goog.testing.jsunit.AUTO_RUN_DELAY_IN_MS', 500); (function() { // Increases the maximum number of stack frames in Google Chrome from the // default 10 to 50 to get more useful stack traces. Error.stackTraceLimit = 50; // Store a reference to the window's timeout so that it can't be overridden // by tests. /** @type {!Function} */ var realTimeout = window.setTimeout; // Check for JsUnit's test runner (need to check for >2.2 and <=2.2) if (top['JsUnitTestManager'] || top['jsUnitTestManager']) { // Running inside JsUnit so add support code. var path = goog.basePath + goog.testing.jsunit.CORE_SCRIPT; document.write('