cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alsoro...@apache.org
Subject cordova-paramedic git commit: Enabled Saucelabs results gathering without localtunnel
Date Mon, 06 Jun 2016 16:26:51 GMT
Repository: cordova-paramedic
Updated Branches:
  refs/heads/master 28d5dac1d -> c3cb0defa


Enabled Saucelabs results gathering without localtunnel


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

Branch: refs/heads/master
Commit: c3cb0defa8e9034256ba608ac98cb5565261af8f
Parents: 28d5dac
Author: Alexander Sorokin <alexander.sorokin@akvelon.com>
Authored: Fri Jun 3 19:01:18 2016 +0300
Committer: Alexander Sorokin <alexander.sorokin@akvelon.com>
Committed: Mon Jun 6 19:25:50 2016 +0300

----------------------------------------------------------------------
 event-cache-plugin/EventCache.js          |  94 +++++++++++++
 event-cache-plugin/paramedic.js           |  43 ++++++
 event-cache-plugin/plugin.xml             |  35 +++++
 lib/ParamedicConfig.js                    |   4 +
 lib/appium/helpers/lib/q.min.js           |   1 +
 lib/appium/helpers/screenshotHelper.js    |  57 ++++++++
 lib/appium/helpers/wdHelper.js            | 175 +++++++++++++++++++++++++
 lib/paramedic.js                          |  75 ++++++++---
 main.js                                   |   2 +-
 paramedic-plugin/JasmineParamedicProxy.js |  27 ++--
 10 files changed, 478 insertions(+), 35 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/c3cb0def/event-cache-plugin/EventCache.js
----------------------------------------------------------------------
diff --git a/event-cache-plugin/EventCache.js b/event-cache-plugin/EventCache.js
new file mode 100644
index 0000000..0309c6f
--- /dev/null
+++ b/event-cache-plugin/EventCache.js
@@ -0,0 +1,94 @@
+/* global window, cordova, device */
+/**
+    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.
+*/
+
+var platformMap = {
+    'ipod touch':'ios',
+    'iphone':'ios'
+};
+
+function JasmineParamedicProxy() {
+    this.specExecuted = 0;
+    this.specFailed = 0;
+    window._jasmineParamedicProxyCache = [];
+}
+
+function cacheEvent (eventName, eventObject) {
+    window._jasmineParamedicProxyCache.push({
+        eventName: eventName,
+        eventObject: eventObject
+    });
+}
+
+JasmineParamedicProxy.prototype.jasmineStarted = function (o) {
+    cacheEvent('jasmineStarted', o);
+};
+
+JasmineParamedicProxy.prototype.specStarted = function (o) {
+    cacheEvent('specStarted', o);
+};
+
+JasmineParamedicProxy.prototype.specDone = function (o) {
+    if (o.status !== 'disabled') {
+        this.specExecuted++;
+    }
+    if (o.status === 'failed') {
+        this.specFailed++;
+    }
+
+    cacheEvent('specDone', o);
+};
+
+JasmineParamedicProxy.prototype.suiteStarted = function (o) {
+    cacheEvent('suiteStarted', o);
+};
+
+JasmineParamedicProxy.prototype.suiteDone = function (o) {
+    cacheEvent('suiteDone', o);
+};
+
+JasmineParamedicProxy.prototype.jasmineDone = function (o) {
+    var p = 'Desktop';
+    var devmodel = 'none';
+    var version = cordova.version;
+    if (typeof device !== 'undefined') {
+        p = device.platform.toLowerCase();
+        devmodel = device.model || device.name;
+        version = device.version.toLowerCase();
+    }
+
+    o = o || {};
+
+    // include platform info
+    /*o.cordova = {
+        platform: (platformMap.hasOwnProperty(p) ? platformMap[p] : p),
+        version: version,
+        model: devmodel
+    };*/
+
+    // include common spec results
+    o.specResults = {
+        specExecuted : this.specExecuted,
+        specFailed   : this.specFailed
+    };
+
+    cacheEvent('jasmineDone', o);
+};
+
+module.exports = JasmineParamedicProxy;

http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/c3cb0def/event-cache-plugin/paramedic.js
----------------------------------------------------------------------
diff --git a/event-cache-plugin/paramedic.js b/event-cache-plugin/paramedic.js
new file mode 100644
index 0000000..6db4b5b
--- /dev/null
+++ b/event-cache-plugin/paramedic.js
@@ -0,0 +1,43 @@
+/* global jasmine, cordova */
+/**
+    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.
+*/
+
+function Paramedic() {
+
+}
+
+Paramedic.prototype.initialize = function() {
+    this.injectJasmineReporter();
+};
+
+Paramedic.prototype.injectJasmineReporter = function () {
+    var EventCache = require('cordova-plugin-paramedic-event-cache.EventCache');
+    var eventCache = new EventCache();
+    var testsModule = cordova.require("cordova-plugin-test-framework.cdvtests");
+    var defineAutoTestsOriginal = testsModule.defineAutoTests;
+
+    testsModule.defineAutoTests = function () {
+        defineAutoTestsOriginal();
+        jasmine.getEnv().addReporter(eventCache);
+    };
+};
+
+new Paramedic().initialize();
+
+module.exports = Paramedic;

http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/c3cb0def/event-cache-plugin/plugin.xml
----------------------------------------------------------------------
diff --git a/event-cache-plugin/plugin.xml b/event-cache-plugin/plugin.xml
new file mode 100644
index 0000000..df85801
--- /dev/null
+++ b/event-cache-plugin/plugin.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+
+<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
+           id="cordova-plugin-paramedic-event-cache"
+      version="1.0.0-dev">
+
+    <name>Paramedic Event Cache</name>
+    <description>Cordova Paramedic Event Cache Plugin</description>
+    <license>Apache 2.0</license>
+
+    <js-module src="EventCache.js" name="EventCache" />
+
+    <js-module src="paramedic.js" name="paramedic">
+        <runs/>
+    </js-module>
+
+</plugin>

http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/c3cb0def/lib/ParamedicConfig.js
----------------------------------------------------------------------
diff --git a/lib/ParamedicConfig.js b/lib/ParamedicConfig.js
index 9a7d44f..1ffc0aa 100644
--- a/lib/ParamedicConfig.js
+++ b/lib/ParamedicConfig.js
@@ -25,6 +25,10 @@ var util = require('./utils').utilities;
 
 function ParamedicConfig(json) {
     this._config = json;
+    // ignore --shouldUseSauce when not running on iOS or Android
+    if (['android', 'ios'].indexOf(this._config.platform) < 0) {
+        this._config.shouldUseSauce = false;
+    }
 }
 
 ParamedicConfig.parseFromArguments = function (argv) {

http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/c3cb0def/lib/appium/helpers/lib/q.min.js
----------------------------------------------------------------------
diff --git a/lib/appium/helpers/lib/q.min.js b/lib/appium/helpers/lib/q.min.js
new file mode 100644
index 0000000..cd7c65d
--- /dev/null
+++ b/lib/appium/helpers/lib/q.min.js
@@ -0,0 +1 @@
+!function(t){"use strict";if("function"==typeof bootstrap)bootstrap("promise",t);else if("object"==typeof
exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define(t);else
if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=t}else{if("undefined"==typeof window&&"undefined"==typeof
self)throw new Error("This environment was not anticipated by Q. Please file a bug.");var
n="undefined"!=typeof window?window:self,e=n.Q;n.Q=t(),n.Q.noConflict=function(){return n.Q=e,this}}}(function(){"use
strict";function t(t){return function(){return K.apply(t,arguments)}}function n(t){return
t===Object(t)}function e(t){return"[object StopIteration]"===en(t)||t instanceof _}function
r(t,n){if(V&&n.stack&&"object"==typeof t&&null!==t&&t.stack&&-1===t.stack.indexOf(rn)){for(var
e=[],r=n;r;r=r.source)r.stack&&e.unshift(r.stack);e.unshift(t.stack);var i=e.join("\n"+rn+"\n");t.stack=o(i)}}function
o(t){for(var n=t.split("\n"),e=[],r=0;r<n.length;++r){var 
 o=n[r];c(o)||i(o)||!o||e.push(o)}return e.join("\n")}function i(t){return-1!==t.indexOf("(module.js:")||-1!==t.indexOf("(node.js:")}function
u(t){var n=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(t);if(n)return[n[1],Number(n[2])];var e=/at
([^ ]+):(\d+):(?:\d+)$/.exec(t);if(e)return[e[1],Number(e[2])];var r=/.*@(.+):(\d+)$/.exec(t);return
r?[r[1],Number(r[2])]:void 0}function c(t){var n=u(t);if(!n)return!1;var e=n[0],r=n[1];return
e===H&&r>=q&&fn>=r}function s(){if(V)try{throw new Error}catch(t){var
n=t.stack.split("\n"),e=n[0].indexOf("@")>0?n[1]:n[2],r=u(e);if(!r)return;return H=r[0],r[1]}}function
f(t,n,e){return function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(n+"
is deprecated, use "+e+" instead.",new Error("").stack),t.apply(t,arguments)}}function p(t){return
t instanceof h?t:g(t)?O(t):E(t)}function a(){function t(t){n=t,i.source=t,W(e,function(n,e){p.nextTick(function(){t.promiseDispatch.apply(t,e)})},void
0),e=void 0,r=void 0}var n,e=[],r=
 [],o=Z(a.prototype),i=Z(h.prototype);if(i.promiseDispatch=function(t,o,i){var u=L(arguments);e?(e.push(u),"when"===o&&i[1]&&r.push(i[1])):p.nextTick(function(){n.promiseDispatch.apply(n,u)})},i.valueOf=function(){if(e)return
i;var t=v(n);return m(t)&&(n=t),t},i.inspect=function(){return n?n.inspect():{state:"pending"}},p.longStackSupport&&V)try{throw
new Error}catch(u){i.stack=u.stack.substring(u.stack.indexOf("\n")+1)}return o.promise=i,o.resolve=function(e){n||t(p(e))},o.fulfill=function(e){n||t(E(e))},o.reject=function(e){n||t(R(e))},o.notify=function(t){n||W(r,function(n,e){p.nextTick(function(){e(t)})},void
0)},o}function l(t){if("function"!=typeof t)throw new TypeError("resolver must be a function.");var
n=a();try{t(n.resolve,n.reject,n.notify)}catch(e){n.reject(e)}return n.promise}function d(t){return
l(function(n,e){for(var r=0,o=t.length;o>r;r++)p(t[r]).then(n,e)})}function h(t,n,e){void
0===n&&(n=function(t){return R(new Error("Promise does not support operation: "+t))}),v
 oid 0===e&&(e=function(){return{state:"unknown"}});var r=Z(h.prototype);if(r.promiseDispatch=function(e,o,i){var
u;try{u=t[o]?t[o].apply(r,i):n.call(r,o,i)}catch(c){u=R(c)}e&&e(u)},r.inspect=e,e){var
o=e();"rejected"===o.state&&(r.exception=o.reason),r.valueOf=function(){var t=e();return"pending"===t.state||"rejected"===t.state?r:t.value}}return
r}function y(t,n,e,r){return p(t).then(n,e,r)}function v(t){if(m(t)){var n=t.inspect();if("fulfilled"===n.state)return
n.value}return t}function m(t){return t instanceof h}function g(t){return n(t)&&"function"==typeof
t.then}function k(t){return m(t)&&"pending"===t.inspect().state}function j(t){return!m(t)||"fulfilled"===t.inspect().state}function
w(t){return m(t)&&"rejected"===t.inspect().state}function b(){on.length=0,un.length=0,sn||(sn=!0)}function
x(t,n){sn&&("object"==typeof process&&"function"==typeof process.emit&&p.nextTick.runAfter(function(){-1!==X(un,t)&&(process.emit("unhandledRejection",n,t),cn.push(t))}),un.push(t),on.push(n&&
 "undefined"!=typeof n.stack?n.stack:"(no stack) "+n))}function T(t){if(sn){var n=X(un,t);-1!==n&&("object"==typeof
process&&"function"==typeof process.emit&&p.nextTick.runAfter(function(){var
e=X(cn,t);-1!==e&&(process.emit("rejectionHandled",on[n],t),cn.splice(e,1))}),un.splice(n,1),on.splice(n,1))}}function
R(t){var n=h({when:function(n){return n&&T(this),n?n(t):this}},function(){return this},function(){return{state:"rejected",reason:t}});return
x(n,t),n}function E(t){return h({when:function(){return t},get:function(n){return t[n]},set:function(n,e){t[n]=e},"delete":function(n){delete
t[n]},post:function(n,e){return null===n||void 0===n?t.apply(void 0,e):t[n].apply(t,e)},apply:function(n,e){return
t.apply(n,e)},keys:function(){return nn(t)}},void 0,function(){return{state:"fulfilled",value:t}})}function
O(t){var n=a();return p.nextTick(function(){try{t.then(n.resolve,n.reject,n.notify)}catch(e){n.reject(e)}}),n.promise}function
S(t){return h({isDef:function(){}},function(n,e){retu
 rn A(t,n,e)},function(){return p(t).inspect()})}function N(t,n,e){return p(t).spread(n,e)}function
D(t){return function(){function n(t,n){var u;if("undefined"==typeof StopIteration){try{u=r[t](n)}catch(c){return
R(c)}return u.done?p(u.value):y(u.value,o,i)}try{u=r[t](n)}catch(c){return e(c)?p(c.value):R(c)}return
y(u,o,i)}var r=t.apply(this,arguments),o=n.bind(n,"next"),i=n.bind(n,"throw");return o()}}function
P(t){p.done(p.async(t)())}function C(t){throw new _(t)}function Q(t){return function(){return
N([this,I(arguments)],function(n,e){return t.apply(n,e)})}}function A(t,n,e){return p(t).dispatch(n,e)}function
I(t){return y(t,function(t){var n=0,e=a();return W(t,function(r,o,i){var u;m(o)&&"fulfilled"===(u=o.inspect()).state?t[i]=u.value:(++n,y(o,function(r){t[i]=r,0===--n&&e.resolve(t)},e.reject,function(t){e.notify({index:i,value:t})}))},void
0),0===n&&e.resolve(t),e.promise})}function U(t){if(0===t.length)return p.resolve();var
n=p.defer(),e=0;return W(t,function(r,o,i){functio
 n u(t){n.resolve(t)}function c(){e--,0===e&&n.reject(new Error("Can't get fulfillment
value from any promise, all promises were rejected."))}function s(t){n.notify({index:i,value:t})}var
f=t[i];e++,y(f,u,c,s)},void 0),n.promise}function F(t){return y(t,function(t){return t=Y(t,p),y(I(Y(t,function(t){return
y(t,z,z)})),function(){return t})})}function M(t){return p(t).allSettled()}function B(t,n){return
p(t).then(void 0,void 0,n)}function $(t,n){return p(t).nodeify(n)}var V=!1;try{throw new Error}catch(G){V=!!G.stack}var
H,_,q=s(),z=function(){},J=function(){function t(){for(var t,r;e.next;)e=e.next,t=e.task,e.task=void
0,r=e.domain,r&&(e.domain=void 0,r.enter()),n(t,r);for(;c.length;)t=c.pop(),n(t);o=!1}function
n(n,e){try{n()}catch(r){if(u)throw e&&e.exit(),setTimeout(t,0),e&&e.enter(),r;setTimeout(function(){throw
r},0)}e&&e.exit()}var e={task:void 0,next:null},r=e,o=!1,i=void 0,u=!1,c=[];if(J=function(t){r=r.next={task:t,domain:u&&process.domain,next:null},o||(o=!0,i())},"object"
 ==typeof process&&"[object process]"===process.toString()&&process.nextTick)u=!0,i=function(){process.nextTick(t)};else
if("function"==typeof setImmediate)i="undefined"!=typeof window?setImmediate.bind(window,t):function(){setImmediate(t)};else
if("undefined"!=typeof MessageChannel){var s=new MessageChannel;s.port1.onmessage=function(){i=f,s.port1.onmessage=t,t()};var
f=function(){s.port2.postMessage(0)};i=function(){setTimeout(t,0),f()}}else i=function(){setTimeout(t,0)};return
J.runAfter=function(t){c.push(t),o||(o=!0,i())},J}(),K=Function.call,L=t(Array.prototype.slice),W=t(Array.prototype.reduce||function(t,n){var
e=0,r=this.length;if(1===arguments.length)for(;;){if(e in this){n=this[e++];break}if(++e>=r)throw
new TypeError}for(;r>e;e++)e in this&&(n=t(n,this[e],e));return n}),X=t(Array.prototype.indexOf||function(t){for(var
n=0;n<this.length;n++)if(this[n]===t)return n;return-1}),Y=t(Array.prototype.map||function(t,n){var
e=this,r=[];return W(e,function(o,i,u){r.push(t.call(n,i
 ,u,e))},void 0),r}),Z=Object.create||function(t){function n(){}return n.prototype=t,new n},tn=t(Object.prototype.hasOwnProperty),nn=Object.keys||function(t){var
n=[];for(var e in t)tn(t,e)&&n.push(e);return n},en=t(Object.prototype.toString);_="undefined"!=typeof
ReturnValue?ReturnValue:function(t){this.value=t};var rn="From previous event:";p.resolve=p,p.nextTick=J,p.longStackSupport=!1,"object"==typeof
process&&process&&process.env&&process.env.Q_DEBUG&&(p.longStackSupport=!0),p.defer=a,a.prototype.makeNodeResolver=function(){var
t=this;return function(n,e){n?t.reject(n):t.resolve(arguments.length>2?L(arguments,1):e)}},p.Promise=l,p.promise=l,l.race=d,l.all=I,l.reject=R,l.resolve=p,p.passByCopy=function(t){return
t},h.prototype.passByCopy=function(){return this},p.join=function(t,n){return p(t).join(n)},h.prototype.join=function(t){return
p([this,t]).spread(function(t,n){if(t===n)return t;throw new Error("Can't join: not the same:
"+t+" "+n)})},p.race=d,h.prototype.race=function()
 {return this.then(p.race)},p.makePromise=h,h.prototype.toString=function(){return"[object
Promise]"},h.prototype.then=function(t,n,e){function o(n){try{return"function"==typeof t?t(n):n}catch(e){return
R(e)}}function i(t){if("function"==typeof n){r(t,c);try{return n(t)}catch(e){return R(e)}}return
R(t)}function u(t){return"function"==typeof e?e(t):t}var c=this,s=a(),f=!1;return p.nextTick(function(){c.promiseDispatch(function(t){f||(f=!0,s.resolve(o(t)))},"when",[function(t){f||(f=!0,s.resolve(i(t)))}])}),c.promiseDispatch(void
0,"when",[void 0,function(t){var n,e=!1;try{n=u(t)}catch(r){if(e=!0,!p.onerror)throw r;p.onerror(r)}e||s.notify(n)}]),s.promise},p.tap=function(t,n){return
p(t).tap(n)},h.prototype.tap=function(t){return t=p(t),this.then(function(n){return t.fcall(n).thenResolve(n)})},p.when=y,h.prototype.thenResolve=function(t){return
this.then(function(){return t})},p.thenResolve=function(t,n){return p(t).thenResolve(n)},h.prototype.thenReject=function(t){return
this.then(f
 unction(){throw t})},p.thenReject=function(t,n){return p(t).thenReject(n)},p.nearer=v,p.isPromise=m,p.isPromiseAlike=g,p.isPending=k,h.prototype.isPending=function(){return"pending"===this.inspect().state},p.isFulfilled=j,h.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},p.isRejected=w,h.prototype.isRejected=function(){return"rejected"===this.inspect().state};var
on=[],un=[],cn=[],sn=!0;p.resetUnhandledRejections=b,p.getUnhandledReasons=function(){return
on.slice()},p.stopUnhandledRejectionTracking=function(){b(),sn=!1},b(),p.reject=R,p.fulfill=E,p.master=S,p.spread=N,h.prototype.spread=function(t,n){return
this.all().then(function(n){return t.apply(void 0,n)},n)},p.async=D,p.spawn=P,p["return"]=C,p.promised=Q,p.dispatch=A,h.prototype.dispatch=function(t,n){var
e=this,r=a();return p.nextTick(function(){e.promiseDispatch(r.resolve,t,n)}),r.promise},p.get=function(t,n){return
p(t).dispatch("get",[n])},h.prototype.get=function(t){return this.dispatch("get",[t
 ])},p.set=function(t,n,e){return p(t).dispatch("set",[n,e])},h.prototype.set=function(t,n){return
this.dispatch("set",[t,n])},p.del=p["delete"]=function(t,n){return p(t).dispatch("delete",[n])},h.prototype.del=h.prototype["delete"]=function(t){return
this.dispatch("delete",[t])},p.mapply=p.post=function(t,n,e){return p(t).dispatch("post",[n,e])},h.prototype.mapply=h.prototype.post=function(t,n){return
this.dispatch("post",[t,n])},p.send=p.mcall=p.invoke=function(t,n){return p(t).dispatch("post",[n,L(arguments,2)])},h.prototype.send=h.prototype.mcall=h.prototype.invoke=function(t){return
this.dispatch("post",[t,L(arguments,1)])},p.fapply=function(t,n){return p(t).dispatch("apply",[void
0,n])},h.prototype.fapply=function(t){return this.dispatch("apply",[void 0,t])},p["try"]=p.fcall=function(t){return
p(t).dispatch("apply",[void 0,L(arguments,1)])},h.prototype.fcall=function(){return this.dispatch("apply",[void
0,L(arguments)])},p.fbind=function(t){var n=p(t),e=L(arguments,1);return fu
 nction(){return n.dispatch("apply",[this,e.concat(L(arguments))])}},h.prototype.fbind=function(){var
t=this,n=L(arguments);return function(){return t.dispatch("apply",[this,n.concat(L(arguments))])}},p.keys=function(t){return
p(t).dispatch("keys",[])},h.prototype.keys=function(){return this.dispatch("keys",[])},p.all=I,h.prototype.all=function(){return
I(this)},p.any=U,h.prototype.any=function(){return U(this)},p.allResolved=f(F,"allResolved","allSettled"),h.prototype.allResolved=function(){return
F(this)},p.allSettled=M,h.prototype.allSettled=function(){return this.then(function(t){return
I(Y(t,function(t){function n(){return t.inspect()}return t=p(t),t.then(n,n)}))})},p.fail=p["catch"]=function(t,n){return
p(t).then(void 0,n)},h.prototype.fail=h.prototype["catch"]=function(t){return this.then(void
0,t)},p.progress=B,h.prototype.progress=function(t){return this.then(void 0,void 0,t)},p.fin=p["finally"]=function(t,n){return
p(t)["finally"](n)},h.prototype.fin=h.prototype["finally"]=
 function(t){return t=p(t),this.then(function(n){return t.fcall().then(function(){return n})},function(n){return
t.fcall().then(function(){throw n})})},p.done=function(t,n,e,r){return p(t).done(n,e,r)},h.prototype.done=function(t,n,e){var
o=function(t){p.nextTick(function(){if(r(t,i),!p.onerror)throw t;p.onerror(t)})},i=t||n||e?this.then(t,n,e):this;"object"==typeof
process&&process&&process.domain&&(o=process.domain.bind(o)),i.then(void
0,o)},p.timeout=function(t,n,e){return p(t).timeout(n,e)},h.prototype.timeout=function(t,n){var
e=a(),r=setTimeout(function(){n&&"string"!=typeof n||(n=new Error(n||"Timed out after
"+t+" ms"),n.code="ETIMEDOUT"),e.reject(n)},t);return this.then(function(t){clearTimeout(r),e.resolve(t)},function(t){clearTimeout(r),e.reject(t)},e.notify),e.promise},p.delay=function(t,n){return
void 0===n&&(n=t,t=void 0),p(t).delay(n)},h.prototype.delay=function(t){return this.then(function(n){var
e=a();return setTimeout(function(){e.resolve(n)},t),e.promise})},p.nfapp
 ly=function(t,n){return p(t).nfapply(n)},h.prototype.nfapply=function(t){var n=a(),e=L(t);return
e.push(n.makeNodeResolver()),this.fapply(e).fail(n.reject),n.promise},p.nfcall=function(t){var
n=L(arguments,1);return p(t).nfapply(n)},h.prototype.nfcall=function(){var t=L(arguments),n=a();return
t.push(n.makeNodeResolver()),this.fapply(t).fail(n.reject),n.promise},p.nfbind=p.denodeify=function(t){var
n=L(arguments,1);return function(){var e=n.concat(L(arguments)),r=a();return e.push(r.makeNodeResolver()),p(t).fapply(e).fail(r.reject),r.promise}},h.prototype.nfbind=h.prototype.denodeify=function(){var
t=L(arguments);return t.unshift(this),p.denodeify.apply(void 0,t)},p.nbind=function(t,n){var
e=L(arguments,2);return function(){function r(){return t.apply(n,arguments)}var o=e.concat(L(arguments)),i=a();return
o.push(i.makeNodeResolver()),p(r).fapply(o).fail(i.reject),i.promise}},h.prototype.nbind=function(){var
t=L(arguments,0);return t.unshift(this),p.nbind.apply(void 0,t)},p.nmapply=p
 .npost=function(t,n,e){return p(t).npost(n,e)},h.prototype.nmapply=h.prototype.npost=function(t,n){var
e=L(n||[]),r=a();return e.push(r.makeNodeResolver()),this.dispatch("post",[t,e]).fail(r.reject),r.promise},p.nsend=p.nmcall=p.ninvoke=function(t,n){var
e=L(arguments,2),r=a();return e.push(r.makeNodeResolver()),p(t).dispatch("post",[n,e]).fail(r.reject),r.promise},h.prototype.nsend=h.prototype.nmcall=h.prototype.ninvoke=function(t){var
n=L(arguments,1),e=a();return n.push(e.makeNodeResolver()),this.dispatch("post",[t,n]).fail(e.reject),e.promise},p.nodeify=$,h.prototype.nodeify=function(t){return
t?void this.then(function(n){p.nextTick(function(){t(null,n)})},function(n){p.nextTick(function(){t(n)})}):this},p.noConflict=function(){throw
new Error("Q.noConflict only works when Q is used as a global")};var fn=s();return p});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/c3cb0def/lib/appium/helpers/screenshotHelper.js
----------------------------------------------------------------------
diff --git a/lib/appium/helpers/screenshotHelper.js b/lib/appium/helpers/screenshotHelper.js
new file mode 100644
index 0000000..dab6d75
--- /dev/null
+++ b/lib/appium/helpers/screenshotHelper.js
@@ -0,0 +1,57 @@
+/* jshint node: true */
+/*
+ *
+ * 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';
+
+var path = require('path');
+
+function generateScreenshotName() {
+    var date = new Date();
+
+    var month = date.getMonth() + 1;
+    var day = date.getDate();
+    var hour = date.getHours();
+    var min = date.getMinutes();
+    var sec = date.getSeconds();
+
+    month = (month < 10 ? "0" : "") + month;
+    day = (day < 10 ? "0" : "") + day;
+    hour = (hour < 10 ? "0" : "") + hour;
+    min = (min < 10 ? "0" : "") + min;
+    sec = (sec < 10 ? "0" : "") + sec;
+
+    return date.getFullYear() + '-' + month + '-' + day + '_' +  hour + '.' + min + '.' +
sec + '.png';
+}
+
+module.exports.saveScreenshot = function (driver) {
+    var oldContext;
+    return driver
+        .currentContext()
+        .then(function (cc) {
+            oldContext = cc;
+        })
+        .context('NATIVE_APP')
+        .saveScreenshot(path.join(global.SCREENSHOT_PATH, generateScreenshotName()))
+        .then(function () {
+            return driver.context(oldContext);
+        });
+};

http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/c3cb0def/lib/appium/helpers/wdHelper.js
----------------------------------------------------------------------
diff --git a/lib/appium/helpers/wdHelper.js b/lib/appium/helpers/wdHelper.js
new file mode 100644
index 0000000..e315422
--- /dev/null
+++ b/lib/appium/helpers/wdHelper.js
@@ -0,0 +1,175 @@
+/* jshint node: true */
+/* global navigator, document */
+/*
+ *
+ * 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';
+
+var APPIUM_SERVER_HOST = 'localhost';
+var APPIUM_SERVER_PORT = 4723;
+var WEBVIEW_WAIT_TIMEOUT = 5000;
+var IMPLICIT_WAIT_TIMEOUT = 10000;
+var ASYNC_SCRIPT_TIMEOUT = 60000;
+
+var fs = require('fs');
+var path = require('path');
+var wd = global.WD || require('wd');
+
+module.exports.getDriver = function (platform) {
+    var normalizedPlatform;
+    switch (platform.toLowerCase()) {
+        case 'android':
+            normalizedPlatform = 'Android';
+            break;
+        case 'ios':
+            normalizedPlatform = 'iOS';
+            break;
+        default:
+            throw 'Unknown platform: ' + platform;
+    }
+
+    var serverConfig = {
+        host: APPIUM_SERVER_HOST,
+        port: APPIUM_SERVER_PORT
+    };
+
+    var driverConfig = {
+        browserName: '',
+        platformName: normalizedPlatform,
+        platformVersion: global.PLATFORM_VERSION || '',
+        deviceName: global.DEVICE_NAME || '',
+        app: global.PACKAGE_PATH,
+        autoAcceptAlerts: true,
+    };
+    if (global.UDID) {
+        driverConfig.udid = global.UDID;
+    }
+
+    var driver = global.WD.promiseChainRemote(serverConfig);
+    module.exports.configureLogging(driver);
+
+    return driver
+        .init(driverConfig)
+        .setImplicitWaitTimeout(IMPLICIT_WAIT_TIMEOUT);
+};
+
+module.exports.getWD = function () {
+    return wd;
+};
+
+module.exports.getWebviewContext = function (driver, retries) {
+    if (typeof retries === 'undefined') {
+        retries = 2;
+    }
+    return driver
+        .contexts()
+        .then(function (contexts) {
+            // take the last webview context
+            for (var i = 0; i < contexts.length; i++) {
+                if (contexts[i].indexOf('WEBVIEW') >= 0) {
+                    return contexts[i];
+                }
+            }
+            // no webview context, the app is still loading
+            return driver
+                .then(function () {
+                    if (retries > 0) {
+                        console.log('Couldn\'t get webview context. Retries remaining: '
+ retries);
+                        return driver
+                            .sleep(WEBVIEW_WAIT_TIMEOUT)
+                            .then(function () {
+                                return module.exports.getWebviewContext(driver, retries -
1);
+                        });
+                    }
+                    throw 'Couldn\'t get webview context. Failing...';
+                });
+        });
+};
+
+module.exports.waitForDeviceReady = function (driver) {
+    return driver
+        .setAsyncScriptTimeout(ASYNC_SCRIPT_TIMEOUT)
+        .executeAsync(function (cb) {
+            document.addEventListener('deviceready', cb, false);
+        }, []);
+};
+
+module.exports.injectLibraries = function (driver) {
+    var q = fs.readFileSync(path.join(__dirname, '/lib/q.min.js'), 'utf8');
+    return driver
+        .execute(q)
+        .execute(function () {
+            navigator._appiumPromises = {};
+        }, []);
+};
+
+module.exports.configureLogging = function (driver) {
+    driver.on('status', function (info) {
+        console.log(info);
+    });
+    driver.on('command', function (meth, path, data) {
+        console.log(' > ' + meth, path, data || '');
+    });
+    driver.on('http', function (meth, path, data) {
+        console.log(' > ' + meth, path, data || '');
+    });
+};
+
+module.exports.tapElementByXPath = function (xpath, driver) {
+    return driver
+        .waitForElementByXPath(xpath, 30000)
+        .getLocation()
+        .then(function (loc) {
+            if (loc.x <= 0) {
+                loc.x = 1;
+            }
+            if (loc.y <= 0) {
+                loc.y = 1;
+            }
+            loc.x = Math.floor(loc.x + 1);
+            loc.y = Math.floor(loc.y + 1);
+
+            var wd = module.exports.getWD();
+            var tapElement = new wd.TouchAction();
+            tapElement.tap(loc);
+            return driver.performTouchAction(tapElement);
+        });
+};
+
+wd.addPromiseChainMethod('getWebviewContext', function (retries) {
+    return module.exports.getWebviewContext(this, retries);
+});
+
+wd.addPromiseChainMethod('injectLibraries', function () {
+    return module.exports.tapElementByXPath(this);
+});
+
+wd.addPromiseChainMethod('waitForDeviceReady', function () {
+    return module.exports.waitForDeviceReady(this);
+});
+
+wd.addPromiseChainMethod('injectLibraries', function () {
+    return module.exports.tapElementByXPath(this);
+});
+
+wd.addPromiseChainMethod('tapElementByXPath', function (xpath) {
+    return module.exports.tapElementByXPath(xpath, this);
+});

http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/c3cb0def/lib/paramedic.js
----------------------------------------------------------------------
diff --git a/lib/paramedic.js b/lib/paramedic.js
index d26e3ba..ecfad7f 100644
--- a/lib/paramedic.js
+++ b/lib/paramedic.js
@@ -1,3 +1,4 @@
+/* global window */
 /**
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
@@ -36,10 +37,16 @@ var ParamediciOSPermissions = require('./ParamediciOSPermissions');
 var ParamedicTargetChooser  = require('./ParamedicTargetChooser');
 var ParamedicAppUninstall   = require('./ParamedicAppUninstall');
 
+//this will add custom promise chain methods to the driver prototype
+require('./appium/helpers/wdHelper');
+
 // Time to wait for initial device connection.
 // If device has not connected within this interval the tests are stopped.
 var INITIAL_CONNECTION_TIMEOUT = 300000; // 5mins
 
+var SAUCE_HOST = 'ondemand.saucelabs.com';
+var SAUCE_PORT = 80;
+
 var applicationsToGrantPermission = [
     'kTCCServiceAddressBook'
 ];
@@ -111,6 +118,9 @@ ParamedicRunner.prototype.installPlugins = function () {
     this.pluginsManager.installTestsForExistingPlugins();
 
     var additionalPlugins = ['cordova-plugin-test-framework', 'cordova-plugin-device', path.join(__dirname,
'../paramedic-plugin')];
+    if (this.config.shouldUseSauce() && !this.config.getUseTunnel()) {
+        additionalPlugins.push(path.join(__dirname, '../event-cache-plugin'));
+    }
     if (this.config.getPlatformId() === 'windows') {
         additionalPlugins.push(path.join(__dirname, '../debug-mode-plugin'));
     }
@@ -500,36 +510,59 @@ ParamedicRunner.prototype.runSauceTests = function () {
                 caps.autoAcceptAlerts = true;
                 break;
             default:
-                throw new Error('Unsupported platform for sauce labs testing');
+                throw new Error('Unsupported platform for sauce labs testing: ' + this.config.getPlatformId());
         }
 
-        return Q.promise(function(resolve, reject) {
-            logger.normal('cordova-paramedic: connecting webdriver');
+        logger.normal('cordova-paramedic: connecting webdriver');
 
-            var driver = wd.remote('ondemand.saucelabs.com', 80, user, key);
-            driver.init(caps, function(error) {
-                if (error) {
-                    throw new Error('Error starting Appium web driver');
-                }
-
-                logger.normal('cordova-paramedic: connecting to app');
-
-                self.waitForTests()
-                .done(function(result) {
-                    logger.normal('cordova-paramedic: tests finished');
-                    driver.quit(function () {
-                        resolve(result);
+        var driver = wd.promiseChainRemote(SAUCE_HOST, SAUCE_PORT, user, key);
+        return driver.init(caps)
+        .then(function () {
+            if (self.config.getUseTunnel()) {
+                return driver;
+            }
+            return driver
+            .getWebviewContext()
+            .then(function (webview) {
+                return driver.context(webview);
+            });
+        })
+        .then(function () {
+            logger.normal('cordova-paramedic: connecting to app');
+
+            if (!self.config.getUseTunnel()) {
+                var pollForResults = setInterval(function () {
+                    // polling for new events
+                    driver.execute(function () {
+                        var result = window._jasmineParamedicProxyCache;
+                        window._jasmineParamedicProxyCache = [];
+                        return result;
+                    }, [])
+                    .then(function (events) {
+                        for (var i = 0; i < events.length; i++) {
+                            self.server.emit(events[i].eventName, events[i].eventObject);
+                        }
                     });
-                }, function () {
-                    logger.normal('cordova-paramedic: tests failed to complete; ending appium
session');
-                    driver.quit(reject);
-                });
+                }, 5000);
+            }
+
+            return self.waitForTests()
+            .then(function (result) {
+                logger.normal('cordova-paramedic: tests finished');
+            }, function () {
+                logger.normal('cordova-paramedic: tests failed to complete; ending appium
session');
+            })
+            .fin(function () {
+                if (pollForResults) {
+                    clearInterval(pollForResults);
+                }
+                return driver.quit();
             });
         });
     });
 };
 
-var storedCWD =  null;
+var storedCWD = null;
 
 exports.run = function(paramedicConfig) {
 

http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/c3cb0def/main.js
----------------------------------------------------------------------
diff --git a/main.js b/main.js
index 2ab2969..3a73485 100755
--- a/main.js
+++ b/main.js
@@ -71,7 +71,7 @@ if (pathToParamedicConfig || // --config
     .catch(function (error) {
         if (error && error.stack) {
             console.error(error.stack);
-        } else {
+        } else if (error) {
             console.error(error);
         }
         process.exit(1);

http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/c3cb0def/paramedic-plugin/JasmineParamedicProxy.js
----------------------------------------------------------------------
diff --git a/paramedic-plugin/JasmineParamedicProxy.js b/paramedic-plugin/JasmineParamedicProxy.js
index a75135a..cfec003 100644
--- a/paramedic-plugin/JasmineParamedicProxy.js
+++ b/paramedic-plugin/JasmineParamedicProxy.js
@@ -1,3 +1,4 @@
+/* global window, cordova, device */
 /**
     Licensed to the Apache Software Foundation (ASF) under one
     or more contributor license agreements.  See the NOTICE file
@@ -17,6 +18,11 @@
     under the License.
 */
 
+var platformMap = {
+    'ipod touch':'ios',
+    'iphone':'ios'
+};
+
 function JasmineParamedicProxy(socket) {
     this.socket = socket;
     this.specExecuted = 0;
@@ -52,11 +58,11 @@ JasmineParamedicProxy.prototype.suiteDone = function (o) {
 
 JasmineParamedicProxy.prototype.jasmineDone = function (o) {
     var p = 'Desktop';
-    var devmodel='none';
+    var devmodel = 'none';
     var version = cordova.version;
-    if(typeof device != 'undefined') {
+    if (typeof device !== 'undefined') {
         p = device.platform.toLowerCase();
-        devmodel=device.model || device.name;
+        devmodel = device.model || device.name;
         version = device.version.toLowerCase();
     }
 
@@ -64,23 +70,18 @@ JasmineParamedicProxy.prototype.jasmineDone = function (o) {
 
     // include platform info
     o.cordova = {
-        platform:(platformMap.hasOwnProperty(p) ? platformMap[p] : p),
-        version:version,
-        model:devmodel
-    }
+        platform: (platformMap.hasOwnProperty(p) ? platformMap[p] : p),
+        version: version,
+        model: devmodel
+    };
 
     // include common spec results
     o.specResults = {
         specExecuted : this.specExecuted,
         specFailed   : this.specFailed
-    }
+    };
 
     this.socket.emit('jasmineDone', o);
 };
 
-var platformMap = {
-    'ipod touch':'ios',
-    'iphone':'ios'
-};
-
 module.exports = JasmineParamedicProxy;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message