You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by so...@apache.org on 2017/02/28 02:29:59 UTC

[19/50] incubator-weex git commit: * [test] use one global session for all test

* [test] use one global session for all test


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/66670052
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/66670052
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/66670052

Branch: refs/heads/0.11-dev
Commit: 666700529b6ea66107b17f36623410ccc67aa0d3
Parents: 7811a5c
Author: sospartan <so...@gmail.com>
Authored: Wed Feb 22 15:24:38 2017 +0800
Committer: sospartan <so...@gmail.com>
Committed: Wed Feb 22 15:24:38 2017 +0800

----------------------------------------------------------------------
 test/scripts/components/scroll-event.test.js | 28 ++++++++---------------
 test/scripts/dom.test.js                     | 12 +++-------
 test/scripts/index.test.js                   | 12 +++-------
 test/scripts/util.js                         | 24 +++++++++++++++++++
 4 files changed, 39 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/66670052/test/scripts/components/scroll-event.test.js
----------------------------------------------------------------------
diff --git a/test/scripts/components/scroll-event.test.js b/test/scripts/components/scroll-event.test.js
index 2ddb5db..5306257 100644
--- a/test/scripts/components/scroll-event.test.js
+++ b/test/scripts/components/scroll-event.test.js
@@ -9,22 +9,16 @@ var util = require("../util.js");
 
 describe('list scroll event', function () {
   this.timeout(util.getTimeoutMills());
-  var driver = wd(util.getConfig()).initPromiseChain();
-  driver.configureHttp({
-    timeout: 100000
-  });
+  var driver = util.createDriver(wd);
 
   before(function () {
-    return driver
-      .initDriver()
+    return util.init(driver)
       .get('wxpage://' + util.getDeviceHost() +'/list-scroll.js')
       .waitForElementByXPath('//div/text[1]',util.getGETActionWaitTimeMills(),1000)
   });
 
   after(function () {
-      return driver
-      .sleep(1000)
-      .quit()
+      return util.quit(driver);
   })
 
 
@@ -57,22 +51,16 @@ describe('list scroll event', function () {
 
 describe('scroller scroll event', function () {
   this.timeout(util.getTimeoutMills());
-  var driver = wd(util.getConfig()).initPromiseChain();
-  driver.configureHttp({
-    timeout: 100000
-  });
+  var driver = util.createDriver(wd);
 
   before(function () {
-    return driver
-      .initDriver()
+    return util.init(driver)
       .get('wxpage://' + util.getDeviceHost() +'/scroller-scroll.js')
       .waitForElementByXPath('//div/text[1]',util.getGETActionWaitTimeMills(),1000)
   });
 
   after(function () {
-      return driver
-      .sleep(1000)
-      .quit()
+      return util.quit(driver)
   })
 
 
@@ -89,4 +77,6 @@ describe('scroller scroll event', function () {
       assert.equal(y > 200,true)
     })
   })
-});
\ No newline at end of file
+});
+
+

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/66670052/test/scripts/dom.test.js
----------------------------------------------------------------------
diff --git a/test/scripts/dom.test.js b/test/scripts/dom.test.js
index c275dd2..d49f112 100644
--- a/test/scripts/dom.test.js
+++ b/test/scripts/dom.test.js
@@ -9,22 +9,16 @@ var util = require("./util.js");
 
 describe('weex mobile index', function () {
   this.timeout(util.getTimeoutMills());
-  var driver = wd(util.getConfig()).initPromiseChain();
-  driver.configureHttp({
-    timeout: 100000
-  });
+  var driver = util.createDriver(wd);
 
   before(function () {
-    return driver
-      .initDriver()
+    return util.init(driver)
       .get('wxpage://' + util.getDeviceHost() +'/dom-operation.js')
       .waitForElementByXPath('//div/text[2]',util.getGETActionWaitTimeMills(),1000);
   });
 
   after(function () {
-      return driver
-      .sleep(1000)
-      .quit()
+      return util.quit(driver)
   })
 
   it('#1 Repeat', ()=>{

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/66670052/test/scripts/index.test.js
----------------------------------------------------------------------
diff --git a/test/scripts/index.test.js b/test/scripts/index.test.js
index 7e62f28..aa9d77a 100644
--- a/test/scripts/index.test.js
+++ b/test/scripts/index.test.js
@@ -9,22 +9,16 @@ var util = require("./util.js");
 
 describe('weex mobile index', function () {
   this.timeout(util.getTimeoutMills());
-  var driver = wd(util.getConfig()).initPromiseChain();
-  driver.configureHttp({
-    timeout: 100000
-  });
+  var driver = util.createDriver(wd);
 
   before(function () {
-    return driver
-      .initDriver()
+    return util.init(driver)
       .get('wxpage://' + util.getDeviceHost() +'/index.js')
       .waitForElementByXPath('//div/text[1]',util.getGETActionWaitTimeMills(),1000);
   });
 
   after(function () {
-      return driver
-      .sleep(1000)
-      .quit()
+      return util.quit(driver);
   })
 
 

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/66670052/test/scripts/util.js
----------------------------------------------------------------------
diff --git a/test/scripts/util.js b/test/scripts/util.js
index a1b60f1..a607e3f 100644
--- a/test/scripts/util.js
+++ b/test/scripts/util.js
@@ -53,5 +53,29 @@ module.exports = {
     },
     getGETActionWaitTimeMills:function(){
         return (isRunInCI ? 120 : 5 ) * 1000;
+    },
+    createDriver:function(wd){
+        var driver = global._wxDriver;
+        if(!driver){
+            console.log('Create new driver');
+            driver = wd(this.getConfig()).initPromiseChain();
+            driver.configureHttp({
+                timeout: 100000
+            });
+            global._wxDriver = driver;
+        }
+        
+        return driver;
+    },
+    init:function(driver){
+        if(driver._isInit)
+            return driver.status()
+        else{
+            driver._isInit = true;
+            return driver.initDriver()
+        }
+    },
+    quit:function(driver){
+        return driver.sleep(1000).back().sleep(1000);
     }
 }