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/03/07 02:17:45 UTC
[2/6] incubator-weex git commit: * [test] add testcase for fixed item
in scroller
* [test] add testcase for fixed item in scroller
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/cc6f1168
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/cc6f1168
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/cc6f1168
Branch: refs/heads/0.11-dev
Commit: cc6f11688709cc9db19541151bb1625b475b6f42
Parents: edbdcec
Author: sospartan <so...@gmail.com>
Authored: Fri Mar 3 18:15:02 2017 +0800
Committer: sospartan <so...@gmail.com>
Committed: Fri Mar 3 18:15:02 2017 +0800
----------------------------------------------------------------------
test/pages/components/scroller-fixed.we | 62 +++++++++++++++++++++
test/scripts/components/scroller-fixed.test.js | 39 +++++++++++++
2 files changed, 101 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/cc6f1168/test/pages/components/scroller-fixed.we
----------------------------------------------------------------------
diff --git a/test/pages/components/scroller-fixed.we b/test/pages/components/scroller-fixed.we
new file mode 100644
index 0000000..9c2d50d
--- /dev/null
+++ b/test/pages/components/scroller-fixed.we
@@ -0,0 +1,62 @@
+<template>
+ <scroller id="container" class="container" onscroll="onscroll">
+ <div><text>{{vp}}|{{p1}}|{{p2}}</text></div>
+ <div repeat="{{items}}" style="background-color:yellow;height:500"><text>row</text></div>
+ <div id="panel" class="fixed-panel"></div>
+ <div id="panel2" class="fixed-panel2"></div>
+ </scroller>
+</template>
+<style>
+ .container {
+ width: 750;
+ }
+ .fixed-panel {
+ position: fixed;
+ bottom: 0;
+ left: 0;
+ height: 200;
+ background-color: #ff0000;
+ width: 200;
+ }
+ .fixed-panel2 {
+ position: fixed;
+ right: 0;
+ top: 0;
+ height: 200;
+ background-color: #ff0000;
+ width: 200;
+ }
+</style>
+<script>
+ var dom = require("@weex-module/dom")
+ module.exports = {
+ data:{
+ items:[1,1,1,1,1,1,1,1],
+ height:100,
+ vp:-1,
+ p1:-1,
+ p2:-1
+ },
+ ready:function(){
+ var self = this;
+ dom.getComponentRect(this.$el('container'),function(data){
+ self.vp = data.size.height;
+ })
+ },
+ methods:{
+ onscroll:function(e){
+ var self = this;
+ dom.getComponentRect(this.$el('container'),function(data){
+ self.vp = Math.round(data.size.height);
+ });
+ dom.getComponentRect(this.$el('panel'),function(data){
+ self.p1 = Math.round(data.size.top+data.size.height);
+ });
+ dom.getComponentRect(this.$el('panel2'),function(data){
+ self.p2 = data.size.top;
+ });
+ //should vp != 0 && p1 == vp && p2 ==0
+ }
+ }
+ }
+</script>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/cc6f1168/test/scripts/components/scroller-fixed.test.js
----------------------------------------------------------------------
diff --git a/test/scripts/components/scroller-fixed.test.js b/test/scripts/components/scroller-fixed.test.js
new file mode 100644
index 0000000..0766f27
--- /dev/null
+++ b/test/scripts/components/scroller-fixed.test.js
@@ -0,0 +1,39 @@
+'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('scroller fixed position item ', function () {
+ this.timeout(util.getTimeoutMills());
+ var driver = util.createDriver(wd);
+
+ before(function () {
+ return util.init(driver)
+ .get('wxpage://' + util.getDeviceHost() +'/components/scroller-fixed.js')
+ .waitForElementByXPath('//scroller[1]/div[1]',util.getGETActionWaitTimeMills(),1000)
+ });
+
+ after(function () {
+ return util.quit(driver)
+ })
+
+
+ it('#1 position:fixed items', () => {
+ return driver
+ .touch('drag', {fromX:200, fromY:500, toX:200, toY: 400})
+ .sleep(2000)
+ .touch('drag', {fromX:200, fromY:400, toX:200, toY: 500})
+ .sleep(2000)
+ .elementByXPath('//scroller[1]/div[1]/text[1]')
+ .text()
+ .then((text)=>{
+ var parts = text.split("|");
+ assert.equal(parts[0],parts[1]);
+ assert.equal(parts[2],0);
+ })
+ })
+});
\ No newline at end of file