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 02:41:28 UTC

[1/4] incubator-weex git commit: * [ios] add fireEvent js method

Repository: incubator-weex
Updated Branches:
  refs/heads/0.13-dev 320230466 -> 834191e0d


* [ios] add fireEvent js method


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/e7e93c09
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/e7e93c09
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/e7e93c09

Branch: refs/heads/0.13-dev
Commit: e7e93c09632a13ef0abdb106e82c404343a6e59b
Parents: 507cd7c
Author: acton393 <zh...@gmail.com>
Authored: Wed Apr 26 19:03:46 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Wed Apr 26 19:03:46 2017 +0800

----------------------------------------------------------------------
 .../alibaba/weex/extend/module/WXEventModule.java | 18 ++++++++++++++++++
 .../WeexDemo/extend/module/WXEventModule.m        | 16 ++++++++++++++++
 2 files changed, 34 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/e7e93c09/android/playground/app/src/main/java/com/alibaba/weex/extend/module/WXEventModule.java
----------------------------------------------------------------------
diff --git a/android/playground/app/src/main/java/com/alibaba/weex/extend/module/WXEventModule.java b/android/playground/app/src/main/java/com/alibaba/weex/extend/module/WXEventModule.java
index 098681d..06c5326 100644
--- a/android/playground/app/src/main/java/com/alibaba/weex/extend/module/WXEventModule.java
+++ b/android/playground/app/src/main/java/com/alibaba/weex/extend/module/WXEventModule.java
@@ -23,9 +23,11 @@ import android.net.Uri;
 import android.text.TextUtils;
 
 import com.taobao.weex.annotation.JSMethod;
+import com.taobao.weex.bridge.JSCallback;
 import com.taobao.weex.common.WXModule;
 
 import java.util.HashMap;
+import java.util.Map;
 
 
 public class WXEventModule extends WXModule {
@@ -61,4 +63,20 @@ public class WXEventModule extends WXModule {
       mWXSDKInstance.fireModuleEvent("event", this, params);
     }
   }
+  /*
+   * a test method for macaca case, you can fire globalEvent when download finish、device shaked and so on.
+   * @param event event name
+  * */
+  @JSMethod(uiThread = true)
+  public void fireNativeGlobalEvent(String event, JSCallback callback) {
+    Map<String,Object> params=new HashMap<String,Object>();
+    params.put("eventParam","value");
+
+    mWXSDKInstance.fireGlobalEventCallback(event, params);
+    if (null != callback) {
+      Map<String, Boolean> result = new HashMap<String, Boolean>();
+      result.put("ok",true);
+      callback.invoke(result);
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/e7e93c09/ios/playground/WeexDemo/extend/module/WXEventModule.m
----------------------------------------------------------------------
diff --git a/ios/playground/WeexDemo/extend/module/WXEventModule.m b/ios/playground/WeexDemo/extend/module/WXEventModule.m
index b3b1cfb..9f58090 100644
--- a/ios/playground/WeexDemo/extend/module/WXEventModule.m
+++ b/ios/playground/WeexDemo/extend/module/WXEventModule.m
@@ -27,6 +27,8 @@
 
 WX_EXPORT_METHOD(@selector(openURL:))
 
+WX_EXPORT_METHOD(@selector(fireNativeGlobalEvent:callback:))
+
 - (void)openURL:(NSString *)url
 {
     NSString *newURL = url;
@@ -43,5 +45,19 @@ WX_EXPORT_METHOD(@selector(openURL:))
     [[weexInstance.viewController navigationController] pushViewController:controller animated:YES];
 }
 
+
+/**
+ a test method for macaca case, you can fire globalEvent when download finish、device shaked and so on.
+ @param event event name
+ */
+- (void)fireNativeGlobalEvent:(NSString *)event callback:(WXModuleCallback)callback
+{
+    [weexInstance fireGlobalEvent:event params:@{@"eventParam":@"eventValue"}];
+    if (callback) {
+        NSDictionary * result = @{@"ok": @true};
+        callback(result);
+    }
+}
+
 @end
 


[3/4] incubator-weex git commit: Merge branch 'globalEvent-macaca-case' of github.com:acton393/incubator-weex into 0.13-dev

Posted by ac...@apache.org.
Merge branch 'globalEvent-macaca-case' of github.com:acton393/incubator-weex into 0.13-dev


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/b2672dc4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/b2672dc4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/b2672dc4

Branch: refs/heads/0.13-dev
Commit: b2672dc493429c585a01bc12942e1ae8aef2fa69
Parents: 6566fc2 391ce4c
Author: sospartan <so...@apache.org>
Authored: Tue May 16 14:59:18 2017 +0800
Committer: sospartan <so...@apache.org>
Committed: Tue May 16 14:59:18 2017 +0800

----------------------------------------------------------------------
 .../weex/extend/module/WXEventModule.java       | 18 ++++++
 .../WeexDemo/extend/module/WXEventModule.m      | 16 ++++++
 test/pages/modules/globalEvent.vue              | 48 ++++++++++++++++
 test/scripts/modules/globalEvent.test.js        | 60 ++++++++++++++++++++
 4 files changed, 142 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/b2672dc4/android/playground/app/src/main/java/com/alibaba/weex/extend/module/WXEventModule.java
----------------------------------------------------------------------
diff --cc android/playground/app/src/main/java/com/alibaba/weex/extend/module/WXEventModule.java
index 10a51cd,06c5326..e417f0f
--- a/android/playground/app/src/main/java/com/alibaba/weex/extend/module/WXEventModule.java
+++ b/android/playground/app/src/main/java/com/alibaba/weex/extend/module/WXEventModule.java
@@@ -22,8 -22,8 +22,9 @@@ import android.content.Intent
  import android.net.Uri;
  import android.text.TextUtils;
  
 +import com.alibaba.weex.WXPageActivity;
  import com.taobao.weex.annotation.JSMethod;
+ import com.taobao.weex.bridge.JSCallback;
  import com.taobao.weex.common.WXModule;
  
  import java.util.HashMap;


[4/4] incubator-weex git commit: Merge branch '0.13-dev' of https://git-wip-us.apache.org/repos/asf/incubator-weex into apache-0.13-dev

Posted by ac...@apache.org.
Merge branch '0.13-dev' of https://git-wip-us.apache.org/repos/asf/incubator-weex into apache-0.13-dev


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/834191e0
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/834191e0
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/834191e0

Branch: refs/heads/0.13-dev
Commit: 834191e0de49a627da0235b3b5d3eee74edb5f6b
Parents: 3202304 b2672dc
Author: acton393 <zh...@gmail.com>
Authored: Wed May 17 10:40:04 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Wed May 17 10:40:04 2017 +0800

----------------------------------------------------------------------
 .../weex/extend/module/WXEventModule.java       | 18 ++++++
 .../WeexDemo/extend/module/WXEventModule.m      | 16 ++++++
 test/pages/modules/globalEvent.vue              | 48 ++++++++++++++++
 test/scripts/modules/globalEvent.test.js        | 60 ++++++++++++++++++++
 4 files changed, 142 insertions(+)
----------------------------------------------------------------------



[2/4] incubator-weex git commit: * [ios] add macaca case and js

Posted by ac...@apache.org.
* [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")
+    })
+  })
+});