WXNavigatorModule extends WXModule { @WXModuleAnno public void push(String param, final String callbackId) { if (!TextUtils.isEmpty(param)) { if (WXSDKEngine.getActivityNavBarSetter() != null) { if (WXSDKEngine.getActivityNavBarSetter().push(param)) { WXBridgeManager.getInstance().callback(mWXSDKInstance.getInstanceId(), callbackId, MSG_SUCCESS); return; } } try { JSONObject jsonObject = new JSONObject(param); String url = jsonObject.optString(URL, ""); if (!TextUtils.isEmpty(url)) { Uri rawUri = Uri.parse(url); String scheme = rawUri.getScheme(); Uri.Builder builder = rawUri.buildUpon(); if (TextUtils.isEmpty(scheme)) { builder.scheme("http"); } Intent intent = new Intent(Intent.ACTION_VIEW, builder.build()); intent.addCategory(WEEX); intent.putExtra(INSTANCE_ID, mWXSDKInstance.getInstanceId()); mWXSDKInstance.getContext().startActivity(intent); WXBridgeManager.getInstance().callback(mWXSDKInstance.getInstanceId(), callbackId, MSG_SUCCESS); } } catch (Exception e) { WXLogUtils.eTag(TAG, e); WXBridgeManager.getInstance().callback(mWXSDKInstance.getInstanceId(), callbackId, MSG_FAILED); } } WXBridgeManager.getInstance().callback(mWXSDKInstance.getInstanceId(), callbackId, MSG_FAILED); }  @WXModuleAnno void push(String param, final String callbackId); @WXModuleAnno void pop(String param, final String callbackId); @WXModuleAnno void setNavBarRightItem(String param, final String callbackId); @WXModuleAnno void clearNavBarRightItem(String param, final String callbackId); @WXModuleAnno void setNavBarLeftItem(String param, final String callbackId); @WXModuleAnno void clearNavBarLeftItem(String param, final String callbackId); @WXModuleAnno void setNavBarMoreItem(String param, final String callbackId); @WXModuleAnno void clearNavBarMoreItem(String param, final String callbackId); @WXModuleAnno void setNavBarTitle(String param, final String callbackId); static final String MSG_SUCCESS; static final String MSG_FAILED; }
@Test public void testPush() throws Exception { module.push("{}",""); module.push("{'url':'kdkdkdkdkd'}",""); mockSetter(); module.push("{}",""); }