cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmo...@apache.org
Subject git commit: some restructuring in prep for manual tests
Date Wed, 30 Oct 2013 16:21:09 GMT
Updated Branches:
  refs/heads/cdvtest 6432c73c8 -> aeaecf7e9


some restructuring in prep for manual tests


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

Branch: refs/heads/cdvtest
Commit: aeaecf7e99420d8ddcb62d487241aba58a17f120
Parents: 6432c73
Author: Michal Mocny <mmocny@gmail.com>
Authored: Wed Oct 30 12:11:34 2013 -0400
Committer: Michal Mocny <mmocny@gmail.com>
Committed: Wed Oct 30 12:11:34 2013 -0400

----------------------------------------------------------------------
 cordova-app-test-harness/www/index.html   |  2 +-
 cordova-app-test-harness/www/main.css     |  4 +-
 cordova-app-test-harness/www/main.js      | 81 ++++++++++++++++----------
 cordova-plugin-test-framework/www/test.js | 62 ++++++++++++++++----
 4 files changed, 103 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/aeaecf7e/cordova-app-test-harness/www/index.html
----------------------------------------------------------------------
diff --git a/cordova-app-test-harness/www/index.html b/cordova-app-test-harness/www/index.html
index 39c03b5..ec98bd6 100644
--- a/cordova-app-test-harness/www/index.html
+++ b/cordova-app-test-harness/www/index.html
@@ -4,7 +4,7 @@
     <title>Cordova tests</title>
     <meta charset="utf-8" />
     <meta name="format-detection" content="telephone=no" />
-    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1,
minimum-scale=1, target-densitydpi=device-dpi" />
+    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1,
minimum-scale=1, width=device-width" />
     <link rel="stylesheet" type="text/css" href="assets/topcoat-0.7.5/css/topcoat-mobile-light.min.css">
     <link rel="stylesheet" type="text/css" href="assets/jasmine-2.0.0-rc5/jasmine.css"
media="screen">
     <link rel="stylesheet" type="text/css" href="main.css" media="screen">

http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/aeaecf7e/cordova-app-test-harness/www/main.css
----------------------------------------------------------------------
diff --git a/cordova-app-test-harness/www/main.css b/cordova-app-test-harness/www/main.css
index 08eafb1..70bfcf9 100644
--- a/cordova-app-test-harness/www/main.css
+++ b/cordova-app-test-harness/www/main.css
@@ -8,7 +8,6 @@ html, body {
 *, *:before, *:after {
   -webkit-box-sizing: border-box;
   box-sizing: border-box;
-  /*line-height: 1.4em;*/
 }
 
 #title {
@@ -16,10 +15,12 @@ html, body {
   height: 30px;
   width: 100%;
   top: 0;
+  z-index: 1000;
 
   background-color: #58b;
   font-size: 25px;
   text-align: center;
+  font-weight: bold;
 }
 
 #content {
@@ -32,6 +33,7 @@ html, body {
   height: 150px;
   width: 100%;
   bottom: 0;
+  z-index: 1000;
 
   background-color: white;
   border-top: 2px solid #777;

http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/aeaecf7e/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 a972a33..58b4091 100644
--- a/cordova-app-test-harness/www/main.js
+++ b/cordova-app-test-harness/www/main.js
@@ -40,6 +40,7 @@ function createButton(title, callback) {
 
 function logger() {
   console.log.apply(console, Array.prototype.slice.apply(arguments));
+  //console.trace();
   var el = document.getElementById('log');
   var div = document.createElement('div');
   div.textContent = Array.prototype.slice.apply(arguments).map(function(arg) {
@@ -80,43 +81,33 @@ function setDeviceInfo() {
 
 /******************************************************************************/
 
-function runAutoTests() {
-  setTitle('Auto Tests');
-  createButton('Back', function() { setMode('main'); });
-
-  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);
-
-  var plugins = cordova.require('cordova/plugin_list')
+function getPluginTestsJsModules() {
+  return cordova.require('cordova/plugin_list')
     .map(function(jsmodule) {
       return jsmodule.id;
     })
     .filter(function(id) {
       return /.tests$/.test(id);
     });
+}
 
-  plugins.forEach(function(id) {
-    var tests;
-    try {
-      tests = cordova.require(id);
-      logger('Loaded:', id);
-    } catch(ex) {
-      logger('Failed to load:', id);
-      return;
-    }
-    tests.init();
-  });
+/******************************************************************************/
+
+function runAutoTests() {
+  setTitle('Auto Tests');
+  createButton('Back', function() { setMode('main'); });
+
+  // Set up jasmine
+  var jasmine = jasmineRequire.core(jasmineRequire);
+  jasmineRequire.html(jasmine);
+  var jasmineEnv = jasmine.getEnv();
 
   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"); }
   });
@@ -124,7 +115,10 @@ function runAutoTests() {
   jasmineEnv.specFilter = function(spec) {
     return specFilter.matches(spec.getFullName());
   };
+  */
 
+  // Set up jasmine html reporter
+  var contentEl = document.getElementById('content');
   var htmlReporter = new jasmine.HtmlReporter({
     env: jasmineEnv,
     queryString: getURLParameter,
@@ -135,8 +129,27 @@ function runAutoTests() {
     timer: new jasmine.Timer()
   });
   htmlReporter.initialize();
+
   jasmineEnv.addReporter(htmlReporter);
 
+  // Define our tests
+  var test = cordova.require('org.apache.cordova.test-framework.test');
+  logger(test);
+  test.initForAutoTests(jasmine);
+
+  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();
 }
 
@@ -145,6 +158,10 @@ function runAutoTests() {
 function runManualTests() {
   setTitle('Manual Tests');
   createButton('Back', function() { setMode('main'); });
+
+  var contentEl = document.getElementById('content');
+  var test = cordova.require('org.apache.cordova.test-framework.test');
+  test.initForManualTests();
 }
 
 /******************************************************************************/
@@ -156,12 +173,15 @@ function runUnknownMode() {
 
 /******************************************************************************/
 
-function loaded() {
-}
+document.addEventListener("DOMContentLoaded", function() {
+});
+
+document.addEventListener("deviceready", function() {
+  var contentEl = document.getElementById('content');
+  var test = cordova.require('org.apache.cordova.test-framework.test');
+  test.init(contentEl, createButton, logger);
 
-function ready() {
   var mode = getMode();
-  logger(mode);
   if (mode === 'main')
     runMain();
   else if (mode === 'autotests')
@@ -170,10 +190,7 @@ function ready() {
     runManualTests();
   else
     runUnknownMode();
-}
-
-document.addEventListener("DOMContentLoaded", loaded);
-document.addEventListener("deviceready", ready);
+});
 
 /******************************************************************************/
 

http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/aeaecf7e/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 fbe99c9..fcb1eba 100644
--- a/cordova-plugin-test-framework/www/test.js
+++ b/cordova-plugin-test-framework/www/test.js
@@ -20,25 +20,44 @@
 */
 
 /******************************************************************************/
+/******************************************************************************/
+/******************************************************************************/
+// Common
 
 var contentEl,
     createActionButtonFn,
-    logFn,
-    jasmine,
-    jasmineEnv,
-    jasmineInterface;
+    logFn;
 
 /******************************************************************************/
 
-exports.init = function(jasmine_, contentEl_, createActionButtonFn_, logFn_) {
-  jasmine = jasmine_;
+exports.init = function(contentEl_, createActionButtonFn_, logFn_) {
   contentEl = contentEl_;
   createActionButtonFn = createActionButtonFn_;
   logFn = logFn_;
+};
 
+/******************************************************************************/
 
-  jasmineEnv = jasmine.getEnv();
+Object.defineProperty(exports, "log", {
+    get: function() { return logFn; }
+});
+
+/******************************************************************************/
+/******************************************************************************/
+/******************************************************************************/
+// Auto Tests
+
+(function() {
+
+var jasmine,
+    jasmineEnv,
+    jasmineInterface;
+
+/******************************************************************************/
 
+exports.initForAutoTests = function(jasmine_) {
+  jasmine = jasmine_;
+  jasmineEnv = jasmine.getEnv();
   jasmineInterface = {
     describe: function(description, specDefinitions) {
       return jasmineEnv.describe(description, specDefinitions);
@@ -90,17 +109,16 @@ exports.init = function(jasmine_, contentEl_, createActionButtonFn_,
logFn_) {
   };
 
   jasmineEnv.addReporter(jasmineInterface.jsApiReporter);
-}
+};
 
 /******************************************************************************/
 
 exports.runAutoTests = function() {
   jasmineEnv.execute();
-}
+};
 
 /******************************************************************************/
 
-// eval this!
 exports.injectJasmineInterface = function(target, targetName) {
   var ret = "";
   for (var property in jasmineInterface) {
@@ -108,12 +126,32 @@ exports.injectJasmineInterface = function(target, targetName) {
     ret += 'var ' + property + ' = this[\'' + property + '\'];\n';
   }
   return ret;
-}
+};
+
+/******************************************************************************/
+
+}());
+
+/******************************************************************************/
+/******************************************************************************/
+/******************************************************************************/
+// Manual Tests
+
+(function () {
+
+/******************************************************************************/
+
+exports.initForManualTests = function() {
+};
 
 /******************************************************************************/
 
 exports.addManualTest = function(title, handler) {
   createActionButtonFn(title, handler);
-}
+};
+
+/******************************************************************************/
+
+}());
 
 /******************************************************************************/


Mime
View raw message