* [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.12-dev Commit: 47200259b356c88ddb8fe6925522fb66a5089139 Parents: 90c3583 Author: YorkShen <shenyua...@gmail.com> Authored: Wed Apr 12 11:33:11 2017 +0800 Committer: YorkShen <shenyua...@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">æ°¸åä¹å¹´ï¼å²å¨ç¸ä¸ï¼æ®æ¥ä¹åï¼ä¼äºä¼ç¨½å±±é´ä¹å °äºã\n\t群贤æ¯è³ï¼å°é¿å¸éãæ¤å°æå´å±±å³»é¢ï¼èæè©ç«¹ï¼åææ¸ æµæ¿æ¹ï¼æ带左å³ãå¼ä»¥ä¸ºæµè§æ²æ°´ï¼ååå ¶æ¬¡ã\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">å ¶å½¢ä¹ï¼ç¿©è¥æ鸿ï¼å©è¥æ¸¸é¾ï¼è£æç§èï¼åèæ¥æ¾ãé«£é«´å ®è¥è½»äºä¹è½æï¼é£é£å ®è¥æµé£ä¹åéªãè¿èæä¹ï¼çè¥å¤ªé³åæéãè¿«èå¯ä¹ï¼ç¼è¥èèåºæ¸æ³¢ã秾纤å¾è¡·ï¼ä¿®çå度ãè©è¥åæï¼è °å¦çº¦ç´ ã延é¢ç§é¡¹ï¼çè´¨åé²ï¼è³æ³½æ å ï¼é åå¼å¾¡ãäºé«»å³¨å³¨ï¼ä¿®çèå¨ï¼ä¸¹åå¤æï¼ç齿å é²ãæç¸åçï¼é¥è¾ æ¿æï¼ç姿è³é¸ï¼ä»ªéä½é²ãææ ç»°æï¼åªäºè¯è¨ãå¥ææ·ä¸ï¼éª¨ååºå¾ãæ«ç½è¡£ä¹çç²²å ®ï¼ç¥ç¶ç¢§ä¹åçãæ´éç¿ ä¹é¦é¥°ï¼ç¼æç 以è躯ãè·µè¿æ¸¸ä¹æå±¥ï¼æ³é¾ç»¡ä¹è½»è£¾ãå¾®å¹½å °ä¹è³è¼å ®ï¼æ¥è¸è¹°äºå±±é ãäºæ¯å¿½ç纵ä½ï¼ä»¥é¨ä»¥å¬ãå·¦åéæï¼å³è«æ¡æãæçè äºç¥æµå ®ï¼éæ¹æ¿ä¹çèã</text> + <text test-id ="fixed-size" style="width:300px; height:100px;color:#FF00FF">壬æä¹ç§ï¼ä¸ææ¢æï¼èåä¸å®¢æ³è游äºèµ¤å£ä¹ä¸ãæ¸ é£å¾æ¥ï¼æ°´æ³¢ä¸å ´ã举é å±å®¢ï¼è¯µææä¹è¯ï¼æçªçªä¹ç« ãå°çï¼æåºäºä¸å±±ä¹ä¸ï¼å¾å¾äºæçä¹é´ãç½é²æ¨ªæ±ï¼æ°´å æ¥å¤©ã纵ä¸èä¹æå¦ï¼åä¸é¡·ä¹è«ç¶ã浩浩ä¹å¦å¯è御é£ï¼èä¸ç¥å ¶ææ¢ï¼é£é£ä¹å¦éä¸ç¬ç«,ç¾½åèç»ä»ã</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 + }) + } +});