From callback-dev-return-13001-apmail-incubator-callback-dev-archive=incubator.apache.org@incubator.apache.org Tue Sep 11 02:44:50 2012 Return-Path: X-Original-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 969BBD9F7 for ; Tue, 11 Sep 2012 02:44:50 +0000 (UTC) Received: (qmail 93358 invoked by uid 500); 11 Sep 2012 02:44:50 -0000 Delivered-To: apmail-incubator-callback-dev-archive@incubator.apache.org Received: (qmail 93334 invoked by uid 500); 11 Sep 2012 02:44:50 -0000 Mailing-List: contact callback-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-dev@incubator.apache.org Received: (qmail 93318 invoked by uid 99); 11 Sep 2012 02:44:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Sep 2012 02:44:50 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of agrieve@google.com designates 209.85.214.175 as permitted sender) Received: from [209.85.214.175] (HELO mail-ob0-f175.google.com) (209.85.214.175) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 11 Sep 2012 02:44:45 +0000 Received: by obblz20 with SMTP id lz20so39611obb.6 for ; Mon, 10 Sep 2012 19:44:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type :x-system-of-record; bh=dKVMtA21D24r8TzDmDQMvyQJ2mwP9ErODVAE58NgvQs=; b=MOFBarMp3raqs2yhNKET9Z2o6UzC1fkdbjSkgYpbvF0ZJtEckAC/W9VVt2XZYRL4QF 4Bel+QER2JlxWrkbNOyEkrCaAjKP3ug6G0laklQY7T1bmiV7Fym+s4oBoBSLN3SUvxIZ 92UkaBMgH99tVd+eyqqZ+oezH8feABbqMnLbsfI3wTjBiFYKh0sinHv/NLUANTvz2L7P jWiV+T3TFjxH9bZH9Ka+DWmfmnXSAxndY/YmIKppkPZoQhHqmwqjktRY4io0aQrB/lQd VexyV/OABRRproM/CDCgLi27Z+B9pgX8y6mX4F2xJixAGG8vb+iyHkw2b0T5PCGepmRv z3xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:content-type :x-system-of-record:x-gm-message-state; bh=dKVMtA21D24r8TzDmDQMvyQJ2mwP9ErODVAE58NgvQs=; b=oZjNmvLs7n/mAmrZ0tC6aDwbXRK7FPBHjIThljhMyckIpJp6N3bNhVrTBN1pTRLPnI jx4L5wQLjwBZraYySR02SDmIWBSDcqCAg52kd8D8iJz48W8FxhZUHZLOjkvZdCL2Hhk6 3V0nXv8BMsSuclYX5UE8cuXRPpMsRymmF1pO523kEXzo338wPKFBMaHBQzfuaT6AACa+ yBaz2z0CSbEvnVqZ7MHZzsK/prUZ42FVZWeXzHo5z/Xzs1npFBwFlNju3Av2Kk0XgQeb IfGhCYHQPYkOCwR4nNpGumMkx7migZEo26BnFq92C/U12zXRzFTdC74LwlGaWDcLKN/Y m8+w== Received: by 10.60.8.39 with SMTP id o7mr1579017oea.122.1347331464474; Mon, 10 Sep 2012 19:44:24 -0700 (PDT) Received: by 10.60.8.39 with SMTP id o7mr1579006oea.122.1347331464328; Mon, 10 Sep 2012 19:44:24 -0700 (PDT) MIME-Version: 1.0 Sender: agrieve@google.com Received: by 10.182.125.71 with HTTP; Mon, 10 Sep 2012 19:44:03 -0700 (PDT) In-Reply-To: <20120910211816.17EAF35280@tyr.zones.apache.org> References: <20120910211816.17EAF35280@tyr.zones.apache.org> From: Andrew Grieve Date: Mon, 10 Sep 2012 22:44:03 -0400 X-Google-Sender-Auth: S0UQX48Dx1bpD-5GUiJ299StEi0 Message-ID: Subject: Re: [2/2] spec commit: Adding different bridge benchmarking to the Automated Mobile Spec Tests To: bowserj@gmail.com, callback-dev@incubator.apache.org Content-Type: multipart/alternative; boundary=e89a8ff1c7e053775b04c9640dda X-System-Of-Record: true X-Gm-Message-State: ALoCoQma1q8Mw+XSFwn5GweQhRGN13y3iSrV1kylt+uR5wpy0X7c7avio1SntvuFwlPW76P2RJOVNtS68R62y/qKiU1ieG9U1oT3p53SLIVqO+pOrDpTPtKzwwL/p/I8FFsp0OWmStDzaFJVnVd184Wpo8fl7L8w06GA3WLe53ZtlEflhnC69wiJ2ujCU929niO79+RgIBiKFqPZNM1AEAVZtBbP3FPnaA== X-Virus-Checked: Checked by ClamAV on apache.org --e89a8ff1c7e053775b04c9640dda Content-Type: text/plain; charset=ISO-8859-1 Hey Joe, Wondering why make this into a jasmine test? Does it make the results more easily captured? Other thing I'm wondering is if this should use some JS reflection to detect the available bridge modes since they are different on iOS and non-existant on others (mobile-spec tests are supposed to work on all platforms correct?) On Mon, Sep 10, 2012 at 5:18 PM, wrote: > Adding different bridge benchmarking to the Automated Mobile Spec Tests > > > Project: > http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/repo > Commit: > http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/commit/019c43ef > Tree: > http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/tree/019c43ef > Diff: > http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/diff/019c43ef > > Branch: refs/heads/master > Commit: 019c43ef8fe940289145c557bd669df60eb3b759 > Parents: 8cb36ea > Author: Joe Bowser > Authored: Mon Sep 10 14:17:31 2012 -0700 > Committer: Joe Bowser > Committed: Mon Sep 10 14:17:31 2012 -0700 > > ---------------------------------------------------------------------- > autotest/index.html | 1 + > autotest/pages/bridge.html | 49 ++++++++++ > autotest/tests/bridge.tests.js | 176 +++++++++++++++++++++++++++++++++++ > 3 files changed, 226 insertions(+), 0 deletions(-) > ---------------------------------------------------------------------- > > > > http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/019c43ef/autotest/index.html > ---------------------------------------------------------------------- > diff --git a/autotest/index.html b/autotest/index.html > index 70a1eeb..48fe722 100755 > --- a/autotest/index.html > +++ b/autotest/index.html > @@ -28,6 +28,7 @@ > style="width:100%;">Run Notification Tests > style="width:100%;">Run Platform Tests > style="width:100%;">Run Storage Tests > + Run > Bridge Tests > >

Back
> > > > http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/019c43ef/autotest/pages/bridge.html > ---------------------------------------------------------------------- > diff --git a/autotest/pages/bridge.html b/autotest/pages/bridge.html > new file mode 100644 > index 0000000..56d2d59 > --- /dev/null > +++ b/autotest/pages/bridge.html > @@ -0,0 +1,49 @@ > + > + > + > + > + Cordova: Device API Specs > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + > + Back > + > + > + > > > http://git-wip-us.apache.org/repos/asf/incubator-cordova-mobile-spec/blob/019c43ef/autotest/tests/bridge.tests.js > ---------------------------------------------------------------------- > diff --git a/autotest/tests/bridge.tests.js > b/autotest/tests/bridge.tests.js > new file mode 100644 > index 0000000..5a700e0 > --- /dev/null > +++ b/autotest/tests/bridge.tests.js > @@ -0,0 +1,176 @@ > +/* This test requires some extra code to run, because we want benchmark > results */ > + > +/* > + It's never going to be OVER 9000 > + http://youtu.be/SiMHTK15Pik > +*/ > +var FENCEPOST = 9000; > + > +var exec = cordova.require('cordova/exec'); > + > +var echo = cordova.require('cordova/plugin/echo'), > + startTime = +new Date, > + callCount = 0, > + durationMs = 1000, > + asyncEcho = true, > + useSetTimeout = true, > + payloadSize = 5, > + callsPerSecond = 0, > + completeSpy = null, > + payload = new Array(payloadSize * 10 + 1).join('012\n\n > 6789'); > + > +var vanillaWin = function(result) { > + callCount++; > + if (result != payload) { > + console.log('Wrong echo data!'); > + } > + var elapsedMs = new Date - startTime; > + if (elapsedMs < durationMs) { > + if (useSetTimeout) { > + setTimeout(echoMessage, 0); > + } else { > + echoMessage(); > + } > + } else { > + callsPerSecond = callCount * 1000 / elapsedMs; > + console.log('Calls per second: ' + callsPerSecond); > + if(completeSpy != null) > + completeSpy(); > + } > + } > + > +var reset = function() > +{ > + startTime = +new Date, > + callCount = 0, > + durationMs = 1000, > + asyncEcho = true, > + useSetTimeout = true, > + payloadSize = 5, > + callsPerSecond = 0, > + completeSpy = null, > + payload = new Array(payloadSize * 10 + 1).join('012\n\n > 6789'); > +} > + > +var echoMessage = function() > +{ > + echo(vanillaWin, fail, payload, asyncEcho); > +} > + > +var fail = jasmine.createSpy(); > + > +describe('The JS to Native Bridge', function() { > + > + //Run the reset > + beforeEach(function() { > + reset(); > + }); > + > + it('should work with prompt', function() { > + exec.setJsToNativeBridgeMode(0); > + var win = jasmine.createSpy().andCallFake(function(r) { > + vanillaWin(r); > + }); > + completeSpy = jasmine.createSpy(); > + runs(function() { > + echo(win, fail, payload, asyncEcho); > + }); > + waitsFor(function() { return completeSpy.wasCalled; }, "never > completed", durationMs * 2); > + runs(function() { > + expect(callsPerSecond).toBeGreaterThan(FENCEPOST); > + }); > + }); > + it("should work with jsObject", function() { > + exec.setJsToNativeBridgeMode(1); > + var win = jasmine.createSpy().andCallFake(function(r) { > + vanillaWin(r); > + }); > + completeSpy = jasmine.createSpy(); > + runs(function() { > + echo(win, fail, payload, asyncEcho); > + }); > + waitsFor(function() { return completeSpy.wasCalled; }, "never > completed", durationMs * 2); > + runs(function() { > + expect(callsPerSecond).toBeGreaterThan(FENCEPOST); > + }); > + }); > +}); > + > +describe("The Native to JS Bridge", function() { > + > + //Run the reset > + beforeEach(function() { > + reset(); > + }); > + > + it("should work with polling", function() { > + exec.setNativeToJsBridgeMode(0); > + var win = jasmine.createSpy().andCallFake(function(r) { > + vanillaWin(r); > + }); > + completeSpy = jasmine.createSpy(); > + runs(function() { > + echo(win, fail, payload, asyncEcho); > + }); > + waitsFor(function() { return completeSpy.wasCalled; }, "never > completed", durationMs * 2); > + runs(function() { > + expect(callsPerSecond).toBeGreaterThan(FENCEPOST); > + }); > + }); > + it("should work with hanging get", function() { > + exec.setNativeToJsBridgeMode(1); > + var win = jasmine.createSpy().andCallFake(function(r) { > + vanillaWin(r); > + }); > + completeSpy = jasmine.createSpy(); > + runs(function() { > + echo(win, fail, payload, asyncEcho); > + }); > + waitsFor(function() { return completeSpy.wasCalled; }, "never > completed", durationMs * 2); > + runs(function() { > + expect(callsPerSecond).toBeGreaterThan(FENCEPOST); > + }); > + }); > + it("should work with load_url (not on emulator)", function() { > + exec.setNativeToJsBridgeMode(2); > + var win = jasmine.createSpy().andCallFake(function(r) { > + vanillaWin(r); > + }); > + completeSpy = jasmine.createSpy(); > + runs(function() { > + echo(win, fail, payload, asyncEcho); > + }); > + waitsFor(function() { return completeSpy.wasCalled; }, "never > completed", durationMs * 2); > + runs(function() { > + expect(callsPerSecond).toBeGreaterThan(FENCEPOST); > + }); > + }); > + it("should work with online event", function() { > + exec.setNativeToJsBridgeMode(3); > + var win = jasmine.createSpy().andCallFake(function(r) { > + vanillaWin(r); > + }); > + completeSpy = jasmine.createSpy(); > + runs(function() { > + echo(win, fail, payload, asyncEcho); > + }); > + waitsFor(function() { return completeSpy.wasCalled; }, "never > completed", durationMs * 2); > + runs(function() { > + expect(callsPerSecond).toBeGreaterThan(FENCEPOST); > + }); > + }); > + it("should work with the private api", function() { > + exec.setNativeToJsBridgeMode(4); > + var win = jasmine.createSpy().andCallFake(function(r) { > + vanillaWin(r); > + }); > + completeSpy = jasmine.createSpy(); > + runs(function() { > + echo(win, fail, payload, asyncEcho); > + }); > + waitsFor(function() { return completeSpy.wasCalled; }, "never > completed", durationMs * 2); > + runs(function() { > + expect(callsPerSecond).toBeGreaterThan(FENCEPOST); > + }); > + }); > +}); > > --e89a8ff1c7e053775b04c9640dda--