You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by mm...@apache.org on 2013/10/29 20:24:33 UTC

git commit: Moving HTML reporter out of plugin and into app

Updated Branches:
  refs/heads/cdvtest 6984ce603 -> b7670a674


Moving HTML reporter out of plugin and into app


Project: http://git-wip-us.apache.org/repos/asf/cordova-labs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-labs/commit/b7670a67
Tree: http://git-wip-us.apache.org/repos/asf/cordova-labs/tree/b7670a67
Diff: http://git-wip-us.apache.org/repos/asf/cordova-labs/diff/b7670a67

Branch: refs/heads/cdvtest
Commit: b7670a674ad99e8ebc04e57ad7caf1b471162776
Parents: 6984ce6
Author: Michal Mocny <mm...@gmail.com>
Authored: Tue Oct 29 15:24:22 2013 -0400
Committer: Michal Mocny <mm...@gmail.com>
Committed: Tue Oct 29 15:24:22 2013 -0400

----------------------------------------------------------------------
 cordova-app-test-harness/www/main.js      | 43 ++++++++++++++++++++------
 cordova-plugin-test-framework/www/test.js | 40 +++---------------------
 2 files changed, 38 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/b7670a67/cordova-app-test-harness/www/main.js
----------------------------------------------------------------------
diff --git a/cordova-app-test-harness/www/main.js b/cordova-app-test-harness/www/main.js
index ac85f4d..92061d9 100644
--- a/cordova-app-test-harness/www/main.js
+++ b/cordova-app-test-harness/www/main.js
@@ -5,10 +5,6 @@
 'use strict';
 
 function getURLParameter(name) {
-  /*var queryString = new jasmine.QueryString({
-    getWindowLocation: function() { return window.location; }
-  });
-  return queryString.getParam(name);*/
   return decodeURIComponent(
       (new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [,""])[1].replace(/\+/g, '%20')
     ) || null;
@@ -83,6 +79,14 @@ function runAutoTests() {
   setTitle('Auto Tests');
   createButton('Back', function() { location.href = 'index.html'; });
 
+  var jasmine = jasmineRequire.core(jasmineRequire);
+  jasmineRequire.html(jasmine);
+
+  var jasmineEnv = jasmine.getEnv();
+  var contentEl = document.getElementById('content');
+  var test = cordova.require('org.apache.cordova.test-framework.test');
+  test.init(jasmine, contentEl, createButton, logger);
+
   // TODO: get all installed plugins
   var plugins = [
       'org.apache.cordova.device',
@@ -95,13 +99,37 @@ function runAutoTests() {
     try {
       tests = cordova.require(id + '.tests');
     } catch(ex) {
-      logger('Failed to load tests: ' + id);
+      logger('Failed to load tests for: ' + id);
       return;
     }
     tests.init();
   });
 
-  var test = cordova.require('org.apache.cordova.test-framework.test');
+  jasmine.DEFAULT_TIMEOUT_INTERVAL = 300;
+
+  var catchingExceptions = getURLParameter("catch");
+  jasmineEnv.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions);
+
+  var specFilter = new jasmine.HtmlSpecFilter({
+    filterString: function() { return getURLParameter("spec"); }
+  });
+
+  jasmineEnv.specFilter = function(spec) {
+    return specFilter.matches(spec.getFullName());
+  };
+
+  var htmlReporter = new jasmine.HtmlReporter({
+    env: jasmineEnv,
+    queryString: getURLParameter,
+    onRaiseExceptionsClick: function() { /*queryString.setParam("catch", !jasmineEnv.catchingExceptions());*/ },
+    getContainer: function() { return contentEl; },
+    createElement: function() { return document.createElement.apply(document, arguments); },
+    createTextNode: function() { return document.createTextNode.apply(document, arguments); },
+    timer: new jasmine.Timer()
+  });
+  htmlReporter.initialize();
+  jasmineEnv.addReporter(htmlReporter);
+
   test.runAutoTests();
 }
 
@@ -125,9 +153,6 @@ function loaded() {
 }
 
 function ready() {
-  var test = cordova.require('org.apache.cordova.test-framework.test');
-  test.init(document.getElementById('content'), createButton, logger);
-
   var mode = getMode();
   logger(mode);
   if (mode === 'main')

http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/b7670a67/cordova-plugin-test-framework/www/test.js
----------------------------------------------------------------------
diff --git a/cordova-plugin-test-framework/www/test.js b/cordova-plugin-test-framework/www/test.js
index 889ce47..fbe99c9 100644
--- a/cordova-plugin-test-framework/www/test.js
+++ b/cordova-plugin-test-framework/www/test.js
@@ -30,15 +30,13 @@ var contentEl,
 
 /******************************************************************************/
 
-exports.init = function(contentEl_, createActionButtonFn_, logFn_) {
+exports.init = function(jasmine_, contentEl_, createActionButtonFn_, logFn_) {
+  jasmine = jasmine_;
   contentEl = contentEl_;
   createActionButtonFn = createActionButtonFn_;
   logFn = logFn_;
 
 
-  jasmine = jasmineRequire.core(jasmineRequire);
-  jasmineRequire.html(jasmine);
-
   jasmineEnv = jasmine.getEnv();
 
   jasmineInterface = {
@@ -90,43 +88,13 @@ exports.init = function(contentEl_, createActionButtonFn_, logFn_) {
 
     jasmine: jasmine,
   };
+
+  jasmineEnv.addReporter(jasmineInterface.jsApiReporter);
 }
 
 /******************************************************************************/
 
 exports.runAutoTests = function() {
-  var queryString = new jasmine.QueryString({
-    getWindowLocation: function() { return window.location; }
-  });
-
-  jasmine.DEFAULT_TIMEOUT_INTERVAL = 300;
-
-  // TODO: move all of catching to raise so we don't break our brains
-  var catchingExceptions = queryString.getParam("catch");
-  jasmineEnv.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions);
-
-  var htmlReporter = new jasmine.HtmlReporter({
-    env: jasmineEnv,
-    queryString: queryString,
-    onRaiseExceptionsClick: function() { queryString.setParam("catch", !jasmineEnv.catchingExceptions()); },
-    getContainer: function() { return contentEl; },
-    createElement: function() { return document.createElement.apply(document, arguments); },
-    createTextNode: function() { return document.createTextNode.apply(document, arguments); },
-    timer: new jasmine.Timer()
-  });
-
-  jasmineEnv.addReporter(jasmineInterface.jsApiReporter);
-  jasmineEnv.addReporter(htmlReporter);
-
-  var specFilter = new jasmine.HtmlSpecFilter({
-    filterString: function() { return queryString.getParam("spec"); }
-  });
-
-  jasmineEnv.specFilter = function(spec) {
-    return specFilter.matches(spec.getFullName());
-  };
-
-  htmlReporter.initialize();
   jasmineEnv.execute();
 }