You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2017/08/25 07:13:14 UTC

[13/18] incubator-weex git commit: * [test] add pic shot when after test

* [test] add pic shot when after 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/712fa692
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/712fa692
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/712fa692

Branch: refs/heads/0.16-dev
Commit: 712fa692bdacb31e81f4d58929efcb46c5ba3356
Parents: 4797325
Author: gurisxie <27...@qq.com>
Authored: Fri Aug 25 11:49:29 2017 +0800
Committer: gurisxie <27...@qq.com>
Committed: Fri Aug 25 11:49:29 2017 +0800

----------------------------------------------------------------------
 test/mocha.opts                            |  2 --
 test/pages/components/hyperlink.vue        | 31 -----------------
 test/pages/components/hyperlink_target.vue | 23 -------------
 test/scripts/components/a-src.test.js      | 30 +++++++++--------
 test/scripts/components/hyperlink.test.js  | 44 -------------------------
 test/scripts/util.js                       | 21 ++++++++----
 6 files changed, 32 insertions(+), 119 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/712fa692/test/mocha.opts
----------------------------------------------------------------------
diff --git a/test/mocha.opts b/test/mocha.opts
deleted file mode 100644
index f8baf14..0000000
--- a/test/mocha.opts
+++ /dev/null
@@ -1,2 +0,0 @@
---recursive
---bail

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/712fa692/test/pages/components/hyperlink.vue
----------------------------------------------------------------------
diff --git a/test/pages/components/hyperlink.vue b/test/pages/components/hyperlink.vue
deleted file mode 100644
index 7183f4f..0000000
--- a/test/pages/components/hyperlink.vue
+++ /dev/null
@@ -1,31 +0,0 @@
-<template>
-  <div class="wrapper">
-    <a test-id='a-itself' class="button" href="hyperlink_target.js?_wxpage=true">
-      <text test-id='content-inside-a' class="text">Jump</text>
-    </a>
-  </div>
-</template>
-<style>
-  .wrapper {
-    flex-direction: column;
-    justify-content: center;
-  }
-
-  .button {
-    width: 450px;
-    margin-top: 30px;
-    margin-left: 150px;
-    padding-top: 20px;
-    padding-bottom: 20px;
-    border-width: 2px;
-    border-style: solid;
-    border-color: #DDDDDD;
-    background-color: #F5F5F5
-  }
-
-  .text {
-    font-size: 60px;
-    color: #666666;
-    text-align: center;
-  }
-</style>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/712fa692/test/pages/components/hyperlink_target.vue
----------------------------------------------------------------------
diff --git a/test/pages/components/hyperlink_target.vue b/test/pages/components/hyperlink_target.vue
deleted file mode 100644
index 9aab5c0..0000000
--- a/test/pages/components/hyperlink_target.vue
+++ /dev/null
@@ -1,23 +0,0 @@
-<template>
-  <div>
-    <text style="font-size:100px;" test-id='just_text' @click="jump_back">You just clicked A tag.</text>
-  </div>
-</template>
-
-<script>
-  var navigator = weex.requireModule('navigator')
-  var modal = weex.requireModule('modal')
-  export default {
-    methods: {
-      jump_back(event) {
-        navigator.pop({
-          animated: "true"
-        }, event => {
-          modal.toast({
-            message: 'callback: ' + event
-          })
-        })
-      }
-    }
-  };
-</script>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/712fa692/test/scripts/components/a-src.test.js
----------------------------------------------------------------------
diff --git a/test/scripts/components/a-src.test.js b/test/scripts/components/a-src.test.js
index bbc8b99..082ab54 100644
--- a/test/scripts/components/a-src.test.js
+++ b/test/scripts/components/a-src.test.js
@@ -21,21 +21,25 @@ describe('a-src-test', function () {
     return util.quit(driver);
   })
 
-  click_a_tag('#1 Click A tag itself', 'a-itself')
-  click_a_tag('#2 Click some content inside a', 'content-inside-a')
+  it('#1 Click A tag itself', () => {
+    return driver
+      .waitForElementById('a-itself', maxWt, 2000)
+      .click()
+      .waitForElementByName('a-support-href1', maxWt, 2000)
+      .waitForElementByName('jump_back', maxWt, 2000)
+      .click();
+  })
 
-  function click_a_tag(title, id) {
-    it(title, () => {
-      return driver
-        .waitForElementById(id, maxWt, 2000)
-        .click()
-        .waitForElementByName('a-support-href1', maxWt, 2000)
-        .waitForElementByName('jump_back', maxWt, 2000)
-        .click();
-    })
-  }
+  it('#2 Click some content inside a', () => {
+    return driver
+      .waitForElementByName('Jump', maxWt, 2000)
+      .click()
+      .waitForElementByName('a-support-href1', maxWt, 2000)
+      .waitForElementByName('jump_back', maxWt, 2000)
+      .click();
+  })
 
-  it('change src', () => {
+  it('#3 change src', () => {
     return driver
       .waitForElementByName('changeSrc', maxWt, 2000)
       .click()

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/712fa692/test/scripts/components/hyperlink.test.js
----------------------------------------------------------------------
diff --git a/test/scripts/components/hyperlink.test.js b/test/scripts/components/hyperlink.test.js
deleted file mode 100644
index 686edf5..0000000
--- a/test/scripts/components/hyperlink.test.js
+++ /dev/null
@@ -1,44 +0,0 @@
-'use strict';
-
-var _ = require('macaca-utils');
-var assert = require('chai').assert
-var wd = require('weex-wd')
-var path = require('path');
-var os = require('os');
-var util = require("../util.js");
-
-describe('weex a test', function () {
-  this.timeout(util.getTimeoutMills());
-  var driver = util.createDriver(wd);
-
-  beforeEach(function () {
-    return util.init(driver)
-      .get(util.getPage('/components/hyperlink.js'))
-      .waitForElementById("content-inside-a", util.getGETActionWaitTimeMills(), 2000)
-  });
-
-  afterEach(function () {
-    return util.quit(driver);
-  })
-
-  click_a_tag('#1 Click A tag itself', 'a-itself')
-  click_a_tag('#2 Click some content inside a', 'content-inside-a')
-
-  function click_a_tag(title, id) {
-    it(title, () => {
-      return driver
-        .elementById(id)
-        .click()
-        .sleep(2000)
-        .waitForElementById('just_text', util.getGETActionWaitTimeMills(), 2000)
-        .elementById('just_text')
-        .text()
-        .then(text => {
-          assert.equal(text, 'You just clicked A tag.')
-        })
-        .elementById('just_text')
-        .click()
-        .sleep(2000)
-    })
-  }
-});
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/712fa692/test/scripts/util.js
----------------------------------------------------------------------
diff --git a/test/scripts/util.js b/test/scripts/util.js
index b56f934..64e99a8 100644
--- a/test/scripts/util.js
+++ b/test/scripts/util.js
@@ -223,11 +223,19 @@ module.exports = {
                   .sleep(1000)
               })
           })
-            driver = driverFactory.initPromiseChain();
-            driver.configureHttp({
-                timeout: 100000
-            });
-            global._wxDriver = driver;
+          driverFactory.addPromiseChainMethod('saveShot', function(filepath){
+            return this.takeScreenshot()
+              .then(imgData => {
+                var newImg = new Buffer(imgData, 'base64');
+                fs.writeFileSync(filepath, newImg);
+                return this;
+              })
+          });
+          driver = driverFactory.initPromiseChain();
+          driver.configureHttp({
+              timeout: 100000
+          });
+          global._wxDriver = driver;
         }
         
         return driver;
@@ -243,6 +251,7 @@ module.exports = {
     quit:function(driver){
         if(browser)
             return driver.quit()
-        return driver.sleep(1000).back().sleep(1000);
+        var filepath = path.resolve(__dirname,'../../last.png');
+        return driver.saveShot(filepath).sleep(1000).back().sleep(1000);
     }
 }