* [test] add navigator 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/42da9ddf
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/42da9ddf
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/42da9ddf

Branch: refs/heads/0.16-dev
Commit: 42da9ddf770a7d9602ce867157d8d7b0b1596d06
Parents: 66a0fc8
Author: gurisxie <279483...@qq.com>
Authored: Fri Sep 1 18:11:42 2017 +0800
Committer: gurisxie <279483...@qq.com>
Committed: Fri Sep 1 18:11:42 2017 +0800

----------------------------------------------------------------------
 test/pages/include/navbar.vue                | 121 ++++++++++++++++++++++
 test/pages/include/navpage.vue               |  62 +++++++++++
 test/pages/modules/navigator-event.vue       | 101 ++++++++++++++++++
 test/scripts/modules/navigator-event.test.js |  51 +++++++++
 test/scripts/util.js                         |   6 ++
 5 files changed, 341 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/42da9ddf/test/pages/include/navbar.vue
----------------------------------------------------------------------
diff --git a/test/pages/include/navbar.vue b/test/pages/include/navbar.vue
new file mode 100644
index 0000000..69bbe0b
--- /dev/null
+++ b/test/pages/include/navbar.vue
@@ -0,0 +1,121 @@
+<template>
+  <div
+    :dataRole="dataRole"
+    class="container"
+    :style="{ height: height, backgroundColor: backgroundColor }">
+    <text
+      v-if="!rightItemSrc"
+      naviItemPosition="right"
+      :style="{ color: rightItemColor }"
+      class="right-text"
+      v-on:click="onclickrightitem">{{rightItemTitle}}</text>
+    <image
+      v-if="rightItemSrc"
+      naviItemPosition="right"
+      :src="rightItemSrc"
+      class="right-image"
+      v-on:click="onclickrightitem"></image>
+    <text
+      v-if="!leftItemSrc"
+      naviItemPosition="left"
+      :style="{ color: leftItemColor }"
+      class="left-text"
+      v-on:click="onclickleftitem">{{leftItemTitle}}</text>
+    <image
+      v-if="leftItemSrc"
+      naviItemPosition="left"
+      :src="leftItemSrc"
+      class="left-image"
+      v-on:click="onclickleftitem"></image>
+    <text
+      naviItemPosition="center"
+      :style="{ color: titleColor }"
+      class="center-text">{{title}}</text>
+  </div>
+</template>
+
+<style scoped>
+  .container {
+    flex-direction: row; 
+    position: fixed; 
+    top: 0; 
+    left: 0; 
+    right: 0; 
+    width: 750;
+  }
+  .right-text {
+    position: absolute; 
+    bottom: 28; 
+    right: 32; 
+    text-align: right;
+    font-size: 32; 
+    font-family: 'Open Sans', sans-serif;
+  }
+  .left-text {
+    position: absolute; 
+    bottom: 28; 
+    left :32; 
+    text-align :left;  
+    font-size: 32; 
+    font-family: 'Open Sans', sans-serif;
+  }
+  .center-text {
+    position: absolute; 
+    bottom: 25; 
+    left: 172; 
+    right: 172;
+    text-align: center; 
+    font-size: 36; 
+    font-weight: bold;
+  }
+  .left-image {
+    position: absolute; 
+    bottom: 20; 
+    left: 28; 
+    width: 50; 
+    height: 50;
+  }
+  .right-image {
+    position: absolute; 
+    bottom: 20; 
+    right: 28; 
+    width: 50; 
+    height: 50;
+  }
+</style>
+
+<script>
+  module.exports = {
+    props: {
+      dataRole: { default: 'navbar' },
+      //导航条背景色
+      backgroundColor: { default: 'black' },
+      //导航条高度
+      height: { default: 88 },
+      //导航条标题 
+      title: { default: '' },
+      //导航条标题颜色
+      titleColor: { default: 'black' },
+      //右侧按钮图片
+      rightItemSrc: { default: '' },
+      //右侧按钮标题
+      rightItemTitle: { default: '' },
+      //右侧按钮标题颜色
+      rightItemColor: { default: 'black' },
+      //左侧按钮图片
+      leftItemSrc: { default: '' },
+      //左侧按钮标题
+      leftItemTitle: { default: '' },
+      //左侧按钮颜色
+      leftItemColor: { default: 'black' }
+    },
+    methods: {
+      onclickrightitem: function (e) {
+        this.$emit('naviBarRightItemClick');
+      },
+      onclickleftitem: function (e) {
+        this.$emit('naviBarLeftItemClick');
+      }
+    }
+  }
+</script>

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/42da9ddf/test/pages/include/navpage.vue
----------------------------------------------------------------------
diff --git a/test/pages/include/navpage.vue b/test/pages/include/navpage.vue
new file mode 100644
index 0000000..c9ea887
--- /dev/null
+++ b/test/pages/include/navpage.vue
@@ -0,0 +1,62 @@
+<template>
+  <div class="wrapper">
+    <navbar
+      :dataRole="dataRole"
+      :height="height"
+      :backgroundColor="backgroundColor"
+      :title="title"
+      :titleColor="titleColor"
+      :leftItemSrc="leftItemSrc"
+      :leftItemTitle="leftItemTitle"
+      :leftItemColor="leftItemColor"
+      :rightItemSrc="rightItemSrc"
+      :rightItemTitle="rightItemTitle"
+      :rightItemColor="rightItemColor"
+      @naviBarRightItemClick="naviBarRightItemClick"
+      @naviBarLeftItemClick="naviBarLeftItemClick"
+      ></navbar>
+    <div class="wrapper" :style="{ marginTop: height }">
+      <slot></slot>
+    </div>
+  </div>
+</template>
+
+<style scoped>
+  .wrapper {
+    position: absolute; 
+    top: 0; 
+    left: 0; 
+    right: 0; 
+    bottom: 0; 
+    width: 750;
+  }
+</style>
+
+<script>
+  module.exports = {
+    components: {
+      navbar: require('./navbar.vue')
+    },
+    props: {
+      dataRole: { default: 'navbar' },
+      backgroundColor: { default: 'black' },
+      height: { default: 88 },
+      title: { default: "" },
+      titleColor: { default: 'black' },
+      rightItemSrc: { default: '' },
+      rightItemTitle: { default: '' },
+      rightItemColor: { default: 'black' },
+      leftItemSrc: { default: '' },
+      leftItemTitle: { default: '' },
+      leftItemColor: { default: 'black' }
+    },
+    methods: {
+      naviBarRightItemClick: function (e) {
+        this.$emit('naviBarRightItemClick', e)
+      },
+      naviBarLeftItemClick: function (e) {
+        this.$emit('naviBarLeftItemClick', e)
+      }
+    }
+  }
+</script>

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/42da9ddf/test/pages/modules/navigator-event.vue
----------------------------------------------------------------------
diff --git a/test/pages/modules/navigator-event.vue 
b/test/pages/modules/navigator-event.vue
new file mode 100644
index 0000000..acda158
--- /dev/null
+++ b/test/pages/modules/navigator-event.vue
@@ -0,0 +1,101 @@
+<template>
+  <navpage
+    dataRole="none"
+    :height="navBarHeight"
+    :title="title"
+    backgroundColor="#ff5898"
+    titleColor="white"
+    leftItemTitle="Left"
+    leftItemColor="white"
+    rightItemTitle="Right"
+    @naviBarLeftItemClick="naviBarLeftItemClick"
+    @naviBarRightItemClick="naviBarRightItemClick">
+    <panel title="navigator-event">
+      <div style='flex-direction:row;margin:10px;'>
+        <button type="primary" v-if='!isPop' size="small" value="push" 
@click.native="push"></button>
+        <button type="primary" v-if='isPop' size="small" value="pop" 
@click.native="pop"></button>
+        <button type="primary" v-if='isPop' size="small" value="open" 
@click.native="open"></button>
+        <button type="primary" v-if='isPop' size="small" value="close" 
@click.native="close"></button>
+      </div>
+      <panel title='校验结果:'>
+        <text style="font-size:30px">{{textResult}}</text>
+      </panel>
+    </panel>
+    
+    <wxc-desc>
+      <text class='desc'>
+  测试点:
+  * 
+  * 
+  * 
+
+  测试方式:
+  * 
+  * 
+      </text>
+    </wxc-desc>
+  </navpage>
+</template>
+
+<script>
+  var navigator = weex.requireModule('navigator')
+  module.exports = {
+    data: function () {
+      return {
+        navBarHeight: 88,
+        title: 'Navigator',
+        dir: 'examples',
+        baseURL: '',
+        subPath: weex.config.env.platform === 'Web' ? 'vue-web/' : '',
+        textResult:'',
+        isPop: false
+      }
+    },
+    components: {
+      panel: require('../include/panel.vue'),
+      navpage: require('../include/navpage.vue'),
+      button: require('../include/button.vue'),
+      "wxc-desc":require('../include/wxc-desc.vue'),
+    },
+    created: function() {
+      this.isPop = weex.config.bundleUrl.includes('type=pop')
+      this.textResult = weex.config.bundleUrl;
+    },
+    methods: {
+      naviBarLeftItemClick: function (e) {
+        this.textResult='naviBarLeftItemClick';
+      },
+      naviBarRightItemClick: function (e) {
+        this.textResult='naviBarRightItemClick';
+      },
+      push: function () {
+        var params = {
+          'url':  weex.config.bundleUrl + '?type=pop',
+          'animated' : 'true',
+        }
+        navigator.push(params, function () {});
+      },
+      pop: function () {
+        var params = {
+          'url':  weex.config.bundleUrl.replace('?type=pop',''),
+          'animated' : 'true',
+        }
+        navigator.pop(params, function () {});
+      },
+      open: function () {
+        var params = {
+          'url':  weex.config.bundleUrl.replace('?type=pop',''),
+          'animated' : 'true',
+        }
+        navigator.open(params, function () {},function () {});
+      },
+      close: function () {
+        var params = {
+          'animated' : 'true',
+        }
+        navigator.close(params, function () {},function () {});
+      },
+
+    }
+  }
+</script>

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/42da9ddf/test/scripts/modules/navigator-event.test.js
----------------------------------------------------------------------
diff --git a/test/scripts/modules/navigator-event.test.js 
b/test/scripts/modules/navigator-event.test.js
new file mode 100644
index 0000000..1d04203
--- /dev/null
+++ b/test/scripts/modules/navigator-event.test.js
@@ -0,0 +1,51 @@
+'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 = 'navigator-event';
+var timeout = util.getGETActionWaitTimeMills();
+describe('weex '+goal+' test', function () {
+  this.timeout(util.getTimeoutMills());
+  var driver = util.createDriver(wd);
+
+  beforeEach(function () {
+    return util.init(driver)
+      .get(util.getPage('/modules/'+goal+'.js'))
+  });
+
+  afterEach(function () {
+    return util.quitWithoutBack(driver);
+  })
+
+  it('#1 '+goal + ' event', () => {
+    return driver
+    .waitForElementByName(goal, timeout, 2000)
+    .waitForElementByName('Navigator')
+    .waitForElementByName('push')
+    .click()
+    .waitForElementByName('pop')
+    .click()
+    .waitForElementByName('push')
+    .click()
+    //open,close方法未实现
+    // .waitForElementByName('open')
+    // .click()
+    // .waitForElementByName('push')
+    // .click()
+    // .waitForElementByName('close')
+    // .click()
+    // .waitForElementByName('push')
+    .waitForElementByName('Left')
+    .click()
+    .waitForElementByName('naviBarLeftItemClick')
+    .waitForElementByName('Right')
+    .click()
+    .waitForElementByName('naviBarRightItemClick');
+  })
+});

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/42da9ddf/test/scripts/util.js
----------------------------------------------------------------------
diff --git a/test/scripts/util.js b/test/scripts/util.js
index 4637069..197858f 100644
--- a/test/scripts/util.js
+++ b/test/scripts/util.js
@@ -284,5 +284,11 @@ module.exports = {
             return driver.quit()
         var filepath = path.resolve(__dirname,'../../last.png');
         return driver.saveShot(filepath).sleep(1000).back().sleep(1000);
+    },
+    quitWithoutBack:function(driver){
+        if(browser)
+            return driver.quit()
+        var filepath = path.resolve(__dirname,'../../last.png');
+        return driver.saveShot(filepath).sleep(1000);
     }
 }

Reply via email to