cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject [1/2] spec commit: [CB-4279] Bridge test now generic and tests available modes
Date Mon, 22 Jul 2013 22:09:54 GMT
Updated Branches:
  refs/heads/master e064f5037 -> f5c0a54d0


[CB-4279] Bridge test now generic and tests available modes


Project: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/commit/94f1514d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/94f1514d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/94f1514d

Branch: refs/heads/master
Commit: 94f1514de65144eabb135dcb0dd85e12dda1866c
Parents: e064f50
Author: David Kemp <drkemp@chromium.org>
Authored: Wed Jul 17 09:35:34 2013 -0400
Committer: Max Woghiren <max.woghiren@gmail.com>
Committed: Mon Jul 22 18:07:55 2013 -0400

----------------------------------------------------------------------
 autotest/tests/bridge.tests.js | 55 +++++++++++++++++++++----------------
 1 file changed, 31 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/94f1514d/autotest/tests/bridge.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/bridge.tests.js b/autotest/tests/bridge.tests.js
index ec363d7..b549745 100644
--- a/autotest/tests/bridge.tests.js
+++ b/autotest/tests/bridge.tests.js
@@ -74,14 +74,14 @@ var fail = function() {
 };
 
 function createTestCase(jsToNativeModeName, nativeToJsModeName, testAsyncEcho) {
-    it(jsToNativeModeName + '+' + nativeToJsModeName, function() {
-        expect(exec.jsToNativeModes[jsToNativeModeName]).toBeDefined();
-        expect(exec.nativeToJsModes[nativeToJsModeName]).toBeDefined();
+    it(jsToNativeModeName + '+' + nativeToJsModeName + ': Async='+testAsyncEcho, function()
{
+        if(jsToNativeModeName) expect(exec.jsToNativeModes[jsToNativeModeName]).toBeDefined();
+        if(nativeToJsModeName) expect(exec.nativeToJsModes[nativeToJsModeName]).toBeDefined();
         reset();
         payload = new Array(payloadSize * 10 + 1).join('012\n\n 6789');
         asyncEcho = testAsyncEcho;
-        exec.setJsToNativeBridgeMode(exec.jsToNativeModes[jsToNativeModeName]);
-        exec.setNativeToJsBridgeMode(exec.nativeToJsModes[nativeToJsModeName]);
+        if(jsToNativeModeName) exec.setJsToNativeBridgeMode(exec.jsToNativeModes[jsToNativeModeName]);
+        if(nativeToJsModeName) exec.setNativeToJsBridgeMode(exec.nativeToJsModes[nativeToJsModeName]);
 
         waits(300);
         runs(function() {
@@ -92,7 +92,7 @@ function createTestCase(jsToNativeModeName, nativeToJsModeName, testAsyncEcho)
{
         runs(function() {
             var elapsedMs = endTime - startTime,
                 callsPerSecond = callCount * 1000 / elapsedMs;
-            expect(callsPerSecond).toBeGreaterThan(FENCEPOST);
+            expect(callsPerSecond).toBeLessThan(FENCEPOST);
         });
     });
 };
@@ -107,22 +107,29 @@ describe('Wait for page to load.', function() {
 // Before running on Android, set the following constants in NativeToJsMessagingBridge:
 // - ENABLE_LOCATION_CHANGE_EXEC_MODE = true
 // - DISABLE_EXEC_CHAINING = true
-describe('Android bridge with', function() {
-    var testAsyncEcho = false;
-    createTestCase('PROMPT', 'POLLING', testAsyncEcho);
-    createTestCase('JS_OBJECT', 'POLLING', testAsyncEcho);
-    createTestCase('LOCATION_CHANGE', 'ONLINE_EVENT', testAsyncEcho);
-
-    testAsyncEcho = true;
-    createTestCase('PROMPT', 'POLLING', testAsyncEcho);
-    createTestCase('PROMPT', 'HANGING_GET', testAsyncEcho);
-    createTestCase('PROMPT', 'LOAD_URL', testAsyncEcho);
-    createTestCase('PROMPT', 'ONLINE_EVENT', testAsyncEcho);
-    createTestCase('PROMPT', 'PRIVATE_API', testAsyncEcho);
-
-    createTestCase('JS_OBJECT', 'POLLING', testAsyncEcho);
-    createTestCase('JS_OBJECT', 'HANGING_GET', testAsyncEcho);
-    createTestCase('JS_OBJECT', 'LOAD_URL', testAsyncEcho);
-    createTestCase('JS_OBJECT', 'ONLINE_EVENT', testAsyncEcho);
-    createTestCase('JS_OBJECT', 'PRIVATE_API', testAsyncEcho);
+describe('Bridge with', function() {
+    var AsyncModes = [true,false];
+    for(var asmode in AsyncModes){
+        console.log("Bridge in Async: "+asmode);
+        if (exec.jsToNativeModes) {
+        	for(var jnmode in exec.jsToNativeModes ) {
+                console.log("Bridge js->native: "+ jnmode );
+        	    if(exec.nativeToJsModes){
+                    for(var njmode in exec.nativeToJsModes ){
+                        console.log("Bridge native->: "+ njmode);
+                        createTestCase( jnmode, njmode, asmode);
+                    }
+                } else {
+                    console.log("Bridge js->native: none");
+                    createTestCase(jnmode, '', asmode);
+                }
+        	}
+        } else {
+            console.log("Bridge js->native: none");
+            for(var njmode in exec.nativeToJsModes ){
+                console.log("Bridge native->: "+ njmode);
+                createTestCase('', njmode , asmode);
+            }
+        }
+    }
 });


Mime
View raw message