Commits

carkraus committed 8833f7c

use plovr also in all_tests.html. move some files around

Comments (0)

Files changed (11)

all_tests.html

-<!DOCTYPE html>
-<html>
-<!--
-Copyright 2009 The Closure Library Authors. All Rights Reserved.
-
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<head>
-<title>Closure - All JsUnit Tests</title>
-<script src="closure-lib/closure/goog/base.js"></script>
-<script src="alltests.js"></script>
-<script>
-goog.require('goog.userAgent.product');
-goog.require('goog.testing.MultiTestRunner');
-</script>
-<link rel="stylesheet" href="closure-lib/closure/goog/css/multitestrunner.css" type="text/css">
-<style>
-h1 {
-  font: normal x-large arial, helvetica, sans-serif;
-  margin: 0;
-}
-p, form {
-  font: normal small sans-serif;
-  margin: 0;
-}
-#header {
-  position: absolute;
-  right: 10px;
-  top: 13px;
-}
-#footer {
-  margin-top: 8px;
-}
-a {
-  text-decoration: none;
-}
-a:hover {
-  text-decoration: underline;
-}
-.warning {
-  font-size: 14px;
-  font-weight: bold;
-  width: 80%;
-}
-</style>
-</head>
-<body>
-
-<script>
-  if (goog.userAgent.product.CHROME &&
-      window.location.toString().indexOf('file:') == 0) {
-    document.write(
-        '<div class="warning">' +
-        'WARNING: Due to Chrome\'s security restrictions ' +
-        'this test will not be able to load files off your local disk ' +
-        'unless you start Chrome with:<br>' +
-        '<code>--allow-file-access-from-files</code></div><br>');
-  }
-</script>
-
-<h1>Closure - All JsUnit Tests</h1>
-<p id="header">
-  <a href="http://wiki/Main/ClosureUnitTests">Closure JS Testing HOWTO</a>
-</p>
-<div id="runner"></div>
-<!--  Use a form so browser persists input values -->
-<form id="footer" onsubmit="return false">
-  Settings:<br>
-  <input type="checkbox" name="hidepasses" id="hidepasses" checked>
-  <label for="hidepasses">Hide passes</label><br>
-  <input type="checkbox" name="parallel" id="parallel" checked>
-  <label for="parallel">Run in parallel</label>
-  <small>(timing stats not available if enabled)</small><br>
-  <input type="text" name="filter" id="filter" value="">
-  <label for="filter">Run only tests for path</label>
-</form>
-<script>
-  var hidePassesInput = document.getElementById('hidepasses');
-  var parallelInput = document.getElementById('parallel');
-  var filterInput = document.getElementById('filter');
-
-  function setFilterFunction() {
-    var matchValue = filterInput.value || '';
-    testRunner.setFilterFunction(function(testPath) {
-      return testPath.indexOf(matchValue) > -1;
-    });
-  }
-
-  // Create a test runner and render it.
-  var testRunner = new goog.testing.MultiTestRunner()
-      .setName(document.title)
-      .setBasePath('./')
-      .setPoolSize(parallelInput.checked ? 8 : 1)
-      .setStatsBucketSizes(5, 500)
-      .setHidePasses(hidePassesInput.checked)
-      //.setVerbosePasses(true)
-      .addTests(_allTests);
-  testRunner.render(document.getElementById('runner'));
-
-  goog.events.listen(hidePassesInput, 'click', function(e) {
-    testRunner.setHidePasses(e.target.checked);
-  });
-
-  goog.events.listen(parallelInput, 'click', function(e) {
-    testRunner.setPoolSize(e.target.checked ? 8 : 1);
-  });
-
-  goog.events.listen(filterInput, 'keyup', setFilterFunction);
-  setFilterFunction();
-</script>
-</body>
-</html>

alltests.js

-var _allTests = [
-    "src/foo_test.html"
-//    "closure/goog/asserts/asserts_test.html",
-//    "closure/goog/async/conditionaldelay_test.html",
-//    "closure/goog/async/delay_test.html",
-//    "closure/goog/async/throttle_test.html",
-//    "closure/goog/base_test.html"
-];

etc/plovr.json

-{
-    "id": "tests",
-    "paths":["../src"],
-    "inputs":["testing_requirements.js"],
-    "mode":"advanced",
-    "level":"verbose"
-//   ,"disambiguate-properties":true
-//   ,"ambiguate-properties":true
-//  , "debug":true
-//  , "pretty-print":true
-}   

etc/testing_requirements.js

-/**
- * @fileoverview Usage example.
- * @author Carsten Kraus <carsten.kraus@gmail.com>
- */
-goog.require('goog.array');
-goog.require('goog.dom');
-goog.require('goog.events.KeyCodes');
-goog.require('goog.testing.asserts');
-goog.require('goog.testing.events');
-goog.require('goog.testing.jsunit');
-
-
-/** Own deps **/
-goog.require('foo.Foo');
-
-
-
-// Silence dumb compilation warnings
-//goog.addDependency('', [
-//  'goog.Uri',
-//  'goog.net.XhrLite',
-//  'goog.debug.ErrorHandler',
-//  'goog.ui.Control'
-//], []);
-

src/bar.js

Empty file removed.
 foo.Foo.prototype.didTheFoo_ = false;
 
 foo.Foo.prototype.doTheFoo = function() {
-    this.didTheFoo_ = true;
-    console.log('do the foo and now: ', this.didTheFoo_);
+  this.didTheFoo_ = true;
+  goog.global.console['log']('do the foo and now: ', this.didTheFoo_);
 }

src/foo_test.html

 <!DOCTYPE html>
 <html>
-<!--
-Copyright 2009 The Closure Library Authors. All Rights Reserved.
+  <head>
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <title>Foo unit tests</title>
+    <script src="http://localhost:9810/compile?id=tests&mode=raw"></script>
+  </head>
+  <body>
+    
+    <div>some dom</div>
+    
+    <script type="text/javascript">
+      var myFoo;
 
-Use of this source code is governed by the Apache License, Version 2.0.
-See the COPYING file for details.
--->
-<!--
--->
-<head>
-<meta http-equiv="X-UA-Compatible" content="IE=edge">
-  <title>Closure Unit Tests - Foo</title>
-  <script src="http://localhost:9810/compile?id=tests&mode=raw"></script>
-  <script>
-    goog.require('goog.array');
-    goog.require('goog.dom');
-    goog.require('goog.events.KeyCodes');
-    goog.require('goog.testing.asserts');
-    goog.require('goog.testing.events');
-    goog.require('goog.testing.jsunit');
-  </script>
-</head>
-<body>
-<div>
-  <span id="normal" class="goog-checkbox"></span>
-  <span id="checked" class="goog-checkbox goog-checkbox-checked"></span>
-  <span id="unchecked" class="goog-checkbox goog-checkbox-unchecked"></span>
-  <span id="undetermined" class="goog-checkbox goog-checkbox-undetermined"></span>
-  <span id="disabled" class="goog-checkbox goog-checkbox-disabled"></span>
-</div>
-<script type="text/javascript">
-  var foo;
+      function setUp() {
+        myFoo = new foo.Foo();
+      }
 
-  function setUp() {
-    foo = new foo.Foo();
-    alert('SETUP');
-  }
-
-  function tearDown() {
-    delete foo;
-  }
+      function tearDown() {
+        delete myFoo;
+      }
   
-  function testTest() {
-      assertTrue(true);
-  }
-
-//  function testClassNames() {
-//    checkbox.createDom();
-//
-//    checkbox.setChecked(false);
-//    assertSameElements('classnames of unchecked checkbox',
-//        ['goog-checkbox', 'goog-checkbox-unchecked'],
-//        goog.dom.classes.get(checkbox.getElement()));
-//
-//    checkbox.setChecked(true);
-//    assertSameElements('classnames of checked checkbox',
-//        ['goog-checkbox', 'goog-checkbox-checked'],
-//        goog.dom.classes.get(checkbox.getElement()));
-//
-//    checkbox.setChecked(null);
-//    assertSameElements('classnames of partially checked checkbox',
-//        ['goog-checkbox', 'goog-checkbox-undetermined'],
-//        goog.dom.classes.get(checkbox.getElement()));
-//
-//    checkbox.setEnabled(false);
-//    assertSameElements('classnames of partially checked disabled checkbox',
-//        ['goog-checkbox',
-//         'goog-checkbox-undetermined',
-//         'goog-checkbox-disabled'],
-//        goog.dom.classes.get(checkbox.getElement()));
-//  }
-//
-//  function testIsEnabled() {
-//    assertTrue('enabled by default', checkbox.isEnabled());
-//    checkbox.setEnabled(false);
-//    assertFalse('has been disabled', checkbox.isEnabled());
-//  }
-//
-//  function testCheckedState() {
-//    assertTrue('unchecked by default', !checkbox.isChecked() &&
-//        checkbox.isUnchecked() && !checkbox.isUndetermined());
-//
-//    checkbox.setChecked(true);
-//    assertTrue('set to checked', checkbox.isChecked() &&
-//        !checkbox.isUnchecked() && !checkbox.isUndetermined());
-//
-//    checkbox.setChecked(null);
-//    assertTrue('set to partially checked', !checkbox.isChecked() &&
-//        !checkbox.isUnchecked() && checkbox.isUndetermined());
-//  }
-//
-//  function testToggle() {
-//    checkbox.setChecked(null);
-//    checkbox.toggle();
-//    assertTrue('undetermined -> checked', checkbox.getChecked());
-//    checkbox.toggle();
-//    assertFalse('checked -> unchecked', checkbox.getChecked());
-//    checkbox.toggle();
-//    assertTrue('unchecked -> checked', checkbox.getChecked());
-//  };
-//
-//  function testEvents() {
-//    checkbox.render();
-//
-//    var events = []
-//    goog.events.listen(checkbox,
-//        [goog.ui.Component.EventType.CHECK,
-//         goog.ui.Component.EventType.UNCHECK,
-//         goog.ui.Component.EventType.CHANGE],
-//        function(e) {
-//          events.push(e.type);
-//        });
-//
-//    checkbox.setEnabled(false);
-//    goog.testing.events.fireClickSequence(checkbox.getElement());
-//    assertArrayEquals('disabled => no events', [], events);
-//    assertFalse('checked state did not change', checkbox.getChecked());
-//    events = [];
-//
-//    checkbox.setEnabled(true);
-//    goog.testing.events.fireClickSequence(checkbox.getElement());
-//    assertArrayEquals('CHECK+CHANGE fired', ['check', 'change'], events);
-//    assertTrue('checkbox became checked', checkbox.getChecked());
-//    events = [];
-//
-//    goog.testing.events.fireClickSequence(checkbox.getElement());
-//    assertArrayEquals('UNCHECK+CHANGE fired', ['uncheck', 'change'], events);
-//    assertFalse('checkbox became unchecked', checkbox.getChecked());
-//    events = [];
-//
-//    goog.events.listen(checkbox, goog.ui.Component.EventType.CHECK,
-//        function(e) {
-//          e.preventDefault();
-//        });
-//    goog.testing.events.fireClickSequence(checkbox.getElement());
-//    assertArrayEquals('CHECK event fired', ['check'], events);
-//    assertFalse('toggling has been prevented', checkbox.getChecked());
-//  }
-//
-//  function testLabel() {
-//    var label = goog.dom.createElement('div');
-//    document.body.appendChild(label);
-//    try {
-//      checkbox.setChecked(false);
-//      checkbox.setLabel(label);
-//      checkbox.render(label);
-//
-//      goog.testing.events.fireClickSequence(label);
-//      assertTrue('checkbox toggled if the label is clicked',
-//          checkbox.getChecked());
-//      goog.testing.events.fireClickSequence(checkbox.getElement());
-//      assertFalse('checkbox toggled if it is clicked', checkbox.getChecked());
-//
-//      checkbox.setLabel(null);
-//      goog.testing.events.fireClickSequence(label);
-//      assertFalse('label element deactivated', checkbox.getChecked());
-//      goog.testing.events.fireClickSequence(checkbox.getElement());
-//      assertTrue('checkbox still active', checkbox.getChecked());
-//    } finally {
-//      document.body.removeChild(label);
-//    }
-//  }
-//
-//  function testConstructor() {
-//    assertEquals('state is unchecked', goog.ui.Checkbox.State.UNCHECKED,
-//        checkbox.getChecked());
-//
-//    var testCheckboxWithState = new goog.ui.Checkbox(
-//        goog.ui.Checkbox.State.UNDETERMINED);
-//    assertNotNull('checkbox created with custom state', testCheckboxWithState);
-//    assertEquals('checkbox state is undetermined',
-//        goog.ui.Checkbox.State.UNDETERMINED,
-//        testCheckboxWithState.getChecked());
-//    testCheckboxWithState.dispose();
-//  }
-//
-//  function testGetAriaRole() {
-//    checkbox.createDom();
-//
-//    assertEquals("Checkbox's ARIA role should be 'checkbox'",
-//        goog.dom.a11y.Role.CHECKBOX,
-//        goog.dom.a11y.getRole(checkbox.getElement()));
-//  }
-//
-//  function testUpdateAriaState() {
-//    checkbox.createDom();
-//
-//    assertEquals('Checkbox must have default false ARIA state aria-checked',
-//        'false', goog.dom.a11y.getState(checkbox.getElement(),
-//        goog.dom.a11y.State.CHECKED));
-//
-//    checkbox.setChecked(goog.ui.Checkbox.State.CHECKED);
-//    assertEquals('Checkbox must have true ARIA state aria-checked', 'true',
-//        goog.dom.a11y.getState(checkbox.getElement(),
-//        goog.dom.a11y.State.CHECKED));
-//
-//    checkbox.setChecked(goog.ui.Checkbox.State.UNCHECKED);
-//    assertEquals('Checkbox must have false ARIA state aria-checked', 'false',
-//        goog.dom.a11y.getState(checkbox.getElement(),
-//        goog.dom.a11y.State.CHECKED));
-//
-//    checkbox.setChecked(goog.ui.Checkbox.State.UNDETERMINED);
-//    assertEquals('Checkbox must have mixed ARIA state aria-checked', 'mixed',
-//        goog.dom.a11y.getState(checkbox.getElement(),
-//        goog.dom.a11y.State.CHECKED));
-//  }
-//
-//  function testSpaceKey() {
-//    var normalSpan = goog.dom.getElement('normal');
-//
-//    checkbox.decorate(normalSpan);
-//    assertEquals('default state is unchecked',
-//        goog.ui.Checkbox.State.UNCHECKED, checkbox.getChecked());
-//    goog.testing.events.fireKeySequence(normalSpan, goog.events.KeyCodes.SPACE);
-//    assertEquals('SPACE toggles checkbox to be checked',
-//        goog.ui.Checkbox.State.CHECKED, checkbox.getChecked());
-//    goog.testing.events.fireKeySequence(normalSpan, goog.events.KeyCodes.SPACE);
-//    assertEquals('another SPACE toggles checkbox to be unchecked',
-//        goog.ui.Checkbox.State.UNCHECKED, checkbox.getChecked());
-//
-//    // Enter for example doesn't work
-//    goog.testing.events.fireKeySequence(normalSpan, goog.events.KeyCodes.ENTER);
-//    assertEquals('Enter leaves checkbox unchecked',
-//        goog.ui.Checkbox.State.UNCHECKED, checkbox.getChecked());
-//  }
-//
-//  function testDecorate() {
-//    var normalSpan = goog.dom.getElement('normal');
-//    var checkedSpan = goog.dom.getElement('checked');
-//    var uncheckedSpan = goog.dom.getElement('unchecked');
-//    var undeterminedSpan = goog.dom.getElement('undetermined');
-//    var disabledSpan = goog.dom.getElement('disabled');
-//
-//    validateCheckBox(normalSpan, goog.ui.Checkbox.State.UNCHECKED);
-//    validateCheckBox(checkedSpan, goog.ui.Checkbox.State.CHECKED);
-//    validateCheckBox(uncheckedSpan, goog.ui.Checkbox.State.UNCHECKED);
-//    validateCheckBox(undeterminedSpan, goog.ui.Checkbox.State.UNDETERMINED);
-//    validateCheckBox(disabledSpan, goog.ui.Checkbox.State.UNCHECKED, true);
-//  }
-//
-//  function validateCheckBox(span, state, opt_disabled) {
-//    var testCheckbox = goog.ui.decorate(span);
-//    assertNotNull('checkbox created', testCheckbox);
-//    assertEquals('decorate was successful',
-//        goog.ui.Checkbox, testCheckbox.constructor)
-//    assertEquals('checkbox state should be: ' + state, state,
-//        testCheckbox.getChecked());
-//    assertEquals('checkbox is ' + (!opt_disabled ? 'enabled' : 'disabled'),
-//        !opt_disabled, testCheckbox.isEnabled());
-//    testCheckbox.dispose();
-//  }
-
-</script>
-</body>
+      function testFooNotDoneByDefault() {
+        assertFalse(myFoo.didTheFoo_);
+      }
+      
+      function testFooDoneAfterCall() {
+        myFoo.doTheFoo();
+        assertTrue(myFoo.didTheFoo_);
+      }
+    </script>
+  </body>
 </html>
+<!DOCTYPE html>
+<html>
+  <head>
+    <title>All JsUnit Tests</title>
+    <script src="http://localhost:9810/compile?id=tests&mode=raw"></script>
+    <link rel="stylesheet" href="styles.css" type="text/css">
+  </head>
+  <body>
+
+    <script>
+      if (goog.userAgent.product.CHROME &&
+        window.location.toString().indexOf('file:') == 0) {
+        document.write(
+        '<div class="warning">' +
+          'WARNING: Due to Chrome\'s security restrictions ' +
+          'this test will not be able to load files off your local disk ' +
+          'unless you start Chrome with:<br>' +
+          '<code>--allow-file-access-from-files</code></div><br>');
+      }
+    </script>
+
+    <h1>Closure - All JsUnit Tests</h1>
+    <div id="runner"></div>
+
+    <!--  Use a form so browser persists input values -->
+    <form id="footer" onsubmit="return false">
+      Settings:<br>
+      <input type="checkbox" name="hidepasses" id="hidepasses" checked>
+      <label for="hidepasses">Hide passes</label><br>
+      <input type="checkbox" name="parallel" id="parallel" checked>
+      <label for="parallel">Run in parallel</label>
+      <small>(timing stats not available if enabled)</small><br>
+      <input type="text" name="filter" id="filter" value="">
+      <label for="filter">Run only tests for path</label>
+    </form>
+
+    <script>
+      var _allTests = [
+        "src/foo_test.html"
+        //    "closure/goog/asserts/asserts_test.html",
+        //    "closure/goog/async/conditionaldelay_test.html",
+        //    "closure/goog/async/delay_test.html",
+        //    "closure/goog/async/throttle_test.html",
+        //    "closure/goog/base_test.html"
+      ];
+
+      var hidePassesInput = document.getElementById('hidepasses');
+      var parallelInput = document.getElementById('parallel');
+      var filterInput = document.getElementById('filter');
+
+      // Silence warning when running all.html with plovr
+      G_testRunner.setStrict(false);
+
+      function setFilterFunction() {
+        var matchValue = filterInput.value || '';
+        testRunner.setFilterFunction(function(testPath) {
+          return testPath.indexOf(matchValue) > -1;
+        });
+      }
+
+      // Create a test runner and render it.
+      var testRunner = new goog.testing.MultiTestRunner()
+          .setName(document.title)
+          .setBasePath('../')
+          .setPoolSize(parallelInput.checked ? 8 : 1)
+          .setStatsBucketSizes(5, 500)
+          .setHidePasses(hidePassesInput.checked)
+          .setVerbosePasses(true)
+          .addTests(_allTests);
+      testRunner.render(document.getElementById('runner'));
+
+      goog.events.listen(hidePassesInput, 'click', function(e) {
+        testRunner.setHidePasses(e.target.checked);
+      });
+
+      goog.events.listen(parallelInput, 'click', function(e) {
+        testRunner.setPoolSize(e.target.checked ? 8 : 1);
+      });
+
+      goog.events.listen(filterInput, 'keyup', setFilterFunction);
+      setFilterFunction();
+    </script>
+  </body>
+</html>
+/**
+ * @fileoverview Depenency file for easily running closure tests under plovr.
+ * @author Carsten Kraus <carsten.kraus@gmail.com>
+ */
+/** Testing utils */
+goog.require('goog.userAgent.product');
+goog.require('goog.testing.MultiTestRunner');
+goog.require('goog.testing.asserts');
+goog.require('goog.testing.events');
+goog.require('goog.testing.jsunit');
+
+/** Requirements of our modules */
+goog.require('goog.array');
+goog.require('goog.dom');
+//goog.require('goog.debug.ErrorHandler');
+//goog.require('goog.events.EventTarget');
+//goog.require('goog.events.EventHandler');
+//goog.require('goog.events.KeyCodes');
+
+/** Test modules */
+goog.require('foo.Foo');
+{
+    "id": "tests",
+    "paths":["../src"],
+    "inputs":["deps.js"],
+    "mode":"advanced",
+    "level":"verbose"
+//   ,"disambiguate-properties":true
+//   ,"ambiguate-properties":true
+//  , "debug":true
+//  , "pretty-print":true
+}   
+/*
+ * Copyright 2008 The Closure Library Authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by the Apache License, Version 2.0.
+ * See the COPYING file for details.
+ */
+
+/* Author: pupius@google.com (Daniel Pupius) */
+
+.goog-testrunner {
+  background-color: #EEE;
+  border: 1px solid #999;
+  padding: 10px;
+  padding-bottom: 25px;
+}
+
+.goog-testrunner-progress {
+  width: auto;
+  height: 20px;
+  background-color: #FFF;
+  border: 1px solid #999;
+}
+
+.goog-testrunner-progress table {
+  width: 100%;
+  height: 20px;
+  border-collapse: collapse;
+}
+
+.goog-testrunner-buttons {
+  margin-top: 7px;
+}
+
+.goog-testrunner-buttons button {
+  width: 75px;
+}
+
+.goog-testrunner-log,
+.goog-testrunner-report,
+.goog-testrunner-stats {
+  margin-top: 7px;
+  width: auto;
+  height: 400px;
+  background-color: #FFF;
+  border: 1px solid #999;
+  font: normal medium monospace;
+  padding: 5px;
+  overflow: auto;  /* Opera doesn't support overflow-y. */
+  overflow-y: scroll;
+  overflow-x: auto;
+}
+
+.goog-testrunner-report div {
+  margin-bottom: 6px;
+  border-bottom: 1px solid #999;
+}
+
+.goog-testrunner-stats table {
+  margin-top: 20px;
+  border-collapse: collapse;
+  border: 1px solid #EEE;
+}
+
+.goog-testrunner-stats td,
+.goog-testrunner-stats th {
+  padding: 2px 6px;
+  border: 1px solid #F0F0F0;
+}
+
+.goog-testrunner-stats th {
+  font-weight: bold;
+}
+
+.goog-testrunner-stats .center {
+  text-align: center;
+}
+
+.goog-testrunner-progress-summary {
+  font: bold small sans-serif;
+}
+
+.goog-testrunner iframe {
+  position: absolute;
+  left: -640px;
+  top: -480px;
+  width: 640px;
+  height: 480px;
+  margin: 0;
+  border: 0;
+  padding: 0;
+}
+
+.goog-testrunner-report-failure {
+  color: #900;
+}
+
+.goog-testrunner-reporttab,
+.goog-testrunner-logtab,
+.goog-testrunner-statstab {
+  float: left;
+  width: 50px;
+  height: 16px;
+  text-align: center;
+  font: normal small arial, helvetica, sans-serif;
+  color: #666;
+  background-color: #DDD;
+  border: 1px solid #999;
+  border-top: 0;
+  cursor: pointer;
+}
+
+.goog-testrunner-reporttab,
+.goog-testrunner-logtab {
+  border-right: 0;
+}
+
+.goog-testrunner-activetab {
+  font-weight: bold;
+  color: #000;
+  background-color: #CCC;
+}
+
+
+/*
+ * Page
+ */
+h1 {
+  font: normal x-large arial, helvetica, sans-serif;
+  margin: 0;
+}
+p, form {
+  font: normal small sans-serif;
+  margin: 0;
+}
+#header {
+  position: absolute;
+  right: 10px;
+  top: 13px;
+}
+#footer {
+  margin-top: 8px;
+}
+a {
+  text-decoration: none;
+}
+a:hover {
+  text-decoration: underline;
+}
+.warning {
+  font-size: 14px;
+  font-weight: bold;
+  width: 80%;
+}