You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2017/05/17 09:40:22 UTC
[2/7] incubator-weex git commit: * [ios] add macaca case and js
* [ios] add macaca case and js
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/391ce4c2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/391ce4c2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/391ce4c2
Branch: refs/heads/0.13-dev
Commit: 391ce4c275387ee934948640c60058a759f9dc30
Parents: e7e93c0
Author: acton393 <zh...@gmail.com>
Authored: Wed Apr 26 19:07:58 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Wed Apr 26 19:07:58 2017 +0800
----------------------------------------------------------------------
test/pages/modules/globalEvent.vue | 48 +++++++++++++++++++++
test/scripts/modules/globalEvent.test.js | 60 +++++++++++++++++++++++++++
2 files changed, 108 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/391ce4c2/test/pages/modules/globalEvent.vue
----------------------------------------------------------------------
diff --git a/test/pages/modules/globalEvent.vue b/test/pages/modules/globalEvent.vue
new file mode 100644
index 0000000..bb5d631
--- /dev/null
+++ b/test/pages/modules/globalEvent.vue
@@ -0,0 +1,48 @@
+<template>
+ <div style="flex-direction:row">
+ <text test-id="content" class='btn' v-if="show">{{content}}</text>
+ <text test-id="button" class="btn" @click="handleOnclick">{{btnTitle}}</text>
+ </div>
+</template>
+
+<script>
+ module.exports = {
+ data() {
+ return {
+ content:"I received event",
+ show:false,
+ btnTitle:"click me to fire globalEvent"
+ }
+ },
+ mounted(){
+ var self = this;
+ weex.requireModule("globalEvent").addEventListener("showText", function(e){
+ console.log("Hello")
+ self.show = true;
+ });
+ },
+ methods:{
+ handleOnclick:function(e) {
+ var self = this;
+ weex.requireModule("event").fireNativeGlobalEvent("showText",function(e){
+ if(Boolean(e.ok)) {
+ self.btnTitle = "posted"
+ }
+ })
+
+ }
+ }
+ }
+</script>
+
+<style>
+.btn {
+ margin-top:100;
+ margin-left:100;
+ border-width:3;
+ height:50;
+ border-color:red;
+ border-radius:10;
+ background-color:rgba(23,145,245,1)
+}
+</style>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/391ce4c2/test/scripts/modules/globalEvent.test.js
----------------------------------------------------------------------
diff --git a/test/scripts/modules/globalEvent.test.js b/test/scripts/modules/globalEvent.test.js
new file mode 100644
index 0000000..2934fa7
--- /dev/null
+++ b/test/scripts/modules/globalEvent.test.js
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+'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 mobile index', function () {
+ this.timeout(util.getTimeoutMills());
+ var driver = util.createDriver(wd);
+ before(function () {
+ return util.init(driver)
+ .get(util.getPage('/modules/globalEvent.js'))
+ .waitForElementById('button',util.getGETActionWaitTimeMills(),1000)
+ });
+
+ after(function () {
+ return util.quit(driver)
+ })
+
+ it('#0 fireEvent',()=>{
+ return driver
+ .elementById("button")
+ .click()
+ .sleep(2000)
+ .text()
+ .then((elem)=>{
+ assert.equal(elem, "posted")
+ })
+ })
+
+ it('#1 received event', ()=>{
+ return driver
+ .elementById("content")
+ .text()
+ .then((elem)=>{
+ assert.equal(elem, "I received event")
+ })
+ })
+});