cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmo...@apache.org
Subject [1/4] git commit: Refactoring test plugin
Date Fri, 13 Dec 2013 16:02:42 GMT
Updated Branches:
  refs/heads/cdvtest 78337f6a7 -> adc757661


Refactoring test plugin


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

Branch: refs/heads/cdvtest
Commit: 52ff719c2b120c10d4f7392f4fdef0ec8565e7ff
Parents: c2ccde6
Author: Michal Mocny <mmocny@gmail.com>
Authored: Fri Nov 8 14:19:39 2013 -0500
Committer: Michal Mocny <mmocny@gmail.com>
Committed: Fri Nov 8 14:19:44 2013 -0500

----------------------------------------------------------------------
 cordova-app-test-harness/www/main.js | 107 ++++++++++++++++--------------
 1 file changed, 57 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/52ff719c/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 1de8781..4be5c47 100644
--- a/cordova-app-test-harness/www/main.js
+++ b/cordova-app-test-harness/www/main.js
@@ -117,32 +117,30 @@ function runAutoTests() {
     return specFilter.matches(spec.getFullName());
   };
   */
-  createHtmlReporter(jasmine);
-  createCouchdbReporter(jasmine, function(){runtests(jasmine);});
-}
 
-function runtests(jasmine){
-  // Define our tests
-  var test = cordova.require('org.apache.cordova.test-framework.test');
-  logger(test);
-  test.initForAutoTests(jasmine);
+  createHtmlReporter(jasmine);
+  createCouchdbReporter(jasmine, function() {
+    var test = cordova.require('org.apache.cordova.test-framework.test');
+    test.initForAutoTests(jasmine);
+
+    // Define our tests
+    getPluginTestsJsModules().forEach(function(id) {
+      var tests;
+      try {
+        tests = cordova.require(id);
+      } catch(ex) {
+        logger('Failed to load:', id);
+        return;
+      }
+      tests.init();
+      logger('Loaded:', id);
+    });
 
-  getPluginTestsJsModules().forEach(function(id) {
-    var tests;
-    try {
-      tests = cordova.require(id);
-    } catch(ex) {
-      logger('Failed to load:', id);
-      return;
-    }
-    tests.init();
-    logger('Loaded:', id);
+    // Run!
+    test.runAutoTests();
   });
-
-  // Run!
-  test.runAutoTests();
-
 }
+
 function createHtmlReporter(jasmine) {
    // Set up jasmine html reporter
   var jasmineEnv = jasmine.getEnv();
@@ -160,38 +158,47 @@ function createHtmlReporter(jasmine) {
 
   jasmineEnv.addReporter(htmlReporter);
 }
- 
+
 function createCouchdbReporter(jasmine, callback) {
   var settings = cordova.require('org.apache.cordova.appsettings.appsettings');
-  settings.get( function(dbsettings){configureCouchReporter(dbsettings,jasmine,callback);},
-              function(){configureCouchReporter(null,jasmine,callback);},
-              ["CouchdbUrl", "CouchdbPrivateUrl","TestSha"]);
+  var win = function(dbsettings) {
+    configureCouchReporter(dbsettings,jasmine,callback);
+  };
+  var fail = function() {
+    configureCouchReporter(null,jasmine,callback);
+  };
+  settings.get(win, fail, ["CouchdbUrl", "CouchdbPrivateUrl", "TestSha"]);
 }
-             
-function configureCouchReporter(dbsettings, jasmine, callback){
-    if(dbsettings) {
-      try{
-        var reporteroptions =  {serverip: dbsettings['CouchdbUrl'],
-          serverpublic: dbsettings['CouchdbPrivateUrl'],
-          sha: dbsettings['TestSha']};
-        var ciReporter = new jasmine.CouchDBReporter({
-          env: jasmine.getEnv(),
-          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() ,
-          couch: reporteroptions});
- 
-        jasmine.getEnv().addReporter(ciReporter);
-      } catch(ex) {
-        logger('Invalid CouchDB settings:', ex);
-      }
-    } else {
-      logger('CouchDB Settings unavailable.' );
+
+function configureCouchReporter(dbsettings, jasmine, callback) {
+    if (!dbsettings) {
+      console.warn('Not reporting results to CouchDB.');
+      return callback();
     }
-    callback();
+
+    try {
+      var reporteroptions = {
+        serverip: dbsettings['CouchdbUrl'],
+        serverpublic: dbsettings['CouchdbPrivateUrl'],
+        sha: dbsettings['TestSha'],
+      };
+      var ciReporter = new jasmine.CouchDBReporter({
+        env: jasmine.getEnv(),
+        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(),
+        couch: reporteroptions
+      });
+
+      jasmine.getEnv().addReporter(ciReporter);
+    } catch(ex) {
+      logger('Invalid CouchDB settings:', ex);
+    }
+
+    return callback();
 }
 
 /******************************************************************************/


Mime
View raw message