You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by zs...@apache.org on 2017/04/21 06:18:57 UTC

[34/50] incubator-weex git commit: * [test] add Macaca test case for text The test case mainly focus on the layout of text.

* [test] add Macaca test case for text
The test case mainly focus on the layout of text.


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

Branch: refs/heads/0.13-dev
Commit: 47200259b356c88ddb8fe6925522fb66a5089139
Parents: 90c3583
Author: YorkShen <sh...@gmail.com>
Authored: Wed Apr 12 11:33:11 2017 +0800
Committer: YorkShen <sh...@gmail.com>
Committed: Tue Apr 18 19:48:52 2017 +0800

----------------------------------------------------------------------
 test/pages/components/text-layout.vue |  30 +++++++
 test/scripts/components/text.test.js  | 131 +++++++++++++++++++++++++++++
 2 files changed, 161 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/47200259/test/pages/components/text-layout.vue
----------------------------------------------------------------------
diff --git a/test/pages/components/text-layout.vue b/test/pages/components/text-layout.vue
new file mode 100644
index 0000000..e73e64c
--- /dev/null
+++ b/test/pages/components/text-layout.vue
@@ -0,0 +1,30 @@
+<template>
+  <scroller class="wrapper">
+    <text test-id ="text-only">Hello World</text>
+    <text test-id ="lines" style="lines:2;line-height:32px;font-size:36px;color:#0000FF">\u6c38\u548c\u4e5d\u5e74\uff0c\u5c81\u5728\u7678\u4e11\uff0c\u66ae\u6625\u4e4b\u521d\uff0c\u4f1a\u4e8e\u4f1a\u7a3d\u5c71\u9634\u4e4b\u5170\u4ead\u3002\n\t\u7fa4\u8d24\u6bd5\u81f3\uff0c\u5c11\u957f\u54b8\u96c6\u3002\u6b64\u5730\u6709\u5d07\u5c71\u5cfb\u9886\uff0c\u8302\u6797\u8129\u7af9\uff1b\u53c8\u6709\u6e05\u6d41\u6fc0\u6e4d\uff0c\u668e\u5e26\u5de6\u53f3\u3002\u5f15\u4ee5\u4e3a\u6d41\u89de\u66f2\u6c34\uff0c\u5217\u5750\u5176\u6b21\u3002\n\tLet us not seek to satisfy our thirst for freedom. \n\tAgain and again, we must rise to the majestic heights of meeting physical force with soul force.</text>
+    <text test-id ="font" style="lines:3;font-size:48px;color:#FF0000">\u5176\u5f62\u4e5f\uff0c\u7fe9\u82e5\u60ca\u9e3f\uff0c\u5a49\u82e5\u6e38\u9f99\uff0c\u8363\u66dc\u79cb\u83ca\uff0c\u534e\u8302\u6625\u677e\u3002\u9ae3\u9af4\u516e\u82e5\u8f7b\u4e91\u4e4b\u853d\u6708\uff0c\u98d8\u98d6\u516e\u82e5\u6d41\u98ce\u4e4b\u56de\u96ea\u3002\u8fdc\u800c\u671b\u4e4b\uff0c\u768e\u82e5\u592a\u9633\u5347\u671d\u971e\u3002\u8feb\u800c\u5bdf\u4e4b\uff0c\u707c\u82e5\u8299\u8556\u51fa\u6e0c\u6ce2\u3002\u79fe\u7ea4\u5f97\u8877\uff0c\u4fee\u77ed\u5408\u5ea6\u3002\u80a9\u82e5\u524a\u6210\uff0c\u8170\u5982\u7ea6\u7d20\u3002\u5ef6\u9888\u79c0\u9879\uff0c\u7693\u8d28\u5448\u9732\uff0c\u82b3\u6cfd\u65e0\u52a0\uff0c\u94c5\u534e\u5f17\u5fa1\u3002\u4e91\u9afb\u5ce8\u5ce8\uff0c\u4fee\u7709\u8054\u5a1f\uff0c\u4e39\u5507\u5916\u6717\uff0c\u7693\u9f7f\u5185\u9c9c\u3002\u660e\u7738\u5584\u7750\uff0c\u9765\u8f85\u627f\u6743\uff0c\u74cc\u59ff\u8273\u9038\uff0c\u4eea\u9759\u4f53\u95f2\u3002\u67d4\u60c5\u7ef0\u6001\uff0c\u5a9a\u4e8e\u8bed\u8a00\u3002\u5947\u670d\u65f7\u4e16\uff0c\u9aa8\u50cf\u5e94\u56fe\u3002\u62ab\u7f57\u8863\u4e4b\u7480\u7cb2\u516e\uff0c\u73e5\u7476\u78a7\u4e4b\u534e\u741a\u3002\u6234\u91d1\u7fe0\u4e4b\u9996\u9970\uff0c\u7f00\u660e\u73e0\u4ee5\u8000\u8eaf\u3002\u8df5\u8fdc\u6e38\u4e4b\u6587\u5c65\uff0c\u66f3\u96fe\u7ee1\u4e4b\u8f7b\u88fe\u3002\u5fae\u5e7d\u5170\u4e4b\u82b3\u853c\u516e\uff0c\u6b65\u8e1f\u8e70\u4e8e\u5c71\u9685\u3002\u4e8e\u662f\u5ffd\u7109\u7eb5\u4f53\uff0c\u4ee5\u9068\u4ee5\u5b09\u3002\u5de6\u501a\u91c7\u65c4\uff0c\u53f3\u836b\u6842\u65d7\u3002\u6518\u7693\u8155\u4e8e\u795e\u6d52\u516e\uff0c\u91c7\u6e4d\u6fd1\u4e4b\u7384\u829d\u3002</text>
+    <text test-id ="fixed-size" style="width:300px; height:100px;color:#FF00FF">\u58ec\u620c\u4e4b\u79cb\uff0c\u4e03\u6708\u65e2\u671b\uff0c\u82cf\u5b50\u4e0e\u5ba2\u6cdb\u821f\u6e38\u4e8e\u8d64\u58c1\u4e4b\u4e0b\u3002\u6e05\u98ce\u5f90\u6765\uff0c\u6c34\u6ce2\u4e0d\u5174\u3002\u4e3e\u9152\u5c5e\u5ba2\uff0c\u8bf5\u660e\u6708\u4e4b\u8bd7\uff0c\u6b4c\u7a88\u7a95\u4e4b\u7ae0\u3002\u5c11\u7109\uff0c\u6708\u51fa\u4e8e\u4e1c\u5c71\u4e4b\u4e0a\uff0c\u5f98\u5f8a\u4e8e\u6597\u725b\u4e4b\u95f4\u3002\u767d\u9732\u6a2a\u6c5f\uff0c\u6c34\u5149\u63a5\u5929\u3002\u7eb5\u4e00\u82c7\u4e4b\u6240\u5982\uff0c\u51cc\u4e07\u9877\u4e4b\u832b\u7136\u3002\u6d69\u6d69\u4e4e\u5982\u51af\u865a\u5fa1\u98ce\uff0c\u800c\u4e0d\u77e5\u5176\u6240\u6b62\uff1b\u98d8\u98d8\u4e4e\u5982\u9057\u4e16\u72ec\u7acb,\u7fbd\u5316\u800c\u767b\u4ed9\u3002</text>
+    <div style="flex-direction:row;width:500px;height:300px;background-color:red">
+      <text style="flex:1;line-height:36px;background-color:#AC34Ef" test-id="flexgrow-alignitems">Hello </text>
+    </div>
+
+    <div style="flex-direction:row;width:500px;height:300px;background-color:red;align-items:center">
+      <text style="flex:1;line-height:40px;background-color:#12CDEE" test-id="flexgrow">World</text>
+    </div>
+
+    <div style="width:500px;height:300px;background-color:red">
+      <text style="flex:1;line-height:36px;background-color:blue" test-id="flexgrow-alignitems-coloumn">Hello </text>
+    </div>
+
+    <div style="width:500px;height:300px;background-color:red;align-items:center">
+      <text style="flex:1;line-height:40px;background-color:blue" test-id="flexgrow-column">World</text>
+    </div>
+  </scroller>
+</template>
+
+<style>
+.wrapper{
+    width: 750px;
+    background-color: yellow;
+}
+</style>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/47200259/test/scripts/components/text.test.js
----------------------------------------------------------------------
diff --git a/test/scripts/components/text.test.js b/test/scripts/components/text.test.js
new file mode 100644
index 0000000..3c7c347
--- /dev/null
+++ b/test/scripts/components/text.test.js
@@ -0,0 +1,131 @@
+'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 text', function () {
+  this.timeout(util.getTimeoutMills());
+  var driver = util.createDriver(wd);
+
+  before(function () {
+    return util.init(driver)
+      .get(util.getPage('/components/text-layout.js'))
+      .waitForElementById("lines", util.getGETActionWaitTimeMills(),1000)
+  });
+
+  after(function () {
+      // return util.quit(driver);
+  })
+
+
+  let scaleFactor = 0 
+  let screenWidth = 0
+  it ('#1 Window size', () =>{
+    return driver
+    .getWindowSize()
+    .then(size=>{
+      screenWidth =  size.width
+      scaleFactor = screenWidth/ 750
+    })
+  })
+
+  it('#2 Text Content', () => {
+    return driver
+    .elementById('text-only')
+    .text()
+    .then((text)=>{
+      assert.equal(text,'Hello World')
+    })
+  })
+
+  it ('#3 Line Height', () =>{
+    return driver
+    .elementById('lines')
+    .getRect()
+    .then(rect => {
+       assert.equal(rect.width, screenWidth)
+       assert.equal(rect.height, Math.floor(2 * 32 * scaleFactor))
+       scroll(rect.height)
+    })
+  })
+
+   it ('#4 Font Size', () =>{
+    return driver
+    .elementById('font')
+    .getRect()
+    .then(rect => {
+       assert.equal(rect.width, screenWidth)
+       assert.isAtLeast(rect.height, Math.floor(2 * 48 * scaleFactor))
+       scroll(rect.height)
+    })
+  })
+
+   it ('#5 Fixed-Size', () =>{
+    return driver
+    .elementById('fixed-size')
+    .getRect()
+    .then(rect => {
+       assert.equal(rect.width, Math.floor(300 * scaleFactor))
+       assert.equal(rect.height, Math.floor(100 * scaleFactor))
+       scroll(rect.height)
+    })
+  })
+
+   it ('#6 flex:1; align-Items: stretch; flex-direction:row', () =>{
+    return driver
+    .elementById('flexgrow-alignitems')
+    .getRect()
+    .then(rect => {
+       assert.equal(rect.width, Math.floor(500 * scaleFactor))
+       assert.equal(rect.height, Math.floor(300 * scaleFactor))
+       scroll(rect.height)
+    })
+   })
+  
+   it ('#7 flex:1; align-Items: center; flex-direction:row', () =>{
+    return driver
+    .elementById('flexgrow')
+    .getRect()
+    .then(rect => {
+       assert.equal(rect.width, Math.floor(500 * scaleFactor))
+       assert.equal(rect.height, Math.floor(40 * scaleFactor))
+       scroll(rect.height)
+    })
+   })
+
+   it ('#8 flex:1; align-Items: stretch; flex-direction:column', () =>{
+    return driver
+    .elementById('flexgrow-alignitems-coloumn')
+    .getRect()
+    .then(rect => {
+       assert.equal(rect.width, Math.floor(500 * scaleFactor))
+       assert.equal(rect.height, Math.floor(300 * scaleFactor))
+       scroll(rect.height)
+    })
+   })
+  
+   it ('#9 flex:1; align-Items: auto; flex-direction:column', () =>{
+    return driver
+    .elementById('flexgrow-column')
+    .getRect()
+    .then(rect => {
+       assert.isBelow(rect.width, 500 * scaleFactor/2)
+       assert.equal(rect.height, Math.floor(300 * scaleFactor))
+       scroll(rect.height)
+    })
+   })
+
+   function scroll(height){
+      driver.touch('drag', {
+        fromX:100,
+        fromY:300+height,
+        toX:  100,
+        toY: 300,
+        duration: 0.5
+       })
+   }
+});