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 2014/05/06 21:20:47 UTC

[1/4] git commit: Changing some names around

Repository: cordova-labs
Updated Branches:
  refs/heads/cdvtest 599ebd16e -> 8ae8e0336


Changing some names around


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

Branch: refs/heads/cdvtest
Commit: 851130a464815b4e8705d225500cbcb7eecfafd7
Parents: 599ebd1
Author: Michal Mocny <mm...@gmail.com>
Authored: Tue May 6 13:26:27 2014 -0400
Committer: Michal Mocny <mm...@gmail.com>
Committed: Tue May 6 13:26:27 2014 -0400

----------------------------------------------------------------------
 cordova-plugin-test-framework/plugin.xml   |   4 +-
 cordova-plugin-test-framework/www/main.js  |  12 +--
 cordova-plugin-test-framework/www/test.js  |  93 --------------------
 cordova-plugin-test-framework/www/tests.js | 108 ++++++++++++++++++++++++
 4 files changed, 116 insertions(+), 101 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/851130a4/cordova-plugin-test-framework/plugin.xml
----------------------------------------------------------------------
diff --git a/cordova-plugin-test-framework/plugin.xml b/cordova-plugin-test-framework/plugin.xml
index 1a9a12d..3ce8692 100644
--- a/cordova-plugin-test-framework/plugin.xml
+++ b/cordova-plugin-test-framework/plugin.xml
@@ -12,10 +12,10 @@
 
     <!-- <dependency id="org.apache.cordova.appsettings" /> -->
 
-    <js-module src="www/test.js" name="test" />
+    <js-module src="www/tests.js" name="cdvtests" />
     <js-module src="www/jasmine_helpers.js" name="jasmine_helpers" />
     <js-module src="www/main.js" name="main" />
 
-    <asset src="www/assets" target="cdvtest" />
+    <asset src="www/assets" target="cdvtests" />
 
 </plugin>

http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/851130a4/cordova-plugin-test-framework/www/main.js
----------------------------------------------------------------------
diff --git a/cordova-plugin-test-framework/www/main.js b/cordova-plugin-test-framework/www/main.js
index 999ab68..54b1d64 100644
--- a/cordova-plugin-test-framework/www/main.js
+++ b/cordova-plugin-test-framework/www/main.js
@@ -26,7 +26,7 @@
 /******************************************************************************/
 
 function getMode(callback) {
-  var mode = localStorage.getItem('cdvtest-mode') || 'main';
+  var mode = localStorage.getItem('cdvtests-mode') || 'main';
   callback(mode);
 }
 
@@ -42,7 +42,7 @@ function setMode(mode) {
     mode = 'main';
   }
 
-  localStorage.setItem('cdvtest-mode', mode);
+  localStorage.setItem('cdvtests-mode', mode);
   clearContent();
 
   handlers[mode]();
@@ -112,8 +112,8 @@ function runAutoTests() {
   createActionButton('Reset App', location.reload.bind(location));
   createActionButton('Back', setMode.bind(null, 'main'));
 
-  var cdvtest = cordova.require('org.apache.cordova.test-framework.test');
-  cdvtest.defineAutoTests();
+  var cdvtests = cordova.require('org.apache.cordova.test-framework.cdvtests');
+  cdvtests.defineAutoTests();
 
   // Run the tests!
   var jasmineEnv = window.jasmine.getEnv();
@@ -135,8 +135,8 @@ function runManualTests() {
     createActionButton('Reset App', location.reload.bind(location));
     createActionButton('Back', setMode.bind(null, 'manual'));
   }
-  var cdvtest = cordova.require('org.apache.cordova.test-framework.test');
-  cdvtest.defineManualTests(contentEl, beforeEach, createActionButton);
+  var cdvtests = cordova.require('org.apache.cordova.test-framework.cdvtests');
+  cdvtests.defineManualTests(contentEl, beforeEach, createActionButton);
 }
 
 /******************************************************************************/

http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/851130a4/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
deleted file mode 100644
index cb1fd1c..0000000
--- a/cordova-plugin-test-framework/www/test.js
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
- *
-*/
-
-'use strict';
-
-exports.tests = Object.create(null);
-
-function getTestsObject(api) {
-  return exports.tests[api] = exports.tests[api] || { enabled: true };
-}
-
-exports.init = function() {
-  // Attach jasmineInterface to global object
-  var jasmine_helpers = require('./jasmine_helpers');
-  var jasmineInterface = jasmine_helpers.setUpJasmine();
-  for (var property in jasmineInterface) {
-    window[property] = jasmineInterface[property];
-  }
-
-  // This finds all js-modules named "tests" (regardless of plugins they came from)
-  var test_modules = cordova.require('cordova/plugin_list')
-    .map(function(jsmodule) {
-      return jsmodule.id;
-    })
-    .filter(function(id) {
-      return /.tests$/.test(id);
-    });
-
-  // Map auto / manual test definitions for each, but without actually running the handlers
-  test_modules.forEach(function(id) {
-    try {
-      var plugintests = cordova.require(id);
-
-      if (plugintests.hasOwnProperty('defineAutoTests')) {
-        getTestsObject(id).defineAutoTests = function() {
-          jasmineInterface.describe(id + ' >>', plugintests.defineAutoTests.bind(plugintests));
-        };
-      }
-
-      if (plugintests.hasOwnProperty('defineManualTests')) {
-        getTestsObject(id).defineManualTests = plugintests.defineManualTests.bind(plugintests);
-      }
-    } catch(ex) {
-      console.warn('Failed to load tests: ', id);
-      return;
-    }
-  });
-}
-
-exports.defineAutoTests = function() {
-  exports.init();
-
-  Object.keys(exports.tests).forEach(function(key) {
-    if (!exports.tests[key].enabled)
-      return;
-    if (!exports.tests[key].hasOwnProperty('defineAutoTests'))
-      return;
-    exports.tests[key].defineAutoTests();
-  });
-};
-
-exports.defineManualTests = function(contentEl, beforeEach, createActionButton) {
-  exports.init();
-
-  Object.keys(exports.tests).forEach(function(key) {
-    if (!exports.tests[key].enabled)
-      return;
-    if (!exports.tests[key].hasOwnProperty('defineManualTests'))
-      return;
-    createActionButton(key, function() {
-      beforeEach();
-      exports.tests[key].defineManualTests(contentEl, createActionButton);
-    });
-  });
-};

http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/851130a4/cordova-plugin-test-framework/www/tests.js
----------------------------------------------------------------------
diff --git a/cordova-plugin-test-framework/www/tests.js b/cordova-plugin-test-framework/www/tests.js
new file mode 100644
index 0000000..1d20ba0
--- /dev/null
+++ b/cordova-plugin-test-framework/www/tests.js
@@ -0,0 +1,108 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ *
+*/
+
+'use strict';
+
+exports.tests = Object.create(null);
+
+function getTestsObject(api) {
+  return exports.tests[api] = exports.tests[api] || { enabled: true };
+}
+
+function requireAllTestModules() {
+  // This finds all js-modules named "tests" (regardless of plugins they came from)
+  var test_modules = cordova.require('cordova/plugin_list')
+    .map(function(jsmodule) {
+      return jsmodule.id;
+    })
+    .filter(function(id) {
+      return /.tests$/.test(id);
+    });
+
+  // Map auto / manual test definitions for each, but without actually running the handlers
+  test_modules.forEach(function(id) {
+    try {
+      var plugintests = cordova.require(id);
+
+      if (plugintests.hasOwnProperty('defineAutoTests')) {
+        getTestsObject(id).defineAutoTests = function() {
+          jasmineInterface.describe(id + ' >>', plugintests.defineAutoTests.bind(plugintests));
+        };
+      }
+
+      if (plugintests.hasOwnProperty('defineManualTests')) {
+        getTestsObject(id).defineManualTests = plugintests.defineManualTests.bind(plugintests);
+      }
+    } catch(ex) {
+      console.warn('Failed to load tests: ', id);
+      return;
+    }
+  });
+}
+
+function createJasmineInterface() {
+  var jasmine_helpers = require('./jasmine_helpers');
+  var jasmineInterface = jasmine_helpers.setUpJasmine();
+  return jasmineInterface;
+}
+
+function attachJasmineInterfaceToGlobal() {
+  var jasmineInterface = createJasmineInterface();
+  for (var property in jasmineInterface) {
+    window[property] = jasmineInterface[property];
+  }
+}
+
+function detachJasmineInterfaceFromGlobal() {
+  var jasmineInterface = createJasmineInterface();
+  for (var property in jasmineInterface) {
+    delete window[property];
+  }
+}
+
+exports.defineAutoTests = function() {
+  requireAllTestModules();
+  attachJasmineInterfaceToGlobal();
+
+  Object.keys(exports.tests).forEach(function(key) {
+    if (!exports.tests[key].enabled)
+      return;
+    if (!exports.tests[key].hasOwnProperty('defineAutoTests'))
+      return;
+    exports.tests[key].defineAutoTests();
+  });
+};
+
+exports.defineManualTests = function(contentEl, beforeEach, createActionButton) {
+  requireAllTestModules();
+  detachJasmineInterfaceFromGlobal();
+
+  Object.keys(exports.tests).forEach(function(key) {
+    if (!exports.tests[key].enabled)
+      return;
+    if (!exports.tests[key].hasOwnProperty('defineManualTests'))
+      return;
+    createActionButton(key, function() {
+      beforeEach();
+      exports.tests[key].defineManualTests(contentEl, createActionButton);
+    });
+  });
+};


[3/4] git commit: Fix: use globally defined describe

Posted by mm...@apache.org.
Fix: use globally defined describe


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

Branch: refs/heads/cdvtest
Commit: d9924127770216e057fe5910e81ea9506be15559
Parents: f767bbf
Author: Michal Mocny <mm...@gmail.com>
Authored: Tue May 6 14:05:38 2014 -0400
Committer: Michal Mocny <mm...@gmail.com>
Committed: Tue May 6 14:05:38 2014 -0400

----------------------------------------------------------------------
 cordova-plugin-test-framework/www/tests.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/d9924127/cordova-plugin-test-framework/www/tests.js
----------------------------------------------------------------------
diff --git a/cordova-plugin-test-framework/www/tests.js b/cordova-plugin-test-framework/www/tests.js
index 0fc2f68..87b1069 100644
--- a/cordova-plugin-test-framework/www/tests.js
+++ b/cordova-plugin-test-framework/www/tests.js
@@ -44,7 +44,7 @@ function requireAllTestModules() {
 
       if (plugintests.hasOwnProperty('defineAutoTests')) {
         getTestsObject(id).defineAutoTests = function() {
-          jasmineInterface.describe(id + ' >>', plugintests.defineAutoTests.bind(plugintests));
+          describe(id + ' >>', plugintests.defineAutoTests.bind(plugintests));
         };
       }
 


[4/4] git commit: Make a working on screen logger

Posted by mm...@apache.org.
Make a working on screen logger


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

Branch: refs/heads/cdvtest
Commit: 8ae8e03361e3dce02b0c37924e8e9195cd233b79
Parents: d992412
Author: Michal Mocny <mm...@gmail.com>
Authored: Tue May 6 15:20:34 2014 -0400
Committer: Michal Mocny <mm...@gmail.com>
Committed: Tue May 6 15:20:34 2014 -0400

----------------------------------------------------------------------
 .../www/assets/main.css                         | 17 +++-
 cordova-plugin-test-framework/www/main.js       | 83 +++++++++++++++-----
 2 files changed, 79 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/8ae8e033/cordova-plugin-test-framework/www/assets/main.css
----------------------------------------------------------------------
diff --git a/cordova-plugin-test-framework/www/assets/main.css b/cordova-plugin-test-framework/www/assets/main.css
index 43f5ca4..4e33267 100644
--- a/cordova-plugin-test-framework/www/assets/main.css
+++ b/cordova-plugin-test-framework/www/assets/main.css
@@ -27,6 +27,7 @@ html, body {
   position: absolute;
   top: 30px;
   bottom: 20px;
+  padding-bottom: 40%;
   width: 100%;
   overflow-y: auto;
   overflow-x: auto;
@@ -43,7 +44,7 @@ html, body {
 }
 
 #log.expanded {
-  height: 30%;
+  height: 40%;
 }
 
 #log--title {
@@ -64,7 +65,19 @@ html, body {
   background-color: white;
 }
 
-#log--content--line {
+.log--content--line {
   border-bottom: 1px solid #ccc;
   white-space: pre;
 }
+
+.log--content--line--log {
+  background-color: white;
+}
+
+.log--content--line--warn {
+  background-color: #FCFFA6;
+}
+
+.log--content--line--error {
+  background-color: #FFA6A6;
+}

http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/8ae8e033/cordova-plugin-test-framework/www/main.js
----------------------------------------------------------------------
diff --git a/cordova-plugin-test-framework/www/main.js b/cordova-plugin-test-framework/www/main.js
index 54b1d64..d5ecad0 100644
--- a/cordova-plugin-test-framework/www/main.js
+++ b/cordova-plugin-test-framework/www/main.js
@@ -57,13 +57,19 @@ function clearContent() {
   log.innerHTML = '';
   var buttons = document.getElementById('buttons');
   buttons.innerHTML = '';
+
+  setLogVisibility(false);
 }
 
+/******************************************************************************/
+
 function setTitle(title) {
   var el = document.getElementById('title');
   el.textContent = title;
 }
 
+/******************************************************************************/
+
 function setLogVisibility(visible) {
   if (visible) {
     document.getElementById('log').classList.add('expanded');
@@ -72,6 +78,57 @@ function setLogVisibility(visible) {
   }
 }
 
+function toggleLogVisibility() {
+  var log = document.getElementById('log');
+  if (log.classList.contains('expanded')) {
+    log.classList.remove('expanded');
+  } else {
+    log.classList.add('expanded');
+  }
+}
+
+/******************************************************************************/
+
+function attachEvents() {
+  document.getElementById('log--title').addEventListener('click', toggleLogVisibility);
+}
+
+/******************************************************************************/
+
+function wrapConsole() {
+  var origConsole = window.console;
+
+  function appendToOnscreenLog(type, args) {
+    var el = document.getElementById('log--content');
+    var div = document.createElement('div');
+    div.classList.add('log--content--line');
+    div.classList.add('log--content--line--' + type);
+    div.textContent = Array.prototype.slice.apply(args).map(function(arg) {
+        return (typeof arg === 'string') ? arg : JSON.stringify(arg);
+      }).join(' ');
+    el.appendChild(div);
+    // scroll to bottom
+    el.scrollTop = el.scrollHeight;
+  }
+
+  function createCustomLogger(type) {
+    return function() {
+      origConsole[type].apply(origConsole, arguments);
+      //window.medic.log.apply(window.medic.log, arguments);
+      appendToOnscreenLog(type, arguments);
+      setLogVisibility(true);
+    }
+  }
+
+  window.console = {
+    log: createCustomLogger('log'),
+    warn: createCustomLogger('warn'),
+    error: createCustomLogger('error'),
+  }
+}
+
+/******************************************************************************/
+
 function createActionButton(title, callback) {
   var buttons = document.getElementById('buttons');
   var div = document.createElement('div');
@@ -86,27 +143,12 @@ function createActionButton(title, callback) {
   buttons.appendChild(div);
 }
 
-// TODO: make a better logger
-function logger() {
-  console.log.apply(console, arguments);
-  //window.medic.log.apply(window.medic.log, arguments);
-
-  var el = document.getElementById('log--content');
-  var div = document.createElement('div');
-  div.classList.add('log--content--line');
-  div.textContent = Array.prototype.slice.apply(arguments).map(function(arg) {
-      return (typeof arg === 'string') ? arg : JSON.stringify(arg);
-    }).join(' ');
-  el.appendChild(div);
-  // scroll to bottom
-  el.scrollTop = el.scrollHeight;
-}
-
+/******************************************************************************/
+/******************************************************************************/
 /******************************************************************************/
 
 function runAutoTests() {
   setTitle('Auto Tests');
-  setLogVisibility(true);
 
   createActionButton('Again', setMode.bind(null, 'auto'));
   createActionButton('Reset App', location.reload.bind(location));
@@ -124,7 +166,6 @@ function runAutoTests() {
 
 function runManualTests() {
   setTitle('Manual Tests');
-  setLogVisibility(true);
 
   createActionButton('Reset App', location.reload.bind(location));
   createActionButton('Back', setMode.bind(null, 'main'));
@@ -143,7 +184,6 @@ function runManualTests() {
 
 function runMain() {
   setTitle('Cordova Tests');
-  setLogVisibility(false);
 
   createActionButton('Auto Tests', setMode.bind(null, 'auto'));
   createActionButton('Manual Tests', setMode.bind(null, 'manual'));
@@ -161,6 +201,11 @@ exports.init = function() {
     }
   });
   */
+  // TODO: have a way to opt-out of console wrapping in case line numbers are important.
+  // ...Or find a custom way to print line numbers using stack or something.
+  attachEvents();
+  wrapConsole();
+
   getMode(setMode);
 };
 


[2/4] git commit: Fix regex to match js-modules named exactly 'tests'

Posted by mm...@apache.org.
Fix regex to match js-modules named exactly '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/f767bbf4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-labs/tree/f767bbf4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-labs/diff/f767bbf4

Branch: refs/heads/cdvtest
Commit: f767bbf4328af7b51c9be6c02047133dd11987a5
Parents: 851130a
Author: Michal Mocny <mm...@gmail.com>
Authored: Tue May 6 13:27:10 2014 -0400
Committer: Michal Mocny <mm...@gmail.com>
Committed: Tue May 6 13:27:10 2014 -0400

----------------------------------------------------------------------
 cordova-plugin-test-framework/www/tests.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-labs/blob/f767bbf4/cordova-plugin-test-framework/www/tests.js
----------------------------------------------------------------------
diff --git a/cordova-plugin-test-framework/www/tests.js b/cordova-plugin-test-framework/www/tests.js
index 1d20ba0..0fc2f68 100644
--- a/cordova-plugin-test-framework/www/tests.js
+++ b/cordova-plugin-test-framework/www/tests.js
@@ -34,7 +34,7 @@ function requireAllTestModules() {
       return jsmodule.id;
     })
     .filter(function(id) {
-      return /.tests$/.test(id);
+      return /\.tests$/.test(id);
     });
 
   // Map auto / manual test definitions for each, but without actually running the handlers