Repository: incubator-weex Updated Branches: refs/heads/0.16-dev 5e245cc0f -> 42da9ddf7
* [test] add viewport tc Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/b344e473 Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/b344e473 Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/b344e473 Branch: refs/heads/0.16-dev Commit: b344e473352d0bb720741fe22eec33754092038b Parents: 2746853 Author: gurisxie <279483...@qq.com> Authored: Fri Sep 1 11:09:36 2017 +0800 Committer: gurisxie <279483...@qq.com> Committed: Fri Sep 1 11:09:36 2017 +0800 ---------------------------------------------------------------------- test/pages/modules/viewport-basic.vue | 62 ++++++++++++++++++++++++ test/scripts/modules/viewport-basic.test.js | 45 +++++++++++++++++ 2 files changed, 107 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/b344e473/test/pages/modules/viewport-basic.vue ---------------------------------------------------------------------- diff --git a/test/pages/modules/viewport-basic.vue b/test/pages/modules/viewport-basic.vue new file mode 100644 index 0000000..a8743eb --- /dev/null +++ b/test/pages/modules/viewport-basic.vue @@ -0,0 +1,62 @@ +<template> + <div> + <panel title = 'viewport-basic' :padding-body='0'> + <panel title='screenWidthï¼'> + <text test-id='device-width' style="font-size:30px">{{_deviceWidth}}</text> + </panel> + <panel title='screenHeightï¼'> + <text test-id='device-height' style="font-size:30px">{{_deviceHeight}}</text> + </panel> + <div test-id='test-point' style='width:320;height:160;background-color:red;'> + <text>宽度æµè¯</text> + </div> + </panel> + <wxc-desc> + <text class='desc'> +æµè¯ç¹ï¼ + * + +æµè¯æ¹å¼ï¼ + * + * + * + </text> + </wxc-desc> + </div> +</template> +<script> + const meta = weex.requireModule('meta') + // é ç½® viewport ç宽度为 640px + meta.setViewport({ + width: 640 + }) + + module.exports = { + data : { + _deviceWidth:'', + _deviceHeight:'' + }, + components: { + "wxc-desc":require('../include/wxc-desc.vue'), + panel: require('../include/panel.vue'), + button: require('../include/button.vue'), + }, + methods : { + }, + created:function(){ + this._deviceWidth = weex.config.env.deviceWidth; + this._deviceHeight = weex.config.env.deviceHeight; + } + } +</script> + +<style scoped> + .origin{background-color: #FFFFDF;width: 200;height: 50;} + .mr-base{ + margin: 10px; + } + .desc{ + color:#aa0000; + font-size: 30px; + } +</style> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/b344e473/test/scripts/modules/viewport-basic.test.js ---------------------------------------------------------------------- diff --git a/test/scripts/modules/viewport-basic.test.js b/test/scripts/modules/viewport-basic.test.js new file mode 100644 index 0000000..a8b8a18 --- /dev/null +++ b/test/scripts/modules/viewport-basic.test.js @@ -0,0 +1,45 @@ +'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"); + + +var goal = 'viewport-basic'; +var timeout = util.getGETActionWaitTimeMills(); +describe('weex '+goal+' test', function () { + this.timeout(util.getTimeoutMills()); + var driver = util.createDriver(wd); + + let scaleFactor = 0 + let screenWidth = 0 + + beforeEach(function () { + return util.init(driver) + .get(util.getPage('/modules/'+goal+'.js')) + .sleep(2000) + .getWindowSize() + .then(size => { + screenWidth = size.width + scaleFactor = screenWidth / 750 + }) + }); + + afterEach(function () { + return util.quit(driver); + }) + + it('#1 '+goal + ' test', () => { + return driver + .waitForElementByName(goal, timeout, 2000) + .waitForElementById('test-point', timeout, 2000) + .getRect().then((rect)=>{ + var width = rect.width; + console.log('width:'+width+', screenWidth:'+screenWidth) + assert.closeTo(width, screenWidth/2, 2); + }); + }) +}) \ No newline at end of file