src_fm_fc_ms_ff
stringlengths 43
86.8k
| target
stringlengths 20
276k
|
---|---|
JsonArray extends Type<JSONArray> { public boolean cancel() { if (mTask != null) { mTask.cancel(true); if (mTask.isCancelled()) { mListener.onCancel(); return true; } else { return false; } } return false; } JsonArray(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); JsonArray setCallback(HttpListener<JSONArray> listener); boolean cancel(); JsonArray setCacheManager(CacheManagerInterface<JSONArray> cache); } | @Test public void cancel() throws Exception { } |
JsonArray extends Type<JSONArray> { public JsonArray setCacheManager(CacheManagerInterface<JSONArray> cache) { this.mCacheManager = cache; return this; } JsonArray(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); JsonArray setCallback(HttpListener<JSONArray> listener); boolean cancel(); JsonArray setCacheManager(CacheManagerInterface<JSONArray> cache); } | @Test public void setCacheManager() throws Exception { } |
BitMap extends Type<Bitmap> { public BitMap setCallback(HttpListener<Bitmap> listener) { this.listener = listener; this.listener.onRequest(); Bitmap data; if (mCacheManager != null) { data = mCacheManager.getDataFromCache(url); if (data != null) { this.listener.onResponse(data); return this; } } mTask = new BitMapTask(method, url, params, headers, this.listener); mTask.setmCachemanager(mCacheManager); mTask.execute(); return this; } BitMap(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); BitMap setCallback(HttpListener<Bitmap> listener); boolean cancel(); BitMap setCacheManager(CacheManagerInterface<Bitmap> cache); } | @Test public void setCallback() throws Exception { } |
BitMap extends Type<Bitmap> { public boolean cancel() { if (mTask != null) { mTask.cancel(true); if (mTask.isCancelled()) { listener.onCancel(); return true; } else { return false; } } return false; } BitMap(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); BitMap setCallback(HttpListener<Bitmap> listener); boolean cancel(); BitMap setCacheManager(CacheManagerInterface<Bitmap> cache); } | @Test public void cancel() throws Exception { } |
BitMap extends Type<Bitmap> { public BitMap setCacheManager(CacheManagerInterface<Bitmap> cache) { this.mCacheManager = cache; return this; } BitMap(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); BitMap setCallback(HttpListener<Bitmap> listener); boolean cancel(); BitMap setCacheManager(CacheManagerInterface<Bitmap> cache); } | @Test public void setCacheManager() throws Exception { } |
Type { public abstract Type setCacheManager(CacheManagerInterface<T> cacheManager); abstract Type setCacheManager(CacheManagerInterface<T> cacheManager); abstract Type setCallback(HttpListener<T> callback); abstract boolean cancel(); } | @Test public void setCacheManager() throws Exception { } |
Type { public abstract Type setCallback(HttpListener<T> callback); abstract Type setCacheManager(CacheManagerInterface<T> cacheManager); abstract Type setCallback(HttpListener<T> callback); abstract boolean cancel(); } | @Test public void setCallback() throws Exception { } |
Type { public abstract boolean cancel(); abstract Type setCacheManager(CacheManagerInterface<T> cacheManager); abstract Type setCallback(HttpListener<T> callback); abstract boolean cancel(); } | @Test public void cancel() throws Exception { } |
Response { public Response setData(InputStream data) { this.inputStream = data; return this; } int getCode(); Response setCode(int code); InputStream getData(); Response setData(InputStream data); String getDataAsString(); Bitmap getAsBitmap(); } | @Test public void setData() throws Exception { } |
JsonObject extends Type<JSONObject> { public JsonObject setCallback(HttpListener<JSONObject> listener) { this.mListener = listener; mListener.onRequest(); JSONObject data; if (mCacheManager != null) { data = mCacheManager.getDataFromCache(url); if (data != null) { mListener.onResponse(data); return this; } } mTask = new JsonObjectTask(method, url, params, headers, mListener); mTask.execute(); return this; } JsonObject(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); JsonObject setCallback(HttpListener<JSONObject> listener); boolean cancel(); JsonObject setCacheManager(CacheManagerInterface<JSONObject> cache); } | @Test public void setCallback() throws Exception { } |
JsonObject extends Type<JSONObject> { public boolean cancel() { if (mTask != null) { mTask.cancel(true); if (mTask.isCancelled()) { mListener.onCancel(); return true; } else { return false; } } return false; } JsonObject(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); JsonObject setCallback(HttpListener<JSONObject> listener); boolean cancel(); JsonObject setCacheManager(CacheManagerInterface<JSONObject> cache); } | @Test public void cancel() throws Exception { } |
JsonObject extends Type<JSONObject> { public JsonObject setCacheManager(CacheManagerInterface<JSONObject> cache) { this.mCacheManager = cache; return this; } JsonObject(DownZ.Method m, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers); JsonObject setCallback(HttpListener<JSONObject> listener); boolean cancel(); JsonObject setCacheManager(CacheManagerInterface<JSONObject> cache); } | @Test public void setCacheManager() throws Exception { } |
Response { public String getDataAsString() throws IOException { final int bufferSize = 1024; final char[] buffer = new char[bufferSize]; final StringBuilder out = new StringBuilder(); Reader in = new InputStreamReader(inputStream, "UTF-8"); for (; ; ) { int i = in.read(buffer, 0, buffer.length); if (i < 0) break; out.append(buffer, 0, i); } if (inputStream != null) { inputStream.close(); } return out.toString(); } int getCode(); Response setCode(int code); InputStream getData(); Response setData(InputStream data); String getDataAsString(); Bitmap getAsBitmap(); } | @Test public void getDataAsString() throws Exception { } |
Response { public Bitmap getAsBitmap() { Bitmap bitmap = BitmapFactory.decodeStream(this.inputStream); if (inputStream != null) { try { inputStream.close(); } catch (IOException e) { e.printStackTrace(); } } return bitmap; } int getCode(); Response setCode(int code); InputStream getData(); Response setData(InputStream data); String getDataAsString(); Bitmap getAsBitmap(); } | @Test public void getAsBitmap() throws Exception { } |
JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected void onPreExecute() { super.onPreExecute(); } JsonObjectTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONObject> callback); } | @Test public void onPreExecute() throws Exception { } |
JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected JSONObject doInBackground(String... urls) { try { Response response = makeRequest(mUrl, method, params, headers); JSONObject json = new JSONObject(response.getDataAsString()); if (this.mCacheManager != null) { if (this.mCacheManager.getDataFromCache(mUrl) == null) this.mCacheManager.addDataToCache(mUrl, json); } return json; } catch (Exception e) { e.printStackTrace(); error = true; } return null; } JsonObjectTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONObject> callback); } | @Test public void doInBackground() throws Exception { } |
JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected void onPostExecute(JSONObject data) { super.onPostExecute(data); if (!error) this.callback.onResponse(data); else this.callback.onError(); } JsonObjectTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONObject> callback); } | @Test public void onPostExecute() throws Exception { } |
JsonObjectTask extends Task<String, Void, JSONObject> { @Override protected void onCancelled() { super.onCancelled(); if (this.mCacheManager != null) { this.mCacheManager.removeDataFromCache(mUrl); } } JsonObjectTask(DownZ.Method method, String url, ArrayList<RequestParams> params, ArrayList<HeaderParams> headers, HttpListener<JSONObject> callback); } | @Test public void onCancelled() throws Exception { } |
SnappyDecompressor { public static Buffer decompress(byte[] in) { return decompress(in, 0, in.length, null); } private SnappyDecompressor(); static Buffer decompress(byte[] in); static Buffer decompress(byte[] in, Buffer out); static Buffer decompress(byte[] in, int offset, int length); static Buffer decompress(Buffer in); static Buffer decompress(Buffer in, Buffer out); static Buffer decompress(byte[] in, int offset, int length, Buffer out); } | @Test public void testSuperfluousData() { byte[] data = new byte[2]; try { SnappyDecompressor.decompress(data); Assert.fail("Exception was expected"); } catch(FormatViolationException e) { Assert.assertEquals(1, e.getOffset()); } } |
DefaultDragHelper implements DragHelper { @Override public void onDragEnd(@NonNull WXComponent component, int from, int to) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.d(TAG, "list on drag end : " + "from index " + from + " to index " + to); } mEventTrigger.triggerEvent(EVENT_END_DRAG, buildEvent(component.getRef(), from, to)); } DefaultDragHelper(@NonNull List<WXComponent> dataSource, @NonNull RecyclerView recyclerView, @NonNull EventTrigger trigger); @Override void onDragStart(@NonNull WXComponent component, int from); @Override void onDragEnd(@NonNull WXComponent component, int from, int to); @Override void onDragging(int fromPos, int toPos); @Override boolean isLongPressDragEnabled(); @Override void setLongPressDragEnabled(boolean enabled); @Override void startDrag(@NonNull RecyclerView.ViewHolder viewHolder); @Override boolean isDraggable(); @Override void setDraggable(boolean draggable); @Override void setDragExcluded(@NonNull RecyclerView.ViewHolder viewHolder, boolean isExcluded); @Override boolean isDragExcluded(@NonNull RecyclerView.ViewHolder viewHolder); } | @Test public void onDragEnd() throws Exception { WXComponent c = new WXCell(WXSDKInstanceTest.createInstance(),new TestDomObject(),null,false); mFakeDragHelper.onDragEnd(c,1,2); verify(mockedEventTrigger).triggerEvent(eq("dragend"),anyMap()); } |
DefaultDragHelper implements DragHelper { @Override public void onDragging(int fromPos, int toPos) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.d(TAG, "list on dragging : from index " + fromPos + " to index " + toPos); } RecyclerView.Adapter adapter = mRecyclerView.getAdapter(); if (adapter == null) { WXLogUtils.e(TAG, "drag failed because of RecyclerView#Adapter is not bound"); return; } if (fromPos >= 0 && fromPos <= mDataSource.size() - 1 && toPos >= 0 && toPos <= mDataSource.size() - 1) { Collections.swap(mDataSource, fromPos, toPos); adapter.notifyItemMoved(fromPos, toPos); } } DefaultDragHelper(@NonNull List<WXComponent> dataSource, @NonNull RecyclerView recyclerView, @NonNull EventTrigger trigger); @Override void onDragStart(@NonNull WXComponent component, int from); @Override void onDragEnd(@NonNull WXComponent component, int from, int to); @Override void onDragging(int fromPos, int toPos); @Override boolean isLongPressDragEnabled(); @Override void setLongPressDragEnabled(boolean enabled); @Override void startDrag(@NonNull RecyclerView.ViewHolder viewHolder); @Override boolean isDraggable(); @Override void setDraggable(boolean draggable); @Override void setDragExcluded(@NonNull RecyclerView.ViewHolder viewHolder, boolean isExcluded); @Override boolean isDragExcluded(@NonNull RecyclerView.ViewHolder viewHolder); } | @Test public void onDragging() throws Exception { assertEquals(mFakeDataSource.get(0),c1); assertEquals(mFakeDataSource.get(1),c2); mFakeDragHelper.onDragging(0,1); assertEquals(mFakeDataSource.get(0),c2); assertEquals(mFakeDataSource.get(1),c1); } |
WXRefresh extends WXBaseRefresh implements WXSwipeLayout.WXOnRefreshListener { @Override public void onRefresh() { if(isDestoryed()){ return; } ImmutableDomObject dom; if ((dom = getDomObject())!= null && dom.getEvents().contains(Constants.Event.ONREFRESH)) { fireEvent(Constants.Event.ONREFRESH); } } @Deprecated WXRefresh(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXRefresh(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy); @Override boolean canRecycled(); @Override void onRefresh(); @Override int getLayoutTopOffsetForSibling(); @Override void onPullingDown(float dy, int pullOutDistance, float viewHeight); @WXComponentProp(name = Constants.Name.DISPLAY) void setDisplay(String display); static final String HIDE; } | @Test public void testOnRefresh() throws Exception { component.onRefresh(); } |
WXRefresh extends WXBaseRefresh implements WXSwipeLayout.WXOnRefreshListener { @Override public void onPullingDown(float dy, int pullOutDistance, float viewHeight) { if (getDomObject().getEvents() != null && getDomObject().getEvents().contains(Constants.Event.ONPULLING_DOWN)) { Map<String, Object> data = new HashMap<>(); data.put(Constants.Name.DISTANCE_Y, dy); data.put(Constants.Name.PULLING_DISTANCE, pullOutDistance); data.put(Constants.Name.VIEW_HEIGHT, viewHeight); fireEvent(Constants.Event.ONPULLING_DOWN, data); } } @Deprecated WXRefresh(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXRefresh(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy); @Override boolean canRecycled(); @Override void onRefresh(); @Override int getLayoutTopOffsetForSibling(); @Override void onPullingDown(float dy, int pullOutDistance, float viewHeight); @WXComponentProp(name = Constants.Name.DISPLAY) void setDisplay(String display); static final String HIDE; } | @Test public void testOnPullingDown() throws Exception { component.onPullingDown(10,100,100); } |
WXRefresh extends WXBaseRefresh implements WXSwipeLayout.WXOnRefreshListener { @Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.DISPLAY: String display = WXUtils.getString(param,null); if (display != null) setDisplay(display); return true; } return super.setProperty(key,param); } @Deprecated WXRefresh(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXRefresh(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy); @Override boolean canRecycled(); @Override void onRefresh(); @Override int getLayoutTopOffsetForSibling(); @Override void onPullingDown(float dy, int pullOutDistance, float viewHeight); @WXComponentProp(name = Constants.Name.DISPLAY) void setDisplay(String display); static final String HIDE; } | @Test public void testSetProperty() throws Exception { component.setProperty(Constants.Name.DISPLAY,WXRefresh.HIDE); } |
WXSliderNeighbor extends WXSlider { @Override protected boolean setProperty(String key, Object param) { String input; switch (key) { case NEIGHBOR_SCALE: input = WXUtils.getString(param, null); if (input != null) { setNeighborScale(input); } return true; case NEIGHBOR_ALPHA: input = WXUtils.getString(param, null); if (input != null) { setNeighborAlpha(input); } return true; case NEIGHBOR_SPACE: input = WXUtils.getString(param, null); if (input != null) { setNeighborSpace(input); } return true; case CURRENT_ITEM_SCALE: input = WXUtils.getString(param, null); if (input != null) { setCurrentItemScale(input); } return true; } return super.setProperty(key, param); } WXSliderNeighbor(WXSDKInstance instance, WXDomObject node, WXVContainer parent); @Override void bindData(WXComponent component); @WXComponentProp(name = NEIGHBOR_SCALE) void setNeighborScale(String input); @WXComponentProp(name = NEIGHBOR_ALPHA) void setNeighborAlpha(String input); @WXComponentProp(name = NEIGHBOR_SPACE) @SuppressWarnings("unused") void setNeighborSpace(String input); @WXComponentProp(name = CURRENT_ITEM_SCALE) @SuppressWarnings("unused") void setCurrentItemScale(String input); static final String NEIGHBOR_SCALE; static final String NEIGHBOR_ALPHA; static final String NEIGHBOR_SPACE; static final String CURRENT_ITEM_SCALE; } | @Test public void testSetProperties() throws Exception { component.setProperty(WXSliderNeighbor.NEIGHBOR_ALPHA,0.4f); component.setProperty(WXSliderNeighbor.NEIGHBOR_SCALE,0.9f); } |
WXSliderNeighbor extends WXSlider { ZoomTransformer createTransformer() { if(mCachedTransformer == null) { mCachedTransformer = new ZoomTransformer(); } return mCachedTransformer; } WXSliderNeighbor(WXSDKInstance instance, WXDomObject node, WXVContainer parent); @Override void bindData(WXComponent component); @WXComponentProp(name = NEIGHBOR_SCALE) void setNeighborScale(String input); @WXComponentProp(name = NEIGHBOR_ALPHA) void setNeighborAlpha(String input); @WXComponentProp(name = NEIGHBOR_SPACE) @SuppressWarnings("unused") void setNeighborSpace(String input); @WXComponentProp(name = CURRENT_ITEM_SCALE) @SuppressWarnings("unused") void setCurrentItemScale(String input); static final String NEIGHBOR_SCALE; static final String NEIGHBOR_ALPHA; static final String NEIGHBOR_SPACE; static final String CURRENT_ITEM_SCALE; } | @Test public void testZoomTransformer() throws Exception { component = create(); TestComponent page = ComponentTest.createComponent(new TestDomObject(),component,TestComponent.class); TestComponent pageChild = ComponentTest.createComponent(new TestDomObject(),component,TestComponent.class); page.addChild(pageChild); component.addChild(page); ComponentTest.create(component); WXSliderNeighbor.ZoomTransformer transformer = component.createTransformer(); transformer.transformPage(page.getHostView(),0.2f); } |
WXEmbed extends WXDiv implements WXSDKInstance.OnInstanceVisibleListener,NestedContainer { @Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.SRC: String src = WXUtils.getString(param,null); if (src != null) setSrc(src); return true; } return super.setProperty(key, param); } @Deprecated WXEmbed(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXEmbed(WXSDKInstance instance, WXDomObject node, WXVContainer parent); @Override void setOnNestEventListener(OnNestedInstanceEventListener listener); @Override ViewGroup getViewContainer(); @Override void renderNewURL(String url); @Override void reload(); String getOriginUrl(); void setOriginUrl(String originUrl); @WXComponentProp(name = Constants.Name.SRC) void setSrc(String src); String getSrc(); @Override void setVisibility(String visibility); @Override void destroy(); @Override void onAppear(); @Override void onDisappear(); @Override void onActivityStart(); @Override void onActivityResume(); @Override void onActivityPause(); @Override void onActivityStop(); @Override void onActivityDestroy(); static final String ITEM_ID; } | @Test public void testSetProperty() throws Exception { component.setProperty(Constants.Name.SRC,"http: } |
WXEmbed extends WXDiv implements WXSDKInstance.OnInstanceVisibleListener,NestedContainer { @Override public void setVisibility(String visibility) { super.setVisibility(visibility); boolean visible = TextUtils.equals(visibility, Constants.Value.VISIBLE); if (!TextUtils.isEmpty(src) && visible) { if (mNestedInstance == null) { loadContent(); } else { mNestedInstance.onViewAppear(); } } if (!visible) { if (mNestedInstance != null) { mNestedInstance.onViewDisappear(); } } mIsVisible = visible; } @Deprecated WXEmbed(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXEmbed(WXSDKInstance instance, WXDomObject node, WXVContainer parent); @Override void setOnNestEventListener(OnNestedInstanceEventListener listener); @Override ViewGroup getViewContainer(); @Override void renderNewURL(String url); @Override void reload(); String getOriginUrl(); void setOriginUrl(String originUrl); @WXComponentProp(name = Constants.Name.SRC) void setSrc(String src); String getSrc(); @Override void setVisibility(String visibility); @Override void destroy(); @Override void onAppear(); @Override void onDisappear(); @Override void onActivityStart(); @Override void onActivityResume(); @Override void onActivityPause(); @Override void onActivityStop(); @Override void onActivityDestroy(); static final String ITEM_ID; } | @Test public void testSetVisibility() throws Exception { component.setProperty(Constants.Name.VISIBILITY,Constants.Value.HIDDEN); component.setProperty(Constants.Name.SRC,"http: component.setProperty(Constants.Name.VISIBILITY,Constants.Value.VISIBLE); } |
WXLoading extends WXBaseRefresh implements WXSwipeLayout.WXOnLoadingListener { @Override public void onLoading() { ImmutableDomObject domObject = getDomObject(); if (domObject != null && domObject.getEvents().contains(Constants.Event.ONLOADING)) { fireEvent(Constants.Event.ONLOADING); } } WXLoading(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy); @Override void onLoading(); @Override void onPullingUp(float dy, int pullOutDistance, float viewHeight); @Override boolean canRecycled(); @WXComponentProp(name = Constants.Name.DISPLAY) void setDisplay(String display); static final String HIDE; } | @Test public void testOnLoading() throws Exception { component.onLoading(); } |
WXLoading extends WXBaseRefresh implements WXSwipeLayout.WXOnLoadingListener { @Override protected boolean setProperty(String key, Object param) { switch (key) { case Constants.Name.DISPLAY: String display = WXUtils.getString(param,null); if (display != null) setDisplay(display); return true; } return super.setProperty(key, param); } WXLoading(WXSDKInstance instance, WXDomObject node, WXVContainer parent, boolean lazy); @Override void onLoading(); @Override void onPullingUp(float dy, int pullOutDistance, float viewHeight); @Override boolean canRecycled(); @WXComponentProp(name = Constants.Name.DISPLAY) void setDisplay(String display); static final String HIDE; } | @Test public void testSetProperty() throws Exception { component.setProperty(Constants.Name.DISPLAY,WXLoading.HIDE); } |
WXScroller extends WXVContainer<ViewGroup> implements WXScrollViewListener,Scrollable { @Override public void addChild(WXComponent child, int index) { mChildrenLayoutOffset += child.getLayoutTopOffsetForSibling(); if (child instanceof WXBaseRefresh) { if (!checkRefreshOrLoading(child)) { mRefreshs.add(child); } } super.addChild(child,index); } @Deprecated WXScroller(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy); WXScroller(WXSDKInstance instance, WXDomObject node,
WXVContainer parent); @Override ViewGroup getRealView(); @Override void createViewImpl(); ViewGroup getInnerView(); @Override void addEvent(String type); @Override void addChild(WXComponent child, int index); @Override void remove(WXComponent child,boolean destory); @Override void destroy(); @Override int getScrollY(); @Override int getScrollX(); @Override int getOrientation(); Map<String, Map<String, WXComponent>> getStickMap(); @WXComponentProp(name = Constants.Name.SHOW_SCROLLBAR) void setShowScrollbar(boolean show); @WXComponentProp(name = Constants.Name.SCROLLABLE) void setScrollable(boolean scrollable); @WXComponentProp(name = Constants.Name.OFFSET_ACCURACY) void setOffsetAccuracy(int accuracy); @Override boolean isScrollable(); @Override void bindStickStyle(WXComponent component); @Override void unbindStickStyle(WXComponent component); @Override void bindAppearEvent(WXComponent component); @Override void bindDisappearEvent(WXComponent component); @Override void unbindAppearEvent(WXComponent component); @Override void unbindDisappearEvent(WXComponent component); @Override void scrollTo(WXComponent component, Map<String, Object> options); void scrollBy(final int x, final int y); void scrollBy(final int x, final int y, final boolean smooth); @Override void onScrollChanged(WXScrollView scrollView, int x, int y,
int oldx, int oldy); @Override void onScrollToBottom(WXScrollView scrollView, int x, int y); @Override void onScrollStopped(WXScrollView scrollView, int x, int y); @Override void onScroll(WXScrollView scrollView, int x, int y); @JSMethod void resetLoadmore(); static final String DIRECTION; } | @Test public void testAddChild() throws Exception{ WXDiv div = WXDivTest.create(component); component.addChild(div); ComponentTest.create(div); } |
WXAnimationModule extends WXModule { @JSMethod public void transition(@Nullable String ref, @Nullable String animation, @Nullable String callBack) { if (!TextUtils.isEmpty(ref) && !TextUtils.isEmpty(animation) && mWXSDKInstance != null) { DOMAction animationActions = getAnimationAction(ref, animation, callBack); WXSDKManager.getInstance().getWXDomManager().postActionDelay(mWXSDKInstance.getInstanceId(), animationActions, false, WXDomHandler.DELAY_TIME); } } @JSMethod void transition(@Nullable String ref, @Nullable String animation, @Nullable String callBack); } | @Test public void testTransition() throws Exception { module.transition("","",""); module.transition("test","test",""); } |
WXScrollView extends ScrollView implements Callback, IWXScroller,
WXGestureObservable,NestedScrollingChild { @Override public boolean dispatchTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN) { mRedirectTouchToStickyView = true; } if (mRedirectTouchToStickyView) { mRedirectTouchToStickyView = mCurrentStickyView != null; if (mRedirectTouchToStickyView) { mRedirectTouchToStickyView = ev.getY() <= mCurrentStickyView.getHeight() && ev.getX() >= mCurrentStickyView.getLeft() && ev.getX() <= mCurrentStickyView.getRight(); } } if (mRedirectTouchToStickyView) { if (mScrollRect == null) { mScrollRect = new Rect(); getGlobalVisibleRect(mScrollRect); } mCurrentStickyView.getLocationOnScreen(stickyViewP); ev.offsetLocation(0, stickyViewP[1] - mScrollRect.top); } return super.dispatchTouchEvent(ev); } WXScrollView(Context context); WXScrollView(Context context, AttributeSet attrs); WXScrollView(Context context, AttributeSet attrs, int defStyle); void startScrollerTask(); void addScrollViewListener(WXScrollViewListener scrollViewListener); void removeScrollViewListener(WXScrollViewListener scrollViewListener); @Override boolean dispatchTouchEvent(MotionEvent ev); @Override boolean onTouchEvent(MotionEvent ev); @Override void setNestedScrollingEnabled(boolean enabled); @Override boolean isNestedScrollingEnabled(); @Override boolean startNestedScroll(int axes); @Override void stopNestedScroll(); @Override boolean hasNestedScrollingParent(); boolean isScrollable(); void setScrollable(boolean scrollable); @Override boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow); @Override boolean dispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow); @Override boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed); @Override boolean dispatchNestedPreFling(float velocityX, float velocityY); @Override boolean onNestedPreFling(View target, float velocityX,
float velocityY); @Override boolean onNestedFling(View target, float velocityX, float velocityY,
boolean consumed); @Override void fling(int velocityY); @Override boolean handleMessage(Message msg); @Override void destroy(); @Override void registerGestureListener(WXGesture wxGesture); Rect getContentFrame(); void setWAScroller(WXScroller mWAScroller); } | @Test public void testDispatchTouchEvent() throws Exception { for(int action:EVENTS) { MotionEvent event = MotionEvent.obtain(100, 100, action, 10, 10, 0); view.dispatchTouchEvent(event); event.recycle(); } } |
WXScrollView extends ScrollView implements Callback, IWXScroller,
WXGestureObservable,NestedScrollingChild { @Override public boolean onTouchEvent(MotionEvent ev) { if(!scrollable) { return true; } if (mRedirectTouchToStickyView) { if (mScrollRect == null) { mScrollRect = new Rect(); getGlobalVisibleRect(mScrollRect); } mCurrentStickyView.getLocationOnScreen(stickyViewP); ev.offsetLocation(0, -(stickyViewP[1] - mScrollRect.top)); } if (ev.getAction() == MotionEvent.ACTION_DOWN) { mHasNotDoneActionDown = false; } if (mHasNotDoneActionDown) { MotionEvent down = MotionEvent.obtain(ev); down.setAction(MotionEvent.ACTION_DOWN); mHasNotDoneActionDown = false; down.recycle(); } if (ev.getAction() == MotionEvent.ACTION_DOWN) { ox = ev.getX(); oy = ev.getY(); startNestedScroll(ViewCompat.SCROLL_AXIS_HORIZONTAL | ViewCompat.SCROLL_AXIS_VERTICAL); } if (ev.getAction() == MotionEvent.ACTION_UP || ev.getAction() == MotionEvent.ACTION_CANCEL) { mHasNotDoneActionDown = true; stopNestedScroll(); } if (ev.getAction() == MotionEvent.ACTION_MOVE) { float clampedX = ev.getX(); float clampedY = ev.getY(); int dx = (int) (ox - clampedX); int dy = (int) (oy - clampedY); if (dispatchNestedPreScroll(dx, dy, consumed, offsetInWindow)) { ev.setLocation(clampedX+consumed[0],clampedY+consumed[1]); } ox = ev.getX(); oy = ev.getY(); } boolean result = super.onTouchEvent(ev); if (wxGesture != null) { result |= wxGesture.onTouch(this, ev); } return result; } WXScrollView(Context context); WXScrollView(Context context, AttributeSet attrs); WXScrollView(Context context, AttributeSet attrs, int defStyle); void startScrollerTask(); void addScrollViewListener(WXScrollViewListener scrollViewListener); void removeScrollViewListener(WXScrollViewListener scrollViewListener); @Override boolean dispatchTouchEvent(MotionEvent ev); @Override boolean onTouchEvent(MotionEvent ev); @Override void setNestedScrollingEnabled(boolean enabled); @Override boolean isNestedScrollingEnabled(); @Override boolean startNestedScroll(int axes); @Override void stopNestedScroll(); @Override boolean hasNestedScrollingParent(); boolean isScrollable(); void setScrollable(boolean scrollable); @Override boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow); @Override boolean dispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow); @Override boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed); @Override boolean dispatchNestedPreFling(float velocityX, float velocityY); @Override boolean onNestedPreFling(View target, float velocityX,
float velocityY); @Override boolean onNestedFling(View target, float velocityX, float velocityY,
boolean consumed); @Override void fling(int velocityY); @Override boolean handleMessage(Message msg); @Override void destroy(); @Override void registerGestureListener(WXGesture wxGesture); Rect getContentFrame(); void setWAScroller(WXScroller mWAScroller); } | @Test public void testOnTouchEvent() throws Exception { for(int action:EVENTS) { MotionEvent event = MotionEvent.obtain(100, 100, action, 10, 10, 0); view.onTouchEvent(event); event.recycle(); } } |
WXScrollView extends ScrollView implements Callback, IWXScroller,
WXGestureObservable,NestedScrollingChild { @Override protected void onScrollChanged(int x, int y, int oldx, int oldy) { mScrollX = getScrollX(); mScrollY = getScrollY(); onScroll(WXScrollView.this, mScrollX, mScrollY); View view = getChildAt(getChildCount() - 1); if (view == null) { return; } int d = view.getBottom(); d -= (getHeight() + mScrollY); if (d == 0) { onScrollToBottom(mScrollX, mScrollY); } int count = mScrollViewListeners == null ? 0 : mScrollViewListeners.size(); for (int i = 0; i < count; ++i) { mScrollViewListeners.get(i).onScrollChanged(this, x, y, oldx, oldy); } showStickyView(); } WXScrollView(Context context); WXScrollView(Context context, AttributeSet attrs); WXScrollView(Context context, AttributeSet attrs, int defStyle); void startScrollerTask(); void addScrollViewListener(WXScrollViewListener scrollViewListener); void removeScrollViewListener(WXScrollViewListener scrollViewListener); @Override boolean dispatchTouchEvent(MotionEvent ev); @Override boolean onTouchEvent(MotionEvent ev); @Override void setNestedScrollingEnabled(boolean enabled); @Override boolean isNestedScrollingEnabled(); @Override boolean startNestedScroll(int axes); @Override void stopNestedScroll(); @Override boolean hasNestedScrollingParent(); boolean isScrollable(); void setScrollable(boolean scrollable); @Override boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, int dxUnconsumed, int dyUnconsumed, int[] offsetInWindow); @Override boolean dispatchNestedPreScroll(int dx, int dy, int[] consumed, int[] offsetInWindow); @Override boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed); @Override boolean dispatchNestedPreFling(float velocityX, float velocityY); @Override boolean onNestedPreFling(View target, float velocityX,
float velocityY); @Override boolean onNestedFling(View target, float velocityX, float velocityY,
boolean consumed); @Override void fling(int velocityY); @Override boolean handleMessage(Message msg); @Override void destroy(); @Override void registerGestureListener(WXGesture wxGesture); Rect getContentFrame(); void setWAScroller(WXScroller mWAScroller); } | @Test public void testOnScrollChanged() throws Exception { view.onScrollChanged(0,10,0,20); } |
WXGesture extends GestureDetector.SimpleOnGestureListener implements OnTouchListener { @Override public boolean onTouch(View v, MotionEvent event) { try { boolean result = mGestureDetector.onTouchEvent(event); switch (event.getActionMasked()) { case MotionEvent.ACTION_POINTER_DOWN: case MotionEvent.ACTION_DOWN: mIsTouchEventConsumed = false; if(hasSameOrientationWithParent() && !isParentScrollable()){ ViewParent p; if ((p = component.getRealView().getParent()) != null) { p.requestDisallowInterceptTouchEvent(true); } } result |= handleMotionEvent(LowLevelGesture.ACTION_DOWN, event); break; case MotionEvent.ACTION_MOVE: result |= handleMotionEvent(LowLevelGesture.ACTION_MOVE, event); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_POINTER_UP: finishDisallowInterceptTouchEvent(v); result |= handleMotionEvent(LowLevelGesture.ACTION_UP, event); result |= handlePanMotionEvent(event); break; case MotionEvent.ACTION_CANCEL: finishDisallowInterceptTouchEvent(v); result |= handleMotionEvent(LowLevelGesture.ACTION_CANCEL, event); result |= handlePanMotionEvent(event); break; } return result; } catch (Exception e) { WXLogUtils.e("Gesture RunTime Error ", e); return false; } } WXGesture(WXComponent wxComponent, Context context); void setPreventMoveEvent(boolean preventMoveEvent); boolean isTouchEventConsumedByAdvancedGesture(); @Override boolean onTouch(View v, MotionEvent event); @Override void onLongPress(MotionEvent e); @Override boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY); @Override boolean onDown(MotionEvent e); static final String START; static final String MOVE; static final String END; static final String UNKNOWN; static final String LEFT; static final String RIGHT; static final String UP; static final String DOWN; } | @Test public void testOnTouch() throws Exception { MotionEvent event = MotionEvent.obtain(System.currentTimeMillis(), System.currentTimeMillis(),MotionEvent.ACTION_DOWN,0,0,0); mGesture.onTouch(component.getHostView(),event); event = MotionEvent.obtain(System.currentTimeMillis(), System.currentTimeMillis(),MotionEvent.ACTION_MOVE,0,0,0); mGesture.onTouch(component.getHostView(),event); event = MotionEvent.obtain(System.currentTimeMillis(), System.currentTimeMillis(),MotionEvent.ACTION_UP,0,0,0); mGesture.onTouch(component.getHostView(),event); event = MotionEvent.obtain(System.currentTimeMillis(), System.currentTimeMillis(),MotionEvent.ACTION_POINTER_UP,0,0,0); mGesture.onTouch(component.getHostView(),event); event = MotionEvent.obtain(System.currentTimeMillis(), System.currentTimeMillis(),MotionEvent.ACTION_CANCEL,0,0,0); mGesture.onTouch(component.getHostView(),event); } |
BorderDrawable extends Drawable { @Override public int getOpacity() { return mShader!=null?PixelFormat.OPAQUE: WXViewUtils.getOpacityFromColor(WXViewUtils.multiplyColorAlpha(mColor, mAlpha)); } BorderDrawable(); @Override void draw(@NonNull Canvas canvas); @Override void setAlpha(int alpha); @Override int getAlpha(); @Override void setColorFilter(ColorFilter cf); @Override int getOpacity(); @Override void getOutline(@NonNull Outline outline); void setBorderWidth(@BorderWidthStyleColorType int position, float width); void setBorderRadius(@BorderRadiusType int position, float radius); @NonNull float[] getBorderRadius(RectF borderBox); void setBorderColor(@BorderWidthStyleColorType int position, int color); void setBorderStyle(@BorderWidthStyleColorType int position, @NonNull String style); int getColor(); void setColor(int color); void setImage(Shader shader); boolean hasImage(); boolean isRounded(); @NonNull Path getContentPath(@NonNull RectF borderBox); static final int BORDER_TOP_LEFT_RADIUS; static final int BORDER_TOP_RIGHT_RADIUS; static final int BORDER_BOTTOM_RIGHT_RADIUS; static final int BORDER_BOTTOM_LEFT_RADIUS; static final int BORDER_RADIUS_ALL; } | @Test public void testGetOpacity() throws Exception { BorderDrawable opaque = new BorderDrawable(); opaque.setColor(Color.GREEN); assertThat(opaque.getOpacity(), is(PixelFormat.OPAQUE)); BorderDrawable transparent = new BorderDrawable(); transparent.setColor(WXResourceUtils.getColor("#00ff0000")); assertThat(transparent.getOpacity(), is(PixelFormat.TRANSPARENT)); BorderDrawable half = new BorderDrawable(); half.setColor(WXResourceUtils.getColor("#aaff0000")); assertThat(half.getOpacity(), is(PixelFormat.TRANSLUCENT)); BorderDrawable changeAlpha = new BorderDrawable(); changeAlpha.setColor(Color.RED); changeAlpha.setAlpha(15); assertThat(changeAlpha.getOpacity(), is(PixelFormat.TRANSLUCENT)); } |
BorderDrawable extends Drawable { public boolean isRounded() { return mBorderRadius != null && (!FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_TOP_LEFT_RADIUS), 0) || !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_TOP_RIGHT_RADIUS), 0) || !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_BOTTOM_RIGHT_RADIUS), 0) || !FloatUtil.floatsEqual(getBorderRadius(mBorderRadius, BORDER_BOTTOM_LEFT_RADIUS), 0)); } BorderDrawable(); @Override void draw(@NonNull Canvas canvas); @Override void setAlpha(int alpha); @Override int getAlpha(); @Override void setColorFilter(ColorFilter cf); @Override int getOpacity(); @Override void getOutline(@NonNull Outline outline); void setBorderWidth(@BorderWidthStyleColorType int position, float width); void setBorderRadius(@BorderRadiusType int position, float radius); @NonNull float[] getBorderRadius(RectF borderBox); void setBorderColor(@BorderWidthStyleColorType int position, int color); void setBorderStyle(@BorderWidthStyleColorType int position, @NonNull String style); int getColor(); void setColor(int color); void setImage(Shader shader); boolean hasImage(); boolean isRounded(); @NonNull Path getContentPath(@NonNull RectF borderBox); static final int BORDER_TOP_LEFT_RADIUS; static final int BORDER_TOP_RIGHT_RADIUS; static final int BORDER_BOTTOM_RIGHT_RADIUS; static final int BORDER_BOTTOM_LEFT_RADIUS; static final int BORDER_RADIUS_ALL; } | @Test public void testIsRounded(){ BorderDrawable none = new BorderDrawable(); assertThat(none.isRounded(), is(false)); BorderDrawable full = new BorderDrawable(); full.setBorderRadius(BorderDrawable.BORDER_RADIUS_ALL, 12); assertThat(full.isRounded(), is(true)); BorderDrawable noneAndPart = new BorderDrawable(); noneAndPart.setBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS, 5); noneAndPart.setBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS, 12); assertThat(noneAndPart.isRounded(), is(true)); BorderDrawable fullAndPart = new BorderDrawable(); fullAndPart.setBorderRadius(BorderDrawable.BORDER_RADIUS_ALL, 0); fullAndPart.setBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS, 12); fullAndPart.setBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS, 19); assertThat(fullAndPart.isRounded(), is(true)); BorderDrawable partAndFull = new BorderDrawable(); partAndFull.setBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS, 12); partAndFull.setBorderRadius(BorderDrawable.BORDER_RADIUS_ALL, 0); assertThat(partAndFull.isRounded(), is(true)); BorderDrawable zeroAll = new BorderDrawable(); zeroAll.setBorderRadius(BorderDrawable.BORDER_RADIUS_ALL, 0); assertThat(zeroAll.isRounded(), is(false)); BorderDrawable zeroPart = new BorderDrawable(); zeroPart.setBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS, 0); assertThat(zeroPart.isRounded(), is(false)); } |
WXTimerModule extends WXModule implements Destroyable, Handler.Callback { @JSMethod(uiThread = false) public void clearTimeout(@IntRange(from = 1) int funcId) { if (funcId <= 0) { return; } removeOrHoldMessage(MODULE_TIMEOUT, funcId); } WXTimerModule(); @JSMethod(uiThread = false) void setTimeout(@IntRange(from = 1) int funcId, @IntRange(from = 0) int delay); @JSMethod(uiThread = false) void setInterval(@IntRange(from = 1) int funcId, @IntRange(from = 0) int interval); @JSMethod(uiThread = false) void clearTimeout(@IntRange(from = 1) int funcId); @JSMethod(uiThread = false) void clearInterval(@IntRange(from = 1) int funcId); @Override void destroy(); @Override boolean handleMessage(Message msg); } | @Test public void testClearTimeout() throws Exception { module.setTimeout(VALID_FUNC_ID, DELAY); module.clearTimeout(VALID_FUNC_ID); mLooper.idle(DELAY, TimeUnit.MILLISECONDS); Mockito.verify(module, never()).handleMessage(any(Message.class)); } |
WXTimerModule extends WXModule implements Destroyable, Handler.Callback { @JSMethod(uiThread = false) public void clearInterval(@IntRange(from = 1) int funcId) { if (funcId <= 0) { return; } removeOrHoldMessage(MODULE_INTERVAL, funcId); } WXTimerModule(); @JSMethod(uiThread = false) void setTimeout(@IntRange(from = 1) int funcId, @IntRange(from = 0) int delay); @JSMethod(uiThread = false) void setInterval(@IntRange(from = 1) int funcId, @IntRange(from = 0) int interval); @JSMethod(uiThread = false) void clearTimeout(@IntRange(from = 1) int funcId); @JSMethod(uiThread = false) void clearInterval(@IntRange(from = 1) int funcId); @Override void destroy(); @Override boolean handleMessage(Message msg); } | @Test public void testClearInterval() throws Exception { module.setInterval(VALID_FUNC_ID, DELAY); module.clearInterval(VALID_FUNC_ID); mLooper.idle(DELAY, TimeUnit.MILLISECONDS); Mockito.verify(module, never()).handleMessage(any(Message.class)); } |
WXMetaModule extends WXModule { @JSMethod(uiThread = false) public void setViewport(String param) { if (!TextUtils.isEmpty(param)) { try { param = URLDecoder.decode(param, "utf-8"); JSONObject jsObj = JSON.parseObject(param); Context cxt = mWXSDKInstance.getContext(); if (DEVICE_WIDTH.endsWith(jsObj.getString(WIDTH))) { int width = (int)(WXViewUtils.getScreenWidth(cxt)/WXViewUtils.getScreenDensity(cxt)); mWXSDKInstance.setViewPortWidth(width); mWXSDKInstance.setInstanceViewPortWidth(width); } else { int width = jsObj.getInteger(WIDTH); if (width > 0) { mWXSDKInstance.setViewPortWidth(width); mWXSDKInstance.setInstanceViewPortWidth(width); } } } catch (Exception e) { WXLogUtils.e("[WXModalUIModule] alert param parse error ", e); } } } @JSMethod(uiThread = false) void setViewport(String param); static final String WIDTH; static final String DEVICE_WIDTH; } | @Test public void setViewport() throws Exception { JSONObject jsonObject = new JSONObject(); jsonObject.put(WXMetaModule.WIDTH,640); mMeta.setViewport(jsonObject.toString()); assertTrue(mMeta.mWXSDKInstance.getInstanceViewPortWidth() == 640); jsonObject.put(WXMetaModule.WIDTH,320.5); mMeta.setViewport(jsonObject.toString()); assertTrue(mMeta.mWXSDKInstance.getInstanceViewPortWidth() == 320); jsonObject.put(WXMetaModule.WIDTH,"-200"); mMeta.setViewport(jsonObject.toString()); assertTrue(mMeta.mWXSDKInstance.getInstanceViewPortWidth() == 320); jsonObject.put(WXMetaModule.WIDTH,"error"); mMeta.setViewport(jsonObject.toString()); assertTrue(mMeta.mWXSDKInstance.getInstanceViewPortWidth() == 320); mMeta.setViewport("ads"); assertTrue(mMeta.mWXSDKInstance.getInstanceViewPortWidth() == 320); } |
WXAttr implements Map<String, Object>,Cloneable { public static String getValue(Map<String, Object> attr) { if (attr == null) { return null; } Object src = attr.get(Constants.Name.VALUE); if (src == null) { src = attr.get("content"); if (src == null) { return null; } } return src.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); } | @Test public void testGetValue() throws Exception { assertEquals(null,WXAttr.getValue(attr)); attr.put(VALUE,"test"); assertEquals("test",WXAttr.getValue(attr)); } |
WXFileUtils { public static String loadAsset(String path, Context context) { if (context == null || TextUtils.isEmpty(path)) { return null; } InputStream inputStream = null; try { inputStream = context.getAssets().open(path); return readStreamToString(inputStream); } catch (IOException e) { e.printStackTrace(); } return ""; } static String loadFileOrAsset(String path, Context context); static String loadAsset(String path, Context context); static boolean saveFile(String path, byte[] content, Context context); } | @Test public void testLoadFileContent() throws Exception { File folder = new File("build/intermediates/bundles/debug/assets/"); if(!folder.exists()){ folder = new File("build/intermediates/bundles/debug/assets/"); folder.mkdirs(); } File file = new File(folder,"test"); System.out.println(file.getAbsolutePath()); if(!file.exists()){ file.createNewFile(); } WXFileUtils.loadAsset("test", RuntimeEnvironment.application); } |
WXFileUtils { public static boolean saveFile(String path, byte[] content, Context context) { if (TextUtils.isEmpty(path) || content == null || context == null) { return false; } FileOutputStream outStream = null; try { outStream = new FileOutputStream(path); outStream.write(content); return true; } catch (Exception e) { WXLogUtils.e("WXFileUtils saveFile: " + WXLogUtils.getStackTrace(e)); } finally { if (outStream != null) { try { outStream.close(); } catch (IOException e) { e.printStackTrace(); } } } return false; } static String loadFileOrAsset(String path, Context context); static String loadAsset(String path, Context context); static boolean saveFile(String path, byte[] content, Context context); } | @Test public void testSaveFile() throws Exception { WXFileUtils.saveFile("build/test","test".getBytes(),RuntimeEnvironment.application); } |
WXAttr implements Map<String, Object>,Cloneable { public WXImageQuality getImageQuality() { Object obj = containsKey(Name.QUALITY) ? get(Name.QUALITY) : get(Name.IMAGE_QUALITY); WXImageQuality imageQuality = WXImageQuality.AUTO; String value; if (obj != null && !TextUtils.isEmpty(value = obj.toString())) { try { imageQuality = WXImageQuality.valueOf(value.toUpperCase(Locale.US)); }catch (IllegalArgumentException e){ WXLogUtils.e("Image", "Invalid value image quality. Only low, normal, high, original are valid"); } } return imageQuality; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); } | @Test public void testGetImageQuality() throws Exception { assertEquals(WXImageQuality.AUTO,attr.getImageQuality()); attr.put(IMAGE_QUALITY,HIGH); assertEquals(WXImageQuality.HIGH,attr.getImageQuality()); } |
WXUtils { public static float getFloat(Object value) { return getFloat(value, Float.NaN); } static boolean isUiThread(); static boolean isUndefined(float value); static float getFloatByViewport(Object value, int viewport); static float getFloat(Object value); static Float getFloat(Object value, @Nullable Float df); static float fastGetFloat(String raw, int precision); static float fastGetFloat(String raw); static int getInt(Object value); static Integer getInteger(@Nullable Object value, @Nullable Integer df); @Deprecated static long getLong(Object value); @Deprecated static double getDouble(Object value); static boolean isTabletDevice(); static Boolean getBoolean(@Nullable Object value, @Nullable Boolean df); static long getAvailMemory(Context context); static String getString(@Nullable Object value,@Nullable String df); static int parseUnitOrPercent(String raw, int unit); static String getBundleBanner(String content); static final char PERCENT; } | @Test public void testGetFloat() throws Exception { float test_float = WXUtils.getFloat("12324.9px"); assertEquals(12324.9, test_float, 0.01); assertEquals(WXUtils.fastGetFloat("1.2345",2), 1.23f); } |
WXAttr implements Map<String, Object>,Cloneable { public WXImageSharpen getImageSharpen() { Object obj = get(Constants.Name.SHARPEN); if (obj == null) { obj = get(Constants.Name.IMAGE_SHARPEN); } if (obj == null) { return WXImageSharpen.UNSHARPEN; } String imageSharpen = obj.toString(); WXImageSharpen waImageSharpen = WXImageSharpen.UNSHARPEN; if (imageSharpen.equals("sharpen")) { waImageSharpen = WXImageSharpen.SHARPEN; } return waImageSharpen; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); } | @Test public void testGetImageSharpen() throws Exception { assertEquals(WXImageSharpen.UNSHARPEN,attr.getImageSharpen()); } |
WXUtils { public static int getInt(Object value) { return getInteger(value, 0); } static boolean isUiThread(); static boolean isUndefined(float value); static float getFloatByViewport(Object value, int viewport); static float getFloat(Object value); static Float getFloat(Object value, @Nullable Float df); static float fastGetFloat(String raw, int precision); static float fastGetFloat(String raw); static int getInt(Object value); static Integer getInteger(@Nullable Object value, @Nullable Integer df); @Deprecated static long getLong(Object value); @Deprecated static double getDouble(Object value); static boolean isTabletDevice(); static Boolean getBoolean(@Nullable Object value, @Nullable Boolean df); static long getAvailMemory(Context context); static String getString(@Nullable Object value,@Nullable String df); static int parseUnitOrPercent(String raw, int unit); static String getBundleBanner(String content); static final char PERCENT; } | @Test public void testGetInt() throws Exception { int test_int = WXUtils.getInt("23px"); assertEquals(23, test_int); }
@Test public void testGetIntWX() throws Exception { Integer test_int = WXUtils.getInt("100wx"); Integer want = (int)(100 * TEST_DENSITY * 750 / TEST_SCREEN_WIDTH); assertEquals(test_int, want); test_int = WXUtils.getInt("100px"); want = 100; assertEquals(test_int, want); test_int = WXUtils.getInt("100"); want = 100; assertEquals(test_int, want); test_int = WXUtils.getInt(100); want = 100; assertEquals(test_int, want); test_int = WXUtils.getInt(100.1); want = 0; assertEquals(test_int, want); } |
WXUtils { @Deprecated public static long getLong(Object value) { if (value == null) { return 0; } long result = 0; String temp = value.toString().trim(); if (temp.endsWith("wx")) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.w("the value of " + value + " use wx unit, which will be not supported soon after."); } try { return (long)transferWx(temp, 750); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Long.parseLong(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Long.parseLong(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return result; } static boolean isUiThread(); static boolean isUndefined(float value); static float getFloatByViewport(Object value, int viewport); static float getFloat(Object value); static Float getFloat(Object value, @Nullable Float df); static float fastGetFloat(String raw, int precision); static float fastGetFloat(String raw); static int getInt(Object value); static Integer getInteger(@Nullable Object value, @Nullable Integer df); @Deprecated static long getLong(Object value); @Deprecated static double getDouble(Object value); static boolean isTabletDevice(); static Boolean getBoolean(@Nullable Object value, @Nullable Boolean df); static long getAvailMemory(Context context); static String getString(@Nullable Object value,@Nullable String df); static int parseUnitOrPercent(String raw, int unit); static String getBundleBanner(String content); static final char PERCENT; } | @Test public void testGetLong() throws Exception { long test_long = WXUtils.getLong("8098px"); assertEquals(8098, test_long); } |
WXUtils { @Deprecated public static double getDouble(Object value) { if (value == null) { return 0; } double result = 0; String temp = value.toString().trim(); if (temp.endsWith("wx")) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.w("the value of " + value + " use wx unit, which will be not supported soon after."); } try { return transferWx(temp, 750); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Double.parseDouble(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Double.parseDouble(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return result; } static boolean isUiThread(); static boolean isUndefined(float value); static float getFloatByViewport(Object value, int viewport); static float getFloat(Object value); static Float getFloat(Object value, @Nullable Float df); static float fastGetFloat(String raw, int precision); static float fastGetFloat(String raw); static int getInt(Object value); static Integer getInteger(@Nullable Object value, @Nullable Integer df); @Deprecated static long getLong(Object value); @Deprecated static double getDouble(Object value); static boolean isTabletDevice(); static Boolean getBoolean(@Nullable Object value, @Nullable Boolean df); static long getAvailMemory(Context context); static String getString(@Nullable Object value,@Nullable String df); static int parseUnitOrPercent(String raw, int unit); static String getBundleBanner(String content); static final char PERCENT; } | @Test public void testGetDouble() throws Exception { double test_Double = WXUtils.getDouble("8098.8989px"); assertEquals(8098.8, test_Double, 0.1); }
@Test public void testGetDoubleWX() throws Exception { Double test_double = WXUtils.getDouble("100.32wx"); Double want = (100.32D * TEST_DENSITY * 750 / TEST_SCREEN_WIDTH); assertEquals(test_double, want, 0.01); test_double = WXUtils.getDouble("100px"); want = 100D; assertEquals(test_double, want, 0.01); test_double = WXUtils.getDouble("100"); want = 100D; assertEquals(test_double, want, 0.01); test_double = WXUtils.getDouble(100); want = 100D; assertEquals(test_double, want, 0.01); test_double = WXUtils.getDouble(100.1); want = 100.1D; assertEquals(test_double, want, 0.01); } |
WXUtils { public static float getFloatByViewport(Object value, int viewport) { if (value == null) { return Float.NaN; } String temp = value.toString().trim(); if (temp.endsWith("wx")) { try { return transferWx(temp, viewport); } catch (NumberFormatException e) { WXLogUtils.e("Argument format error! value is " + value, e); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else if (temp.endsWith("px")) { try { temp = temp.substring(0, temp.indexOf("px")); return Float.parseFloat(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } }else { try { return Float.parseFloat(temp); } catch (NumberFormatException nfe) { WXLogUtils.e("Argument format error! value is " + value, nfe); } catch (Exception e) { WXLogUtils.e("Argument error! value is " + value, e); } } return Float.NaN; } static boolean isUiThread(); static boolean isUndefined(float value); static float getFloatByViewport(Object value, int viewport); static float getFloat(Object value); static Float getFloat(Object value, @Nullable Float df); static float fastGetFloat(String raw, int precision); static float fastGetFloat(String raw); static int getInt(Object value); static Integer getInteger(@Nullable Object value, @Nullable Integer df); @Deprecated static long getLong(Object value); @Deprecated static double getDouble(Object value); static boolean isTabletDevice(); static Boolean getBoolean(@Nullable Object value, @Nullable Boolean df); static long getAvailMemory(Context context); static String getString(@Nullable Object value,@Nullable String df); static int parseUnitOrPercent(String raw, int unit); static String getBundleBanner(String content); static final char PERCENT; } | @Test public void testGetFloatWX() throws Exception { Float test_float = WXUtils.getFloatByViewport("100wx", TEST_VIEW_PORT); Float want = 100 * TEST_DENSITY * TEST_VIEW_PORT / TEST_SCREEN_WIDTH; assertEquals(test_float, want , 0.01); test_float = WXUtils.getFloatByViewport("100px", TEST_VIEW_PORT); want = 100F; assertEquals(test_float, want); test_float = WXUtils.getFloatByViewport("100.2", TEST_VIEW_PORT); want = 100.2F; assertEquals(test_float, want); test_float = WXUtils.getFloatByViewport(100.2F, TEST_VIEW_PORT); want = 100.2F; assertEquals(test_float, want, 0.0001); test_float = WXUtils.getFloatByViewport(100.2D, TEST_VIEW_PORT); want = 100.2F; assertEquals(test_float, want, 0.0001); test_float = WXUtils.getFloatByViewport("NaN", TEST_VIEW_PORT); want = Float.NaN; assertEquals(test_float, want); } |
WXAttr implements Map<String, Object>,Cloneable { public String getImageSrc() { Object src = get(Constants.Name.SRC); if (src == null) { return null; } return src.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); } | @Test public void testGetImageSrc() throws Exception { assertEquals(null,attr.getImageSrc()); attr.put(SRC,"test"); assertEquals("test",attr.getImageSrc()); } |
DefaultUriAdapter implements URIAdapter { @NonNull @Override public Uri rewrite(WXSDKInstance instance, String type, Uri uri) { if (TextUtils.isEmpty(instance.getBundleUrl())) { return uri; } Uri base = Uri.parse(instance.getBundleUrl()); Uri.Builder resultBuilder = uri.buildUpon(); if (uri.isRelative()) { if(uri.getEncodedPath().length() == 0){ return base; } else { resultBuilder = buildRelativeURI(resultBuilder, base, uri); return resultBuilder.build(); } } return uri; } @NonNull @Override Uri rewrite(WXSDKInstance instance, String type, Uri uri); } | @Test public void testRewrite() throws Exception { final String host = "http: final String base = host + "/test/123/"; final String bundleWithSlash = base + "?arg=value"; final String bundle = base + "bundle.js?arg=value"; instance.renderByUrl("", bundle, null, null, 0, 0, WXRenderStrategy.APPEND_ONCE); testRelative(host, base, bundle); instance.renderByUrl("", bundleWithSlash, null, null, 0, 0, WXRenderStrategy.APPEND_ONCE); testRelative(host, base, bundleWithSlash); } |
WXAttr implements Map<String, Object>,Cloneable { public boolean showIndicators() { Object obj = get(Constants.Name.SHOW_INDICATORS); if (obj == null) { return true; } try { return parseBoolean(String.valueOf(obj)); } catch (Exception e) { WXLogUtils.e("[WXAttr] showIndicators:", e); } return true; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); } | @Test public void testShowIndicators() throws Exception { assertEquals(true,attr.showIndicators()); } |
WXAttr implements Map<String, Object>,Cloneable { public boolean autoPlay() { Object obj = get(Constants.Name.AUTO_PLAY); if (obj == null) { return false; } try { return parseBoolean(String.valueOf(obj)); } catch (Exception e) { WXLogUtils.e("[WXAttr] autoPlay:", e); } return false; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); } | @Test public void testAutoPlay() throws Exception { assertEquals(false,attr.autoPlay()); } |
WXAttr implements Map<String, Object>,Cloneable { public String getScope() { Object src = get(Constants.Name.SCOPE); if (src == null) { return null; } return src.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); } | @Test public void testGetScope() throws Exception { assertEquals(null,attr.getScope()); } |
WXAttr implements Map<String, Object>,Cloneable { public String getLoadMoreRetry() { Object src = get(Constants.Name.LOADMORERETRY); if (src == null) { return null; } return src.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); } | @Test public void testGetLoadMoreRetry() throws Exception { assertEquals(null,attr.getLoadMoreRetry()); } |
WXAttr implements Map<String, Object>,Cloneable { public String getLoadMoreOffset() { Object src = get(Constants.Name.LOADMOREOFFSET); if (src == null) { return null; } return src.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); } | @Test public void testGetLoadMoreOffset() throws Exception { assertEquals(null,attr.getLoadMoreOffset()); } |
WXAttr implements Map<String, Object>,Cloneable { public boolean getIsRecycleImage() { Object obj = get(Constants.Name.RECYCLE_IMAGE); if (obj == null) { return true; } try { return parseBoolean(String.valueOf(obj)); } catch (Exception e) { WXLogUtils.e("[WXAttr] recycleImage:", e); } return false; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); } | @Test public void testGetIsRecycleImage() throws Exception { assertEquals(true,attr.getIsRecycleImage()); } |
WXAttr implements Map<String, Object>,Cloneable { public String getScrollDirection() { Object scrollDirection = get("scrollDirection"); if (scrollDirection == null) { return "vertical"; } return scrollDirection.toString(); } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); } | @Test public void testGetScrollDirection() throws Exception { assertEquals("vertical",attr.getScrollDirection()); } |
WXAttr implements Map<String, Object>,Cloneable { public float getElevation(int viewPortW) { Object obj = get(Constants.Name.ELEVATION); float ret = Float.NaN; if (obj != null) { String number = obj.toString(); if (!TextUtils.isEmpty(number)) { ret = WXViewUtils.getRealSubPxByWidth(WXUtils.getFloat(number),viewPortW); } else { ret = 0; } } return ret; } WXAttr(); WXAttr(@NonNull Map<String,Object> standardMap); static String getPrefix(Map<String, Object> attr); static String getSuffix(Map<String, Object> attr); static String getValue(Map<String, Object> attr); WXImageQuality getImageQuality(); WXImageSharpen getImageSharpen(); String getImageSrc(); boolean canRecycled(); boolean showIndicators(); boolean autoPlay(); String getScope(); String getLoadMoreRetry(); String getLoadMoreOffset(); String optString(String key); boolean getIsRecycleImage(); String getScrollDirection(); float getElevation(int viewPortW); float getColumnWidth(); int getColumnCount(); float getColumnGap(); int getLayoutType(); @Override boolean equals(Object o); @Override int hashCode(); @Override void clear(); @Override boolean containsKey(Object key); @Override boolean containsValue(Object value); @NonNull @Override Set<Entry<String, Object>> entrySet(); @Override Object get(Object key); @Override boolean isEmpty(); @NonNull @Override Set<String> keySet(); @Override Object put(String key, Object value); @Override void putAll(Map<? extends String, ?> map); @Override Object remove(Object key); @Override int size(); @NonNull @Override Collection<Object> values(); } | @Test public void testGetElevation() { int elevation = 100, viewPortW = 750; attr.put(Constants.Name.ELEVATION, elevation); assertThat(attr.getElevation(viewPortW), is(WXViewUtils.getRealSubPxByWidth(elevation, viewPortW))); attr.put(Constants.Name.ELEVATION, ""); assertThat(attr.getElevation(viewPortW), is(0f)); attr.put(Constants.Name.ELEVATION, "give me a NAN"); assertThat(attr.getElevation(viewPortW), is(Float.NaN)); } |
WXDomModule extends WXModule { public void callDomMethod(JSONObject task) { if (task == null) { return; } String method = (String) task.get(WXBridgeManager.METHOD); JSONArray args = (JSONArray) task.get(WXBridgeManager.ARGS); callDomMethod(method,args); } WXDomModule(WXSDKInstance instance); void callDomMethod(JSONObject task); Object callDomMethod(String method, JSONArray args); void invokeMethod(String ref, String method, JSONArray args); void postAction(RenderAction action); void postAction(DOMAction action, boolean createContext); static final String CREATE_BODY; static final String UPDATE_ATTRS; static final String UPDATE_STYLE; static final String REMOVE_ELEMENT; static final String ADD_ELEMENT; static final String MOVE_ELEMENT; static final String ADD_EVENT; static final String REMOVE_EVENT; static final String CREATE_FINISH; static final String REFRESH_FINISH; static final String UPDATE_FINISH; static final String SCROLL_TO_ELEMENT; static final String ADD_RULE; static final String GET_COMPONENT_RECT; static final String WXDOM; static final String INVOKE_METHOD; static final String[] METHODS; } | @Test public void testCallDomMethod() throws Exception { module.callDomMethod(null); JSONObject obj = new JSONObject(); for (String m : METHODS) { obj.put(WXBridgeManager.METHOD,m); module.callDomMethod(obj); } obj = new JSONObject(); for (Object[] args:ARGS_CASES ) { JSONArray ary = new JSONArray(); if(args == null){ ary = null; }else { for (Object arg : args ) { ary.add(arg); } } obj.put(WXBridgeManager.ARGS,ary); for (String m : METHODS) { obj.put(WXBridgeManager.METHOD,m); module.callDomMethod(obj); } } } |
WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject { public void parseFromJson(JSONObject map){ if (map == null || map.size() <= 0) { return; } String type = (String) map.get("type"); this.mType = type; this.mRef = (String) map.get("ref"); Object style = map.get("style"); if (style != null && style instanceof JSONObject) { WXStyle styles = new WXStyle(); styles.putAll((JSONObject) style,false); this.mStyles = styles; } Object attr = map.get("attr"); if (attr != null && attr instanceof JSONObject) { WXAttr attrs = new WXAttr((JSONObject) attr); this.mAttributes = attrs; } Object event = map.get("event"); if (event != null && event instanceof JSONArray) { WXEvent events = new WXEvent(); JSONArray eventArray = (JSONArray) event; int count = eventArray.size(); for (int i = 0; i < count; ++i) { events.add(eventArray.getString(i)); } this.mEvents = events; } } void traverseTree(Consumer...consumers); int getViewPortWidth(); void setViewPortWidth(int mViewPortWidth); String getRef(); String getType(); @NonNull WXStyle getStyles(); @NonNull WXAttr getAttrs(); @NonNull WXEvent getEvents(); @NonNull DomContext getDomContext(); void clearEvents(); static void prepareRoot(WXDomObject domObj,float defaultHeight,float defaultWidth); void parseFromJson(JSONObject map); void layoutBefore(); void layoutAfter(); final boolean hasUpdate(); final void markUpdateSeen(); boolean isFixed(); boolean canRecycled(); Object getExtra(); void remove(WXDomObject child); void removeFromDom(WXDomObject child); int index(WXDomObject child); void add(WXDomObject child, int index); @Deprecated void add2Dom(WXDomObject child, int index); WXDomObject getChild(int index); void addEvent(String e); boolean containsEvent(String e); void removeEvent(String e); void updateAttr(Map<String, Object> attrs); void updateStyle(Map<String, Object> styles); void updateStyle(Map<String, Object> styles, boolean byPesudo); int childCount(); void hide(); void show(); boolean isVisible(); @Override WXDomObject clone(); void destroy(); ArrayList<String> getFixedStyleRefs(); void add2FixedDomList(String ref); String dumpDomTree(); static @Nullable WXDomObject parse(JSONObject json, WXSDKInstance wxsdkInstance); static final String CHILDREN; static final String TYPE; static final String TAG; static final String ROOT; static final String TRANSFORM; static final String TRANSFORM_ORIGIN; @Deprecated
public WXDomObject parent; } | @Test public void testParseFromJson() throws Exception { dom.parseFromJson(JSONObject.parseObject("{\"ref\":\"100\",\"type\":\"div\",\"attr\":{},\"style\":{\"backgroundColor\":\"rgb(40,96,144)\",\"fontSize\":40,\"color\":\"#ffffff\",\"paddingRight\":30,\"paddingLeft\":30,\"paddingBottom\":20,\"paddingTop\":20}}")); assertEquals(dom.getRef(),"100"); assertEquals(dom.getType(),"div"); dom.applyStyleToNode(); } |
WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject { public void add(WXDomObject child, int index) { if (child == null || index < -1 || sDestroy.get()) { return; } if (mDomChildren == null) { mDomChildren = new ArrayList<>(); } int count = mDomChildren.size(); index = index >= count ? -1 : index; if (index == -1) { mDomChildren.add(child); super.addChildAt(child, super.getChildCount()); } else { mDomChildren.add(index, child); super.addChildAt(child, index); } child.parent = this; } void traverseTree(Consumer...consumers); int getViewPortWidth(); void setViewPortWidth(int mViewPortWidth); String getRef(); String getType(); @NonNull WXStyle getStyles(); @NonNull WXAttr getAttrs(); @NonNull WXEvent getEvents(); @NonNull DomContext getDomContext(); void clearEvents(); static void prepareRoot(WXDomObject domObj,float defaultHeight,float defaultWidth); void parseFromJson(JSONObject map); void layoutBefore(); void layoutAfter(); final boolean hasUpdate(); final void markUpdateSeen(); boolean isFixed(); boolean canRecycled(); Object getExtra(); void remove(WXDomObject child); void removeFromDom(WXDomObject child); int index(WXDomObject child); void add(WXDomObject child, int index); @Deprecated void add2Dom(WXDomObject child, int index); WXDomObject getChild(int index); void addEvent(String e); boolean containsEvent(String e); void removeEvent(String e); void updateAttr(Map<String, Object> attrs); void updateStyle(Map<String, Object> styles); void updateStyle(Map<String, Object> styles, boolean byPesudo); int childCount(); void hide(); void show(); boolean isVisible(); @Override WXDomObject clone(); void destroy(); ArrayList<String> getFixedStyleRefs(); void add2FixedDomList(String ref); String dumpDomTree(); static @Nullable WXDomObject parse(JSONObject json, WXSDKInstance wxsdkInstance); static final String CHILDREN; static final String TYPE; static final String TAG; static final String ROOT; static final String TRANSFORM; static final String TRANSFORM_ORIGIN; @Deprecated
public WXDomObject parent; } | @Test public void testAdd() throws Exception { JSONObject obj = new JSONObject(); obj.put("ref","100"); obj.put("type","div"); dom.parseFromJson(obj); JSONObject child = new JSONObject(); child.put("ref","101"); child.put("type","test"); WXDomObject childDom = new WXDomObject(); childDom.parseFromJson(child); dom.add(childDom,0); assertEquals(dom.getChildCount(),1); assertEquals(dom.getChild(0),childDom); dom.removeChildAt(0); assertEquals(dom.getChildCount(),0); dom.add(childDom,0); assertEquals(dom.getChildCount(),1); assertEquals(dom.getChild(0),childDom); dom.remove(childDom); } |
WXDomObject extends CSSNode implements Cloneable,ImmutableDomObject { @Override public WXDomObject clone() { if (sDestroy.get()) { return null; } WXDomObject dom = null; try { dom = WXDomObjectFactory.newInstance(mType); copyFields(dom); } catch (Exception e) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.e("WXDomObject clone error: ", e); } } return dom; } void traverseTree(Consumer...consumers); int getViewPortWidth(); void setViewPortWidth(int mViewPortWidth); String getRef(); String getType(); @NonNull WXStyle getStyles(); @NonNull WXAttr getAttrs(); @NonNull WXEvent getEvents(); @NonNull DomContext getDomContext(); void clearEvents(); static void prepareRoot(WXDomObject domObj,float defaultHeight,float defaultWidth); void parseFromJson(JSONObject map); void layoutBefore(); void layoutAfter(); final boolean hasUpdate(); final void markUpdateSeen(); boolean isFixed(); boolean canRecycled(); Object getExtra(); void remove(WXDomObject child); void removeFromDom(WXDomObject child); int index(WXDomObject child); void add(WXDomObject child, int index); @Deprecated void add2Dom(WXDomObject child, int index); WXDomObject getChild(int index); void addEvent(String e); boolean containsEvent(String e); void removeEvent(String e); void updateAttr(Map<String, Object> attrs); void updateStyle(Map<String, Object> styles); void updateStyle(Map<String, Object> styles, boolean byPesudo); int childCount(); void hide(); void show(); boolean isVisible(); @Override WXDomObject clone(); void destroy(); ArrayList<String> getFixedStyleRefs(); void add2FixedDomList(String ref); String dumpDomTree(); static @Nullable WXDomObject parse(JSONObject json, WXSDKInstance wxsdkInstance); static final String CHILDREN; static final String TYPE; static final String TAG; static final String ROOT; static final String TRANSFORM; static final String TRANSFORM_ORIGIN; @Deprecated
public WXDomObject parent; } | @Test public void testClone() throws Exception { JSONObject.parseObject("{\"ref\":\"100\",\"type\":\"div\",\"attr\":{},\"style\":{\"backgroundColor\":\"rgb(40,96,144)\",\"fontSize\":40,\"color\":\"#ffffff\",\"paddingRight\":30,\"paddingLeft\":30,\"paddingBottom\":20,\"paddingTop\":20}}"); JSONObject obj = new JSONObject(); obj.put("ref","101"); obj.put("type","test"); JSONArray event = new JSONArray(); event.add("click"); obj.put("event",event); dom.parseFromJson(obj); WXDomObject clone = dom.clone(); assertEquals(clone.getRef(),"101"); assertEquals(clone.getType(),"test"); } |
WXDomManager { public void removeDomStatement(String instanceId) { if (!WXUtils.isUiThread()) { throw new WXRuntimeException("[WXDomManager] removeDomStatement"); } final DOMActionContextImpl statement = mDomRegistries.remove(instanceId); if (statement != null) { post(new Runnable() { @Override public void run() { statement.destroy(); } }); } } WXDomManager(WXRenderManager renderManager); void sendEmptyMessageDelayed(int what, long delayMillis); void sendMessage(Message msg); void sendMessageDelayed(Message msg, long delay); void removeDomStatement(String instanceId); void post(Runnable task); void destroy(); void executeAction(String instanceId, DOMAction action, boolean createContext); void postAction(String instanceId,DOMAction action, boolean createContext); void postActionDelay(String instanceId,DOMAction action,
boolean createContext, long delay); void postRenderTask(@NonNull String instanceId); } | @Test public void testRemoveDomStatement() throws Exception { dm.removeDomStatement(instance.getInstanceId()); } |
WXBridgeManager implements Callback,BactchExecutor { public static WXBridgeManager getInstance() { if (mBridgeManager == null) { synchronized (WXBridgeManager.class) { if (mBridgeManager == null) { mBridgeManager = new WXBridgeManager(); } } } return mBridgeManager; } private WXBridgeManager(); static WXBridgeManager getInstance(); void stopRemoteDebug(); Object callModuleMethod(String instanceId, String moduleStr, String methodStr, JSONArray args); void restart(); synchronized void setStackTopInstance(final String instanceId); @Override void post(Runnable r); @Override void setInterceptor(Interceptor interceptor); void post(Runnable r, Object token); void sendMessageDelayed(Message message, long delayMillis); void removeMessage(int what,Object obj); Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options); Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options); int callNative(String instanceId, String tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callUpdateFinish(String instanceId, String callback); int callCreateFinish(String instanceId, String callback); int callRefreshFinish(String instanceId, String callback); int callUpdateAttrs(String instanceId, String ref, String task, String callback); int callUpdateStyle(String instanceId, String ref, String task, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); synchronized void initScriptsFramework(String framework); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEventOnNode(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); @Deprecated void callback(String instanceId, String callback,String data); @Deprecated void callback(final String instanceId, final String callback,
final Map<String, Object> data); @Deprecated void callback(final String instanceId, final String callback,
final Object data,boolean keepAlive); void refreshInstance(final String instanceId, final WXRefreshData jsonData); void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg); void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg); void createInstance(final String instanceId, final String template,
final Map<String, Object> options, final String data); void destroyInstance(final String instanceId); @Override boolean handleMessage(Message msg); void invokeExecJS(String instanceId, String namespace, String function,
WXJSObject[] args,boolean logTaskDetail); void registerModules(final Map<String, Object> modules); void registerComponents(final List<Map<String, Object>> components); void execJSService(final String service); void destroy(); void reportJSException(String instanceId, String function,
String exception); @Deprecated void notifyTrimMemory(); @Nullable Looper getJSLooper(); void notifySerializeCodeCache(); void takeJSHeapSnapshot(String filename); static final String METHOD_CREATE_INSTANCE; static final String METHOD_DESTROY_INSTANCE; static final String METHOD_CALL_JS; static final String METHOD_SET_TIMEOUT; static final String METHOD_REGISTER_MODULES; static final String METHOD_REGISTER_COMPONENTS; static final String METHOD_FIRE_EVENT; static final String METHOD_CALLBACK; static final String METHOD_REFRESH_INSTANCE; static final String METHOD_NOTIFY_TRIM_MEMORY; static final String METHOD_NOTIFY_SERIALIZE_CODE_CACHE; static final String KEY_METHOD; static final String KEY_ARGS; static final String COMPONENT; static final String REF; static final String MODULE; static final String METHOD; static final String ARGS; } | @Test public void testGetInstance() throws Exception { WXBridgeManager instance = WXBridgeManager.getInstance(); assertNotNull(instance); } |
WXBridgeManager implements Callback,BactchExecutor { public void restart() { mInit = false; initWXBridge(WXEnvironment.sRemoteDebugMode); } private WXBridgeManager(); static WXBridgeManager getInstance(); void stopRemoteDebug(); Object callModuleMethod(String instanceId, String moduleStr, String methodStr, JSONArray args); void restart(); synchronized void setStackTopInstance(final String instanceId); @Override void post(Runnable r); @Override void setInterceptor(Interceptor interceptor); void post(Runnable r, Object token); void sendMessageDelayed(Message message, long delayMillis); void removeMessage(int what,Object obj); Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options); Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options); int callNative(String instanceId, String tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callUpdateFinish(String instanceId, String callback); int callCreateFinish(String instanceId, String callback); int callRefreshFinish(String instanceId, String callback); int callUpdateAttrs(String instanceId, String ref, String task, String callback); int callUpdateStyle(String instanceId, String ref, String task, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); synchronized void initScriptsFramework(String framework); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEventOnNode(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); @Deprecated void callback(String instanceId, String callback,String data); @Deprecated void callback(final String instanceId, final String callback,
final Map<String, Object> data); @Deprecated void callback(final String instanceId, final String callback,
final Object data,boolean keepAlive); void refreshInstance(final String instanceId, final WXRefreshData jsonData); void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg); void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg); void createInstance(final String instanceId, final String template,
final Map<String, Object> options, final String data); void destroyInstance(final String instanceId); @Override boolean handleMessage(Message msg); void invokeExecJS(String instanceId, String namespace, String function,
WXJSObject[] args,boolean logTaskDetail); void registerModules(final Map<String, Object> modules); void registerComponents(final List<Map<String, Object>> components); void execJSService(final String service); void destroy(); void reportJSException(String instanceId, String function,
String exception); @Deprecated void notifyTrimMemory(); @Nullable Looper getJSLooper(); void notifySerializeCodeCache(); void takeJSHeapSnapshot(String filename); static final String METHOD_CREATE_INSTANCE; static final String METHOD_DESTROY_INSTANCE; static final String METHOD_CALL_JS; static final String METHOD_SET_TIMEOUT; static final String METHOD_REGISTER_MODULES; static final String METHOD_REGISTER_COMPONENTS; static final String METHOD_FIRE_EVENT; static final String METHOD_CALLBACK; static final String METHOD_REFRESH_INSTANCE; static final String METHOD_NOTIFY_TRIM_MEMORY; static final String METHOD_NOTIFY_SERIALIZE_CODE_CACHE; static final String KEY_METHOD; static final String KEY_ARGS; static final String COMPONENT; static final String REF; static final String MODULE; static final String METHOD; static final String ARGS; } | @Test public void testRestart() throws Exception { getInstance().restart(); } |
WXBridgeManager implements Callback,BactchExecutor { public synchronized void setStackTopInstance(final String instanceId) { post(new Runnable() { @Override public void run() { mNextTickTasks.setStackTopInstance(instanceId); } }, instanceId); } private WXBridgeManager(); static WXBridgeManager getInstance(); void stopRemoteDebug(); Object callModuleMethod(String instanceId, String moduleStr, String methodStr, JSONArray args); void restart(); synchronized void setStackTopInstance(final String instanceId); @Override void post(Runnable r); @Override void setInterceptor(Interceptor interceptor); void post(Runnable r, Object token); void sendMessageDelayed(Message message, long delayMillis); void removeMessage(int what,Object obj); Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options); Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options); int callNative(String instanceId, String tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callUpdateFinish(String instanceId, String callback); int callCreateFinish(String instanceId, String callback); int callRefreshFinish(String instanceId, String callback); int callUpdateAttrs(String instanceId, String ref, String task, String callback); int callUpdateStyle(String instanceId, String ref, String task, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); synchronized void initScriptsFramework(String framework); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEventOnNode(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); @Deprecated void callback(String instanceId, String callback,String data); @Deprecated void callback(final String instanceId, final String callback,
final Map<String, Object> data); @Deprecated void callback(final String instanceId, final String callback,
final Object data,boolean keepAlive); void refreshInstance(final String instanceId, final WXRefreshData jsonData); void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg); void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg); void createInstance(final String instanceId, final String template,
final Map<String, Object> options, final String data); void destroyInstance(final String instanceId); @Override boolean handleMessage(Message msg); void invokeExecJS(String instanceId, String namespace, String function,
WXJSObject[] args,boolean logTaskDetail); void registerModules(final Map<String, Object> modules); void registerComponents(final List<Map<String, Object>> components); void execJSService(final String service); void destroy(); void reportJSException(String instanceId, String function,
String exception); @Deprecated void notifyTrimMemory(); @Nullable Looper getJSLooper(); void notifySerializeCodeCache(); void takeJSHeapSnapshot(String filename); static final String METHOD_CREATE_INSTANCE; static final String METHOD_DESTROY_INSTANCE; static final String METHOD_CALL_JS; static final String METHOD_SET_TIMEOUT; static final String METHOD_REGISTER_MODULES; static final String METHOD_REGISTER_COMPONENTS; static final String METHOD_FIRE_EVENT; static final String METHOD_CALLBACK; static final String METHOD_REFRESH_INSTANCE; static final String METHOD_NOTIFY_TRIM_MEMORY; static final String METHOD_NOTIFY_SERIALIZE_CODE_CACHE; static final String KEY_METHOD; static final String KEY_ARGS; static final String COMPONENT; static final String REF; static final String MODULE; static final String METHOD; static final String ARGS; } | @Test public void testSetStackTopInstance() throws Exception { getInstance().setStackTopInstance(""); } |
WXBridgeManager implements Callback,BactchExecutor { public int callNative(String instanceId, String tasks, String callback) { if (TextUtils.isEmpty(tasks)) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.e("[WXBridgeManager] callNative: call Native tasks is null"); } commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_INVOKE_NATIVE,"[WXBridgeManager] callNative: call Native tasks is null"); return IWXBridge.INSTANCE_RENDERING_ERROR; } if (WXEnvironment.isApkDebugable()) { mLodBuilder.append("[WXBridgeManager] callNative >>>> instanceId:").append(instanceId) .append(", tasks:").append(tasks).append(", callback:").append(callback); WXLogUtils.d(mLodBuilder.substring(0)); mLodBuilder.setLength(0); } if(mDestroyedInstanceId!=null &&mDestroyedInstanceId.contains(instanceId)){ return IWXBridge.DESTROY_INSTANCE; } long start = System.currentTimeMillis(); JSONArray array = JSON.parseArray(tasks); if(WXSDKManager.getInstance().getSDKInstance(instanceId)!=null) { WXSDKManager.getInstance().getSDKInstance(instanceId).jsonParseTime(System.currentTimeMillis() - start); } int size = array.size(); if (size > 0) { try { JSONObject task; for (int i = 0; i < size; ++i) { task = (JSONObject) array.get(i); if (task != null && WXSDKManager.getInstance().getSDKInstance(instanceId) != null) { Object target = task.get(MODULE); if(target != null){ if(WXDomModule.WXDOM.equals(target)){ WXDomModule dom = getDomModule(instanceId); dom.callDomMethod(task); }else { callModuleMethod(instanceId, (String) target, (String) task.get(METHOD), (JSONArray) task.get(ARGS)); } }else if(task.get(COMPONENT) != null){ WXDomModule dom = getDomModule(instanceId); dom.invokeMethod((String) task.get(REF),(String) task.get(METHOD),(JSONArray) task.get(ARGS)); }else{ throw new IllegalArgumentException("unknown callNative"); } } } } catch (Exception e) { WXLogUtils.e("[WXBridgeManager] callNative exception: ", e); commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_INVOKE_NATIVE,"[WXBridgeManager] callNative exception "+e.getCause()); } } if (UNDEFINED.equals(callback) || NON_CALLBACK.equals(callback)) { return IWXBridge.INSTANCE_RENDERING_ERROR; } getNextTick(instanceId, callback); return IWXBridge.INSTANCE_RENDERING; } private WXBridgeManager(); static WXBridgeManager getInstance(); void stopRemoteDebug(); Object callModuleMethod(String instanceId, String moduleStr, String methodStr, JSONArray args); void restart(); synchronized void setStackTopInstance(final String instanceId); @Override void post(Runnable r); @Override void setInterceptor(Interceptor interceptor); void post(Runnable r, Object token); void sendMessageDelayed(Message message, long delayMillis); void removeMessage(int what,Object obj); Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options); Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options); int callNative(String instanceId, String tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callUpdateFinish(String instanceId, String callback); int callCreateFinish(String instanceId, String callback); int callRefreshFinish(String instanceId, String callback); int callUpdateAttrs(String instanceId, String ref, String task, String callback); int callUpdateStyle(String instanceId, String ref, String task, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); synchronized void initScriptsFramework(String framework); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEventOnNode(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); @Deprecated void callback(String instanceId, String callback,String data); @Deprecated void callback(final String instanceId, final String callback,
final Map<String, Object> data); @Deprecated void callback(final String instanceId, final String callback,
final Object data,boolean keepAlive); void refreshInstance(final String instanceId, final WXRefreshData jsonData); void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg); void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg); void createInstance(final String instanceId, final String template,
final Map<String, Object> options, final String data); void destroyInstance(final String instanceId); @Override boolean handleMessage(Message msg); void invokeExecJS(String instanceId, String namespace, String function,
WXJSObject[] args,boolean logTaskDetail); void registerModules(final Map<String, Object> modules); void registerComponents(final List<Map<String, Object>> components); void execJSService(final String service); void destroy(); void reportJSException(String instanceId, String function,
String exception); @Deprecated void notifyTrimMemory(); @Nullable Looper getJSLooper(); void notifySerializeCodeCache(); void takeJSHeapSnapshot(String filename); static final String METHOD_CREATE_INSTANCE; static final String METHOD_DESTROY_INSTANCE; static final String METHOD_CALL_JS; static final String METHOD_SET_TIMEOUT; static final String METHOD_REGISTER_MODULES; static final String METHOD_REGISTER_COMPONENTS; static final String METHOD_FIRE_EVENT; static final String METHOD_CALLBACK; static final String METHOD_REFRESH_INSTANCE; static final String METHOD_NOTIFY_TRIM_MEMORY; static final String METHOD_NOTIFY_SERIALIZE_CODE_CACHE; static final String KEY_METHOD; static final String KEY_ARGS; static final String COMPONENT; static final String REF; static final String MODULE; static final String METHOD; static final String ARGS; } | @Test public void testCallNative() throws Exception { getInstance() .callNative(instance.getInstanceId(), "[{\"module\":\"testModule\",\"method\":\"test\"}]", null); getInstance() .callNative(instance.getInstanceId(), "[{\"module\":\""+WXDomModule.WXDOM+"\",\"method\":\"test\"}]", null); } |
WXBridgeManager implements Callback,BactchExecutor { public synchronized void initScriptsFramework(String framework) { Message msg = mJSHandler.obtainMessage(); msg.obj = framework; msg.what = WXJSBridgeMsgType.INIT_FRAMEWORK; msg.setTarget(mJSHandler); msg.sendToTarget(); } private WXBridgeManager(); static WXBridgeManager getInstance(); void stopRemoteDebug(); Object callModuleMethod(String instanceId, String moduleStr, String methodStr, JSONArray args); void restart(); synchronized void setStackTopInstance(final String instanceId); @Override void post(Runnable r); @Override void setInterceptor(Interceptor interceptor); void post(Runnable r, Object token); void sendMessageDelayed(Message message, long delayMillis); void removeMessage(int what,Object obj); Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options); Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options); int callNative(String instanceId, String tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callUpdateFinish(String instanceId, String callback); int callCreateFinish(String instanceId, String callback); int callRefreshFinish(String instanceId, String callback); int callUpdateAttrs(String instanceId, String ref, String task, String callback); int callUpdateStyle(String instanceId, String ref, String task, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); synchronized void initScriptsFramework(String framework); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEventOnNode(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); @Deprecated void callback(String instanceId, String callback,String data); @Deprecated void callback(final String instanceId, final String callback,
final Map<String, Object> data); @Deprecated void callback(final String instanceId, final String callback,
final Object data,boolean keepAlive); void refreshInstance(final String instanceId, final WXRefreshData jsonData); void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg); void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg); void createInstance(final String instanceId, final String template,
final Map<String, Object> options, final String data); void destroyInstance(final String instanceId); @Override boolean handleMessage(Message msg); void invokeExecJS(String instanceId, String namespace, String function,
WXJSObject[] args,boolean logTaskDetail); void registerModules(final Map<String, Object> modules); void registerComponents(final List<Map<String, Object>> components); void execJSService(final String service); void destroy(); void reportJSException(String instanceId, String function,
String exception); @Deprecated void notifyTrimMemory(); @Nullable Looper getJSLooper(); void notifySerializeCodeCache(); void takeJSHeapSnapshot(String filename); static final String METHOD_CREATE_INSTANCE; static final String METHOD_DESTROY_INSTANCE; static final String METHOD_CALL_JS; static final String METHOD_SET_TIMEOUT; static final String METHOD_REGISTER_MODULES; static final String METHOD_REGISTER_COMPONENTS; static final String METHOD_FIRE_EVENT; static final String METHOD_CALLBACK; static final String METHOD_REFRESH_INSTANCE; static final String METHOD_NOTIFY_TRIM_MEMORY; static final String METHOD_NOTIFY_SERIALIZE_CODE_CACHE; static final String KEY_METHOD; static final String KEY_ARGS; static final String COMPONENT; static final String REF; static final String MODULE; static final String METHOD; static final String ARGS; } | @Test public void testInitScriptsFramework() throws Exception { getInstance().initScriptsFramework(""); } |
WXBridgeManager implements Callback,BactchExecutor { @Deprecated public void fireEvent(final String instanceId, final String ref, final String type, final Map<String, Object> data){ this.fireEvent(instanceId, ref, type, data, null); } private WXBridgeManager(); static WXBridgeManager getInstance(); void stopRemoteDebug(); Object callModuleMethod(String instanceId, String moduleStr, String methodStr, JSONArray args); void restart(); synchronized void setStackTopInstance(final String instanceId); @Override void post(Runnable r); @Override void setInterceptor(Interceptor interceptor); void post(Runnable r, Object token); void sendMessageDelayed(Message message, long delayMillis); void removeMessage(int what,Object obj); Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options); Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options); int callNative(String instanceId, String tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callUpdateFinish(String instanceId, String callback); int callCreateFinish(String instanceId, String callback); int callRefreshFinish(String instanceId, String callback); int callUpdateAttrs(String instanceId, String ref, String task, String callback); int callUpdateStyle(String instanceId, String ref, String task, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); synchronized void initScriptsFramework(String framework); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEventOnNode(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); @Deprecated void callback(String instanceId, String callback,String data); @Deprecated void callback(final String instanceId, final String callback,
final Map<String, Object> data); @Deprecated void callback(final String instanceId, final String callback,
final Object data,boolean keepAlive); void refreshInstance(final String instanceId, final WXRefreshData jsonData); void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg); void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg); void createInstance(final String instanceId, final String template,
final Map<String, Object> options, final String data); void destroyInstance(final String instanceId); @Override boolean handleMessage(Message msg); void invokeExecJS(String instanceId, String namespace, String function,
WXJSObject[] args,boolean logTaskDetail); void registerModules(final Map<String, Object> modules); void registerComponents(final List<Map<String, Object>> components); void execJSService(final String service); void destroy(); void reportJSException(String instanceId, String function,
String exception); @Deprecated void notifyTrimMemory(); @Nullable Looper getJSLooper(); void notifySerializeCodeCache(); void takeJSHeapSnapshot(String filename); static final String METHOD_CREATE_INSTANCE; static final String METHOD_DESTROY_INSTANCE; static final String METHOD_CALL_JS; static final String METHOD_SET_TIMEOUT; static final String METHOD_REGISTER_MODULES; static final String METHOD_REGISTER_COMPONENTS; static final String METHOD_FIRE_EVENT; static final String METHOD_CALLBACK; static final String METHOD_REFRESH_INSTANCE; static final String METHOD_NOTIFY_TRIM_MEMORY; static final String METHOD_NOTIFY_SERIALIZE_CODE_CACHE; static final String KEY_METHOD; static final String KEY_ARGS; static final String COMPONENT; static final String REF; static final String MODULE; static final String METHOD; static final String ARGS; } | @Test public void testFireEvent() throws Exception { getInstance().fireEvent(instance.getInstanceId(),"100", Constants.Event.CLICK,null,null); } |
WXBridgeManager implements Callback,BactchExecutor { @Deprecated public void callback(String instanceId, String callback,String data) { callback(instanceId, callback,data,false); } private WXBridgeManager(); static WXBridgeManager getInstance(); void stopRemoteDebug(); Object callModuleMethod(String instanceId, String moduleStr, String methodStr, JSONArray args); void restart(); synchronized void setStackTopInstance(final String instanceId); @Override void post(Runnable r); @Override void setInterceptor(Interceptor interceptor); void post(Runnable r, Object token); void sendMessageDelayed(Message message, long delayMillis); void removeMessage(int what,Object obj); Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options); Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options); int callNative(String instanceId, String tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callUpdateFinish(String instanceId, String callback); int callCreateFinish(String instanceId, String callback); int callRefreshFinish(String instanceId, String callback); int callUpdateAttrs(String instanceId, String ref, String task, String callback); int callUpdateStyle(String instanceId, String ref, String task, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); synchronized void initScriptsFramework(String framework); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEventOnNode(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); @Deprecated void callback(String instanceId, String callback,String data); @Deprecated void callback(final String instanceId, final String callback,
final Map<String, Object> data); @Deprecated void callback(final String instanceId, final String callback,
final Object data,boolean keepAlive); void refreshInstance(final String instanceId, final WXRefreshData jsonData); void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg); void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg); void createInstance(final String instanceId, final String template,
final Map<String, Object> options, final String data); void destroyInstance(final String instanceId); @Override boolean handleMessage(Message msg); void invokeExecJS(String instanceId, String namespace, String function,
WXJSObject[] args,boolean logTaskDetail); void registerModules(final Map<String, Object> modules); void registerComponents(final List<Map<String, Object>> components); void execJSService(final String service); void destroy(); void reportJSException(String instanceId, String function,
String exception); @Deprecated void notifyTrimMemory(); @Nullable Looper getJSLooper(); void notifySerializeCodeCache(); void takeJSHeapSnapshot(String filename); static final String METHOD_CREATE_INSTANCE; static final String METHOD_DESTROY_INSTANCE; static final String METHOD_CALL_JS; static final String METHOD_SET_TIMEOUT; static final String METHOD_REGISTER_MODULES; static final String METHOD_REGISTER_COMPONENTS; static final String METHOD_FIRE_EVENT; static final String METHOD_CALLBACK; static final String METHOD_REFRESH_INSTANCE; static final String METHOD_NOTIFY_TRIM_MEMORY; static final String METHOD_NOTIFY_SERIALIZE_CODE_CACHE; static final String KEY_METHOD; static final String KEY_ARGS; static final String COMPONENT; static final String REF; static final String MODULE; static final String METHOD; static final String ARGS; } | @Test public void testCallback() throws Exception { getInstance().callbackJavascript(instance.getInstanceId(),"test",null,false); } |
WXBridgeManager implements Callback,BactchExecutor { public void refreshInstance(final String instanceId, final WXRefreshData jsonData) { if (TextUtils.isEmpty(instanceId) || jsonData == null) { return; } mJSHandler.postDelayed(WXThread.secure(new Runnable() { @Override public void run() { invokeRefreshInstance(instanceId, jsonData); } }), 0); } private WXBridgeManager(); static WXBridgeManager getInstance(); void stopRemoteDebug(); Object callModuleMethod(String instanceId, String moduleStr, String methodStr, JSONArray args); void restart(); synchronized void setStackTopInstance(final String instanceId); @Override void post(Runnable r); @Override void setInterceptor(Interceptor interceptor); void post(Runnable r, Object token); void sendMessageDelayed(Message message, long delayMillis); void removeMessage(int what,Object obj); Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options); Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options); int callNative(String instanceId, String tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callUpdateFinish(String instanceId, String callback); int callCreateFinish(String instanceId, String callback); int callRefreshFinish(String instanceId, String callback); int callUpdateAttrs(String instanceId, String ref, String task, String callback); int callUpdateStyle(String instanceId, String ref, String task, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); synchronized void initScriptsFramework(String framework); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEventOnNode(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); @Deprecated void callback(String instanceId, String callback,String data); @Deprecated void callback(final String instanceId, final String callback,
final Map<String, Object> data); @Deprecated void callback(final String instanceId, final String callback,
final Object data,boolean keepAlive); void refreshInstance(final String instanceId, final WXRefreshData jsonData); void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg); void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg); void createInstance(final String instanceId, final String template,
final Map<String, Object> options, final String data); void destroyInstance(final String instanceId); @Override boolean handleMessage(Message msg); void invokeExecJS(String instanceId, String namespace, String function,
WXJSObject[] args,boolean logTaskDetail); void registerModules(final Map<String, Object> modules); void registerComponents(final List<Map<String, Object>> components); void execJSService(final String service); void destroy(); void reportJSException(String instanceId, String function,
String exception); @Deprecated void notifyTrimMemory(); @Nullable Looper getJSLooper(); void notifySerializeCodeCache(); void takeJSHeapSnapshot(String filename); static final String METHOD_CREATE_INSTANCE; static final String METHOD_DESTROY_INSTANCE; static final String METHOD_CALL_JS; static final String METHOD_SET_TIMEOUT; static final String METHOD_REGISTER_MODULES; static final String METHOD_REGISTER_COMPONENTS; static final String METHOD_FIRE_EVENT; static final String METHOD_CALLBACK; static final String METHOD_REFRESH_INSTANCE; static final String METHOD_NOTIFY_TRIM_MEMORY; static final String METHOD_NOTIFY_SERIALIZE_CODE_CACHE; static final String KEY_METHOD; static final String KEY_ARGS; static final String COMPONENT; static final String REF; static final String MODULE; static final String METHOD; static final String ARGS; } | @Test public void testRefreshInstance() throws Exception { getInstance().refreshInstance(instance.getInstanceId(),null); } |
WXBridgeManager implements Callback,BactchExecutor { public void createInstance(final String instanceId, final String template, final Map<String, Object> options, final String data) { final WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(instanceId); if(instance == null){ WXLogUtils.e("WXBridgeManager","createInstance failed, SDKInstance is not exist"); return; } if ( TextUtils.isEmpty(instanceId) || TextUtils.isEmpty(template) || mJSHandler == null) { instance.onRenderError(WXRenderErrorCode.WX_CREATE_INSTANCE_ERROR, "createInstance fail!"); return; } WXModuleManager.createDomModule(instance); post(new Runnable() { @Override public void run() { long start = System.currentTimeMillis(); invokeCreateInstance(instance, template, options, data); final long totalTime = System.currentTimeMillis() - start; WXSDKManager.getInstance().postOnUiThread(new Runnable() { @Override public void run() { instance.createInstanceFinished(totalTime); } }, 0); } }, instanceId); } private WXBridgeManager(); static WXBridgeManager getInstance(); void stopRemoteDebug(); Object callModuleMethod(String instanceId, String moduleStr, String methodStr, JSONArray args); void restart(); synchronized void setStackTopInstance(final String instanceId); @Override void post(Runnable r); @Override void setInterceptor(Interceptor interceptor); void post(Runnable r, Object token); void sendMessageDelayed(Message message, long delayMillis); void removeMessage(int what,Object obj); Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options); Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options); int callNative(String instanceId, String tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callUpdateFinish(String instanceId, String callback); int callCreateFinish(String instanceId, String callback); int callRefreshFinish(String instanceId, String callback); int callUpdateAttrs(String instanceId, String ref, String task, String callback); int callUpdateStyle(String instanceId, String ref, String task, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); synchronized void initScriptsFramework(String framework); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEventOnNode(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); @Deprecated void callback(String instanceId, String callback,String data); @Deprecated void callback(final String instanceId, final String callback,
final Map<String, Object> data); @Deprecated void callback(final String instanceId, final String callback,
final Object data,boolean keepAlive); void refreshInstance(final String instanceId, final WXRefreshData jsonData); void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg); void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg); void createInstance(final String instanceId, final String template,
final Map<String, Object> options, final String data); void destroyInstance(final String instanceId); @Override boolean handleMessage(Message msg); void invokeExecJS(String instanceId, String namespace, String function,
WXJSObject[] args,boolean logTaskDetail); void registerModules(final Map<String, Object> modules); void registerComponents(final List<Map<String, Object>> components); void execJSService(final String service); void destroy(); void reportJSException(String instanceId, String function,
String exception); @Deprecated void notifyTrimMemory(); @Nullable Looper getJSLooper(); void notifySerializeCodeCache(); void takeJSHeapSnapshot(String filename); static final String METHOD_CREATE_INSTANCE; static final String METHOD_DESTROY_INSTANCE; static final String METHOD_CALL_JS; static final String METHOD_SET_TIMEOUT; static final String METHOD_REGISTER_MODULES; static final String METHOD_REGISTER_COMPONENTS; static final String METHOD_FIRE_EVENT; static final String METHOD_CALLBACK; static final String METHOD_REFRESH_INSTANCE; static final String METHOD_NOTIFY_TRIM_MEMORY; static final String METHOD_NOTIFY_SERIALIZE_CODE_CACHE; static final String KEY_METHOD; static final String KEY_ARGS; static final String COMPONENT; static final String REF; static final String MODULE; static final String METHOD; static final String ARGS; } | @Test public void testCreateInstance() throws Exception { getInstance().createInstance(instance.getInstanceId(),"",null,null); } |
WXBridgeManager implements Callback,BactchExecutor { public void destroyInstance(final String instanceId) { if ( mJSHandler == null || TextUtils.isEmpty(instanceId)) { return; } if(mDestroyedInstanceId!=null) { mDestroyedInstanceId.add(instanceId); } mJSHandler.removeCallbacksAndMessages(instanceId); post(new Runnable() { @Override public void run() { removeTaskByInstance(instanceId); invokeDestroyInstance(instanceId); } }, instanceId); } private WXBridgeManager(); static WXBridgeManager getInstance(); void stopRemoteDebug(); Object callModuleMethod(String instanceId, String moduleStr, String methodStr, JSONArray args); void restart(); synchronized void setStackTopInstance(final String instanceId); @Override void post(Runnable r); @Override void setInterceptor(Interceptor interceptor); void post(Runnable r, Object token); void sendMessageDelayed(Message message, long delayMillis); void removeMessage(int what,Object obj); Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options); Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options); int callNative(String instanceId, String tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callUpdateFinish(String instanceId, String callback); int callCreateFinish(String instanceId, String callback); int callRefreshFinish(String instanceId, String callback); int callUpdateAttrs(String instanceId, String ref, String task, String callback); int callUpdateStyle(String instanceId, String ref, String task, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); synchronized void initScriptsFramework(String framework); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEventOnNode(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); @Deprecated void callback(String instanceId, String callback,String data); @Deprecated void callback(final String instanceId, final String callback,
final Map<String, Object> data); @Deprecated void callback(final String instanceId, final String callback,
final Object data,boolean keepAlive); void refreshInstance(final String instanceId, final WXRefreshData jsonData); void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg); void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg); void createInstance(final String instanceId, final String template,
final Map<String, Object> options, final String data); void destroyInstance(final String instanceId); @Override boolean handleMessage(Message msg); void invokeExecJS(String instanceId, String namespace, String function,
WXJSObject[] args,boolean logTaskDetail); void registerModules(final Map<String, Object> modules); void registerComponents(final List<Map<String, Object>> components); void execJSService(final String service); void destroy(); void reportJSException(String instanceId, String function,
String exception); @Deprecated void notifyTrimMemory(); @Nullable Looper getJSLooper(); void notifySerializeCodeCache(); void takeJSHeapSnapshot(String filename); static final String METHOD_CREATE_INSTANCE; static final String METHOD_DESTROY_INSTANCE; static final String METHOD_CALL_JS; static final String METHOD_SET_TIMEOUT; static final String METHOD_REGISTER_MODULES; static final String METHOD_REGISTER_COMPONENTS; static final String METHOD_FIRE_EVENT; static final String METHOD_CALLBACK; static final String METHOD_REFRESH_INSTANCE; static final String METHOD_NOTIFY_TRIM_MEMORY; static final String METHOD_NOTIFY_SERIALIZE_CODE_CACHE; static final String KEY_METHOD; static final String KEY_ARGS; static final String COMPONENT; static final String REF; static final String MODULE; static final String METHOD; static final String ARGS; } | @Test public void testDestroyInstance() throws Exception { getInstance().destroyInstance(instance.getInstanceId()); } |
WXBridgeManager implements Callback,BactchExecutor { @Override public boolean handleMessage(Message msg) { if (msg == null) { return false; } int what = msg.what; switch (what) { case WXJSBridgeMsgType.INIT_FRAMEWORK: invokeInitFramework(msg); break; case WXJSBridgeMsgType.CALL_JS_BATCH: invokeCallJSBatch(msg); break; case WXJSBridgeMsgType.SET_TIMEOUT: TimerInfo timerInfo = (TimerInfo) msg.obj; if(timerInfo == null){ break; } WXJSObject obj = new WXJSObject(WXJSObject.String, timerInfo.callbackId); WXJSObject[] args = {obj}; invokeExecJS("", null, METHOD_SET_TIMEOUT, args); break; case WXJSBridgeMsgType.TAKE_HEAP_SNAPSHOT: if (msg.obj != null) { String filename = (String) msg.obj; mWXBridge.takeHeapSnapshot(filename); } break; default: break; } return false; } private WXBridgeManager(); static WXBridgeManager getInstance(); void stopRemoteDebug(); Object callModuleMethod(String instanceId, String moduleStr, String methodStr, JSONArray args); void restart(); synchronized void setStackTopInstance(final String instanceId); @Override void post(Runnable r); @Override void setInterceptor(Interceptor interceptor); void post(Runnable r, Object token); void sendMessageDelayed(Message message, long delayMillis); void removeMessage(int what,Object obj); Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options); Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options); int callNative(String instanceId, String tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callUpdateFinish(String instanceId, String callback); int callCreateFinish(String instanceId, String callback); int callRefreshFinish(String instanceId, String callback); int callUpdateAttrs(String instanceId, String ref, String task, String callback); int callUpdateStyle(String instanceId, String ref, String task, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); synchronized void initScriptsFramework(String framework); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEventOnNode(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); @Deprecated void callback(String instanceId, String callback,String data); @Deprecated void callback(final String instanceId, final String callback,
final Map<String, Object> data); @Deprecated void callback(final String instanceId, final String callback,
final Object data,boolean keepAlive); void refreshInstance(final String instanceId, final WXRefreshData jsonData); void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg); void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg); void createInstance(final String instanceId, final String template,
final Map<String, Object> options, final String data); void destroyInstance(final String instanceId); @Override boolean handleMessage(Message msg); void invokeExecJS(String instanceId, String namespace, String function,
WXJSObject[] args,boolean logTaskDetail); void registerModules(final Map<String, Object> modules); void registerComponents(final List<Map<String, Object>> components); void execJSService(final String service); void destroy(); void reportJSException(String instanceId, String function,
String exception); @Deprecated void notifyTrimMemory(); @Nullable Looper getJSLooper(); void notifySerializeCodeCache(); void takeJSHeapSnapshot(String filename); static final String METHOD_CREATE_INSTANCE; static final String METHOD_DESTROY_INSTANCE; static final String METHOD_CALL_JS; static final String METHOD_SET_TIMEOUT; static final String METHOD_REGISTER_MODULES; static final String METHOD_REGISTER_COMPONENTS; static final String METHOD_FIRE_EVENT; static final String METHOD_CALLBACK; static final String METHOD_REFRESH_INSTANCE; static final String METHOD_NOTIFY_TRIM_MEMORY; static final String METHOD_NOTIFY_SERIALIZE_CODE_CACHE; static final String KEY_METHOD; static final String KEY_ARGS; static final String COMPONENT; static final String REF; static final String MODULE; static final String METHOD; static final String ARGS; } | @Test public void testHandleMessage() throws Exception { int[] msgs = { WXJSBridgeMsgType.INIT_FRAMEWORK, WXJSBridgeMsgType.CALL_JS_BATCH, WXJSBridgeMsgType.SET_TIMEOUT, WXJSBridgeMsgType.MODULE_INTERVAL, WXJSBridgeMsgType.MODULE_TIMEOUT }; Message msg = new Message(); for(int w:msgs) { msg.what = w; getInstance().handleMessage(msg); } } |
WXBridgeManager implements Callback,BactchExecutor { public void reportJSException(String instanceId, String function, String exception) { if (WXEnvironment.isApkDebugable()) { WXLogUtils.e("reportJSException >>>> instanceId:" + instanceId + ", exception function:" + function + ", exception:" + exception); } WXSDKInstance instance; if (instanceId != null && (instance = WXSDKManager.getInstance().getSDKInstance(instanceId)) != null) { instance.onJSException(WXErrorCode.WX_ERR_JS_EXECUTE.getErrorCode(), function, exception); String err = "function:" + function + "#exception:" + exception; commitJSBridgeAlarmMonitor(instanceId, WXErrorCode.WX_ERR_JS_EXECUTE, err); IWXJSExceptionAdapter adapter = WXSDKManager.getInstance().getIWXJSExceptionAdapter(); if (adapter != null) { WXJSExceptionInfo jsException = new WXJSExceptionInfo(instanceId, instance.getBundleUrl(), WXErrorCode.WX_ERR_JS_EXECUTE.getErrorCode(), function, exception, null); adapter.onJSException(jsException); if (WXEnvironment.isApkDebugable()) { WXLogUtils.d(jsException.toString()); } } } } private WXBridgeManager(); static WXBridgeManager getInstance(); void stopRemoteDebug(); Object callModuleMethod(String instanceId, String moduleStr, String methodStr, JSONArray args); void restart(); synchronized void setStackTopInstance(final String instanceId); @Override void post(Runnable r); @Override void setInterceptor(Interceptor interceptor); void post(Runnable r, Object token); void sendMessageDelayed(Message message, long delayMillis); void removeMessage(int what,Object obj); Object callNativeModule(String instanceId, String module, String method, JSONArray arguments, Object options); Object callNativeComponent(String instanceId, String componentRef, String method, JSONArray arguments, Object options); int callNative(String instanceId, String tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callUpdateFinish(String instanceId, String callback); int callCreateFinish(String instanceId, String callback); int callRefreshFinish(String instanceId, String callback); int callUpdateAttrs(String instanceId, String ref, String task, String callback); int callUpdateStyle(String instanceId, String ref, String task, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); synchronized void initScriptsFramework(String framework); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data); @Deprecated void fireEvent(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEventOnNode(final String instanceId, final String ref,
final String type, final Map<String, Object> data,final Map<String, Object> domChanges); @Deprecated void callback(String instanceId, String callback,String data); @Deprecated void callback(final String instanceId, final String callback,
final Map<String, Object> data); @Deprecated void callback(final String instanceId, final String callback,
final Object data,boolean keepAlive); void refreshInstance(final String instanceId, final WXRefreshData jsonData); void commitJSBridgeAlarmMonitor(String instanceId, WXErrorCode errCode, String errMsg); void commitJSFrameworkAlarmMonitor(final String type, final WXErrorCode errorCode, String errMsg); void createInstance(final String instanceId, final String template,
final Map<String, Object> options, final String data); void destroyInstance(final String instanceId); @Override boolean handleMessage(Message msg); void invokeExecJS(String instanceId, String namespace, String function,
WXJSObject[] args,boolean logTaskDetail); void registerModules(final Map<String, Object> modules); void registerComponents(final List<Map<String, Object>> components); void execJSService(final String service); void destroy(); void reportJSException(String instanceId, String function,
String exception); @Deprecated void notifyTrimMemory(); @Nullable Looper getJSLooper(); void notifySerializeCodeCache(); void takeJSHeapSnapshot(String filename); static final String METHOD_CREATE_INSTANCE; static final String METHOD_DESTROY_INSTANCE; static final String METHOD_CALL_JS; static final String METHOD_SET_TIMEOUT; static final String METHOD_REGISTER_MODULES; static final String METHOD_REGISTER_COMPONENTS; static final String METHOD_FIRE_EVENT; static final String METHOD_CALLBACK; static final String METHOD_REFRESH_INSTANCE; static final String METHOD_NOTIFY_TRIM_MEMORY; static final String METHOD_NOTIFY_SERIALIZE_CODE_CACHE; static final String KEY_METHOD; static final String KEY_ARGS; static final String COMPONENT; static final String REF; static final String MODULE; static final String METHOD; static final String ARGS; } | @Test public void testReportJSException() throws Exception { getInstance().reportJSException(instance.getInstanceId(),"test","test exception"); } |
WXBridge implements IWXBridge { public int callNative(String instanceId, byte [] tasks, String callback) { return callNative(instanceId,new String(tasks),callback); } native int initFramework(String framework, WXParams params); native int execJS(String instanceId, String namespace, String function, WXJSObject[] args); native int execJSService(String javascript); native void takeHeapSnapshot(String filename); int callNative(String instanceId, byte [] tasks, String callback); int callNative(String instanceId, String tasks, String callback); int callAddElement(String instanceId, String ref,byte[] dom,String index, String callback); int callCreateBody(String instanceId, byte [] tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); void reportJSException(String instanceId, String func, String exception); @Override Object callNativeModule(String instanceId, String module, String method, byte [] arguments, byte [] options); @Override void callNativeComponent(String instanceId, String componentRef, String method, byte [] arguments, byte [] options); void setTimeoutNative(String callbackId, String time); void setJSFrmVersion(String version); int callUpdateFinish(String instanceId, byte [] tasks, String callback); int callCreateFinish(String instanceId, byte [] tasks, String callback); int callRefreshFinish(String instanceId, byte [] tasks, String callback); int callUpdateAttrs(String instanceId, String ref, byte [] tasks, String callback); int callUpdateStyle(String instanceId, String ref, byte [] tasks, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); static final String TAG; } | @Test public void testCallNative() throws Exception { bridge.callNative("1","{}","100"); } |
WXBridge implements IWXBridge { public int callAddElement(String instanceId, String ref,byte[] dom,String index, String callback) { return callAddElement(instanceId,ref, new String(dom),index,callback); } native int initFramework(String framework, WXParams params); native int execJS(String instanceId, String namespace, String function, WXJSObject[] args); native int execJSService(String javascript); native void takeHeapSnapshot(String filename); int callNative(String instanceId, byte [] tasks, String callback); int callNative(String instanceId, String tasks, String callback); int callAddElement(String instanceId, String ref,byte[] dom,String index, String callback); int callCreateBody(String instanceId, byte [] tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); void reportJSException(String instanceId, String func, String exception); @Override Object callNativeModule(String instanceId, String module, String method, byte [] arguments, byte [] options); @Override void callNativeComponent(String instanceId, String componentRef, String method, byte [] arguments, byte [] options); void setTimeoutNative(String callbackId, String time); void setJSFrmVersion(String version); int callUpdateFinish(String instanceId, byte [] tasks, String callback); int callCreateFinish(String instanceId, byte [] tasks, String callback); int callRefreshFinish(String instanceId, byte [] tasks, String callback); int callUpdateAttrs(String instanceId, String ref, byte [] tasks, String callback); int callUpdateStyle(String instanceId, String ref, byte [] tasks, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); static final String TAG; } | @Test public void testCallAddElement() throws Exception { bridge.callAddElement("1","1","{}","0","100"); } |
WXBridge implements IWXBridge { public void reportJSException(String instanceId, String func, String exception) { WXBridgeManager.getInstance().reportJSException(instanceId, func, exception); } native int initFramework(String framework, WXParams params); native int execJS(String instanceId, String namespace, String function, WXJSObject[] args); native int execJSService(String javascript); native void takeHeapSnapshot(String filename); int callNative(String instanceId, byte [] tasks, String callback); int callNative(String instanceId, String tasks, String callback); int callAddElement(String instanceId, String ref,byte[] dom,String index, String callback); int callCreateBody(String instanceId, byte [] tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); void reportJSException(String instanceId, String func, String exception); @Override Object callNativeModule(String instanceId, String module, String method, byte [] arguments, byte [] options); @Override void callNativeComponent(String instanceId, String componentRef, String method, byte [] arguments, byte [] options); void setTimeoutNative(String callbackId, String time); void setJSFrmVersion(String version); int callUpdateFinish(String instanceId, byte [] tasks, String callback); int callCreateFinish(String instanceId, byte [] tasks, String callback); int callRefreshFinish(String instanceId, byte [] tasks, String callback); int callUpdateAttrs(String instanceId, String ref, byte [] tasks, String callback); int callUpdateStyle(String instanceId, String ref, byte [] tasks, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); static final String TAG; } | @Test public void testReportJSException() throws Exception { bridge.reportJSException("1","test","some exception"); } |
WXBridge implements IWXBridge { public void setTimeoutNative(String callbackId, String time) { WXBridgeManager.getInstance().setTimeout(callbackId, time); } native int initFramework(String framework, WXParams params); native int execJS(String instanceId, String namespace, String function, WXJSObject[] args); native int execJSService(String javascript); native void takeHeapSnapshot(String filename); int callNative(String instanceId, byte [] tasks, String callback); int callNative(String instanceId, String tasks, String callback); int callAddElement(String instanceId, String ref,byte[] dom,String index, String callback); int callCreateBody(String instanceId, byte [] tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); void reportJSException(String instanceId, String func, String exception); @Override Object callNativeModule(String instanceId, String module, String method, byte [] arguments, byte [] options); @Override void callNativeComponent(String instanceId, String componentRef, String method, byte [] arguments, byte [] options); void setTimeoutNative(String callbackId, String time); void setJSFrmVersion(String version); int callUpdateFinish(String instanceId, byte [] tasks, String callback); int callCreateFinish(String instanceId, byte [] tasks, String callback); int callRefreshFinish(String instanceId, byte [] tasks, String callback); int callUpdateAttrs(String instanceId, String ref, byte [] tasks, String callback); int callUpdateStyle(String instanceId, String ref, byte [] tasks, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); static final String TAG; } | @Test public void testSetTimeoutNative() throws Exception { bridge.setTimeoutNative("100","1024"); } |
WXBridge implements IWXBridge { public void setJSFrmVersion(String version) { if(!TextUtils.isEmpty(version)) { WXEnvironment.JS_LIB_SDK_VERSION = version; } } native int initFramework(String framework, WXParams params); native int execJS(String instanceId, String namespace, String function, WXJSObject[] args); native int execJSService(String javascript); native void takeHeapSnapshot(String filename); int callNative(String instanceId, byte [] tasks, String callback); int callNative(String instanceId, String tasks, String callback); int callAddElement(String instanceId, String ref,byte[] dom,String index, String callback); int callCreateBody(String instanceId, byte [] tasks, String callback); int callCreateBody(String instanceId, String tasks, String callback); int callAddElement(String instanceId, String ref,String dom,String index, String callback); void reportJSException(String instanceId, String func, String exception); @Override Object callNativeModule(String instanceId, String module, String method, byte [] arguments, byte [] options); @Override void callNativeComponent(String instanceId, String componentRef, String method, byte [] arguments, byte [] options); void setTimeoutNative(String callbackId, String time); void setJSFrmVersion(String version); int callUpdateFinish(String instanceId, byte [] tasks, String callback); int callCreateFinish(String instanceId, byte [] tasks, String callback); int callRefreshFinish(String instanceId, byte [] tasks, String callback); int callUpdateAttrs(String instanceId, String ref, byte [] tasks, String callback); int callUpdateStyle(String instanceId, String ref, byte [] tasks, String callback); int callRemoveElement(String instanceId, String ref, String callback); int callMoveElement(String instanceId, String ref, String parentref, String index, String callback); int callAddEvent(String instanceId, String ref, String event, String callback); int callRemoveEvent(String instanceId, String ref, String event, String callback); static final String TAG; } | @Test public void testSetJSFrmVersion() throws Exception { bridge.setJSFrmVersion("v0.1"); } |
WXModuleManager { static Object callModuleMethod(final String instanceId, String moduleStr, String methodStr, JSONArray args) { ModuleFactory factory = sModuleFactoryMap.get(moduleStr); if(factory == null){ WXLogUtils.e("[WXModuleManager] module factory not found."); return null; } final WXModule wxModule = findModule(instanceId, moduleStr,factory); if (wxModule == null) { return null; } WXSDKInstance instance = WXSDKManager.getInstance().getSDKInstance(instanceId); wxModule.mWXSDKInstance = instance; final Invoker invoker = factory.getMethodInvoker(methodStr); try { if(instance != null) { IWXUserTrackAdapter userTrackAdapter = WXSDKManager.getInstance().getIWXUserTrackAdapter(); if(userTrackAdapter != null) { HashMap<String, Serializable> data = new HashMap<String, Serializable>(); data.put(MONITOR_ERROR_CODE, "101"); data.put(MONITOR_ARG, moduleStr + "." + methodStr); data.put(MONITOR_ERROR_MSG, instance.getBundleUrl()); userTrackAdapter.commit(instance.getContext(), null, IWXUserTrackAdapter.INVOKE_MODULE, null, data); } return dispatchCallModuleMethod(instance,wxModule,args,invoker); } else { WXLogUtils.e("callModuleMethod >>> instance is null"); return null; } } catch (Exception e) { WXLogUtils.e("callModuleMethod >>> invoke module:" + moduleStr + ", method:" + methodStr + " failed. ", e); return null; } finally { if (wxModule instanceof WXDomModule || wxModule instanceof WXTimerModule) { wxModule.mWXSDKInstance = null; } } } static boolean registerModule(final String moduleName, final ModuleFactory factory, final boolean global); static void onActivityCreate(String instanceId); static void onActivityStart(String instanceId); static void onActivityPause(String instanceId); static void onActivityResume(String instanceId); static void onActivityStop(String instanceId); static void onActivityDestroy(String instanceId); static boolean onActivityBack(String instanceId); static void onActivityResult(String instanceId,int requestCode, int resultCode, Intent data); static boolean onCreateOptionsMenu(String instanceId,Menu menu); static void onRequestPermissionsResult(String instanceId ,int requestCode, String[] permissions, int[] grantResults); static void destroyInstanceModules(String instanceId); static void createDomModule(WXSDKInstance instance); static void destoryDomModule(String instanceID); static WXDomModule getDomModule(String instanceId); static void reload(); } | @Test public void testCallModuleMethod() throws Exception { WXModuleManager.callModuleMethod(instance.getInstanceId(),"test1","testMethod",null); WXModuleManager.callModuleMethod(instance.getInstanceId(),"test2","testMethod",null); }
@Test public void testCallModuleMethod2() throws Exception { JSONArray args = new JSONArray(); args.add("testarg"); WXModuleManager.callModuleMethod(instance.getInstanceId(),"test1","testMethod",args); }
@Test public void testCallModuleMethod3() throws Exception { JSONArray args = new JSONArray(); args.add("testarg"); args.add(null); WXModuleManager.callModuleMethod(instance.getInstanceId(),"test1","testCallbackMethod",args); }
@Test public void testCallModuleMethod4() throws Exception { JSONArray args = new JSONArray(); args.add("testarg"); args.add("testcallbackId"); WXModuleManager.callModuleMethod(instance.getInstanceId(),"test1","testCallbackMethod",args); } |
WXModuleManager { public static void destroyInstanceModules(String instanceId) { sDomModuleMap.remove(instanceId); Map<String, WXModule> moduleMap = sInstanceModuleMap.remove(instanceId); if (moduleMap == null || moduleMap.size() < 1) { return; } Iterator<Entry<String, WXModule>> iterator = moduleMap.entrySet().iterator(); Entry<String, WXModule> entry; while (iterator.hasNext()) { entry = iterator.next(); WXModule module = entry.getValue(); if(module instanceof Destroyable){ ((Destroyable)module).destroy(); } } } static boolean registerModule(final String moduleName, final ModuleFactory factory, final boolean global); static void onActivityCreate(String instanceId); static void onActivityStart(String instanceId); static void onActivityPause(String instanceId); static void onActivityResume(String instanceId); static void onActivityStop(String instanceId); static void onActivityDestroy(String instanceId); static boolean onActivityBack(String instanceId); static void onActivityResult(String instanceId,int requestCode, int resultCode, Intent data); static boolean onCreateOptionsMenu(String instanceId,Menu menu); static void onRequestPermissionsResult(String instanceId ,int requestCode, String[] permissions, int[] grantResults); static void destroyInstanceModules(String instanceId); static void createDomModule(WXSDKInstance instance); static void destoryDomModule(String instanceID); static WXDomModule getDomModule(String instanceId); static void reload(); } | @Test public void testDestroyInstanceModules() throws Exception { testCallModuleMethod(); WXModuleManager.destroyInstanceModules(instance.getInstanceId()); } |
WXSDKInstance implements IWXActivityStateListener,DomContext, View.OnLayoutChangeListener { public void render(String template, Map<String, Object> options, String jsonInitData) { render(template, options, jsonInitData, WXRenderStrategy.APPEND_ASYNC); } WXSDKInstance(Context context); WXSDKInstance(Context context,String id); void setRenderContainer(RenderContainer a); boolean isTrackComponent(); void setTrackComponent(boolean trackComponent); boolean isLayerTypeEnabled(); void enableLayerType(boolean enable); boolean isNeedValidate(); @Deprecated void setViewPortWidth(int viewPortWidth); @Deprecated static int getViewPortWidth(); void setInstanceViewPortWidth(int instanceViewPortWidth); int getInstanceViewPortWidth(); WXComponent getRootComponent(); void setNestedInstanceInterceptor(NestedInstanceInterceptor interceptor); final WXSDKInstance createNestedInstance(NestedContainer container); void addOnInstanceVisibleListener(OnInstanceVisibleListener l); void removeOnInstanceVisibleListener(OnInstanceVisibleListener l); void init(Context context); void setComponentObserver(ComponentObserver observer); ComponentObserver getComponentObserver(); NativeInvokeHelper getNativeInvokeHelper(); void setBizType(String bizType); ScrollView getScrollView(); void setRootScrollView(ScrollView scrollView); @Deprecated void registerScrollViewListener(WXScrollViewListener scrollViewListener); @Deprecated WXScrollViewListener getScrollViewListener(); @Deprecated void setIWXUserTrackAdapter(IWXUserTrackAdapter adapter); void render(String template, Map<String, Object> options, String jsonInitData); @Deprecated void render(String template, Map<String, Object> options, String jsonInitData, WXRenderStrategy flag); void render(String pageName, String template, Map<String, Object> options, String jsonInitData, WXRenderStrategy flag); @Deprecated void render(String pageName, String template, Map<String, Object> options, String jsonInitData, int width, int height, WXRenderStrategy flag); void render(String template); @Deprecated void render(String template, int width, int height); @Deprecated void renderByUrl(String pageName, final String url, Map<String, Object> options, final String jsonInitData, final int width, final int height, final WXRenderStrategy flag); void renderByUrl(String pageName, final String url, Map<String, Object> options, final String jsonInitData, final WXRenderStrategy flag); void refreshInstance(Map<String, Object> data); void refreshInstance(String jsonData); WXRenderStrategy getRenderStrategy(); @Override Context getUIContext(); String getInstanceId(); Context getContext(); int getWeexHeight(); int getWeexWidth(); IWXImgLoaderAdapter getImgLoaderAdapter(); IDrawableLoader getDrawableLoader(); URIAdapter getURIAdapter(); Uri rewriteUri(Uri uri,String type); IWXHttpAdapter getWXHttpAdapter(); IWXStatisticsListener getWXStatisticsListener(); @Nullable IWebSocketAdapter getWXWebSocketAdapter(); @Deprecated void reloadImages(); boolean isPreRenderMode(); void setPreRenderMode(final boolean isPreRenderMode); void setContext(@NonNull Context context); void registerRenderListener(IWXRenderListener listener); @Deprecated void registerActivityStateListener(IWXActivityStateListener listener); void registerStatisticsListener(IWXStatisticsListener listener); void setLayoutFinishListener(@Nullable LayoutFinishListener listener); LayoutFinishListener getLayoutFinishListener(); void setRenderStartTime(long renderStartTime); @Override void onActivityCreate(); @Override void onActivityStart(); boolean onCreateOptionsMenu(Menu menu); @Override void onActivityPause(); @Override void onActivityResume(); @Override void onActivityStop(); @Override void onActivityDestroy(); @Override boolean onActivityBack(); boolean onBackPressed(); void onActivityResult(int requestCode, int resultCode, Intent data); void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults); void onViewDisappear(); void onViewAppear(); void onCreateFinish(); void onUpdateFinish(); void runOnUiThread(Runnable action); void onRenderSuccess(final int width, final int height); void onRefreshSuccess(final int width, final int height); void onRenderError(final String errCode, final String msg); void onJSException(final String errCode, final String function, final String exception); @Override final void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int
oldTop, int oldRight, int oldBottom); void onLayoutChange(View godView); void firstScreenCreateInstanceTime(long time); void callNativeTime(long time); void jsonParseTime(long time); void firstScreenRenderFinished(); void batchTime(long time); void cssLayoutTime(long time); void applyUpdateTime(long time); void updateDomObjTime(long time); void createInstanceFinished(long time); void commitUTStab(final String type, final WXErrorCode errorCode); synchronized void destroy(); boolean isDestroy(); @Nullable String getBundleUrl(); View getRootView(); View getContainerView(); @Deprecated void setBundleUrl(String url); void onRootCreated(WXComponent root); void moveFixedView(View fixedChild); void removeFixedView(View fixedChild); synchronized List<OnWXScrollListener> getWXScrollListeners(); synchronized void registerOnWXScrollListener(OnWXScrollListener wxScrollListener); void setSize(int width, int height); void fireGlobalEventCallback(String eventName, Map<String,Object> params); void fireEvent(String elementRef,final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEvent(String elementRef,final String type, final Map<String, Object> data); void fireEvent(String ref, String type); void fireModuleEvent(String eventName, WXModule module,Map<String, Object> params); boolean checkModuleEventRegistered(String eventName,WXModule module); WXPerformance getWXPerformance(); Map<String, Serializable> getUserTrackParams(); void addUserTrackParameter(String key,Serializable value); void clearUserTrackParameters(); void removeUserTrackParameter(String key); int getMaxDeepLayer(); void setMaxDeepLayer(int maxDeepLayer); public boolean mEnd; static final String BUNDLE_URL; } | @Test public void testRender() throws Exception { assertEquals(WXFileUtils.loadAsset(null,null),"{}"); mInstance.render("{}",null,null,null); } |
WXNavigatorModule extends WXModule { @JSMethod(uiThread = true) public void push(String param, JSCallback callback) { if (!TextUtils.isEmpty(param)) { if (WXSDKEngine.getActivityNavBarSetter() != null) { if (WXSDKEngine.getActivityNavBarSetter().push(param)) { if (callback != null) { callback.invoke(MSG_SUCCESS); } return; } } try { JSONObject jsonObject = JSON.parseObject(param); String url = jsonObject.getString(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(Constants.Scheme.HTTP); } Intent intent = new Intent(Intent.ACTION_VIEW, builder.build()); intent.addCategory(WEEX); intent.putExtra(INSTANCE_ID, mWXSDKInstance.getInstanceId()); mWXSDKInstance.getContext().startActivity(intent); if (callback != null) { callback.invoke(MSG_SUCCESS); } } } catch (Exception e) { WXLogUtils.eTag(TAG, e); if (callback != null) { callback.invoke(MSG_FAILED); } } } else if (callback != null) { callback.invoke(MSG_FAILED); } } @JSMethod(uiThread = true) void open(JSONObject options, JSCallback success, JSCallback failure); @JSMethod(uiThread = true) void close(JSONObject options, JSCallback success, JSCallback failure); @JSMethod(uiThread = true) void push(String param, JSCallback callback); @JSMethod(uiThread = true) void pop(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarRightItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarRightItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarLeftItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarLeftItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarMoreItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarMoreItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarTitle(String param, JSCallback callback); @JSMethod void setNavBarHidden(String param, final String callback); static final String MSG_SUCCESS; static final String MSG_FAILED; static final String MSG_PARAM_ERR; static final String CALLBACK_RESULT; static final String CALLBACK_MESSAGE; } | @Test public void testPush() throws Exception { module.push("{}",callback); module.push("{'url':'kdkdkdkdkd'}",callback); mockSetter(); module.push("{}",callback); } |
WXNavigatorModule extends WXModule { @JSMethod(uiThread = true) public void pop(String param, JSCallback callback) { if (WXSDKEngine.getActivityNavBarSetter() != null) { if (WXSDKEngine.getActivityNavBarSetter().pop(param)) { if (callback != null) { callback.invoke(MSG_SUCCESS); } return; } } if (mWXSDKInstance.getContext() instanceof Activity) { if (callback != null) { callback.invoke(MSG_SUCCESS); } ((Activity) mWXSDKInstance.getContext()).finish(); } } @JSMethod(uiThread = true) void open(JSONObject options, JSCallback success, JSCallback failure); @JSMethod(uiThread = true) void close(JSONObject options, JSCallback success, JSCallback failure); @JSMethod(uiThread = true) void push(String param, JSCallback callback); @JSMethod(uiThread = true) void pop(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarRightItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarRightItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarLeftItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarLeftItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarMoreItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarMoreItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarTitle(String param, JSCallback callback); @JSMethod void setNavBarHidden(String param, final String callback); static final String MSG_SUCCESS; static final String MSG_FAILED; static final String MSG_PARAM_ERR; static final String CALLBACK_RESULT; static final String CALLBACK_MESSAGE; } | @Test public void testPop() throws Exception { mockSetter(); module.pop("{}",callback); } |
WXNavigatorModule extends WXModule { @JSMethod(uiThread = true) public void setNavBarRightItem(String param, JSCallback callback) { if (!TextUtils.isEmpty(param)) { if (WXSDKEngine.getActivityNavBarSetter() != null) { if (WXSDKEngine.getActivityNavBarSetter().setNavBarRightItem(param)) { if (callback != null) { callback.invoke(MSG_SUCCESS); } return; } } } if (callback != null) { callback.invoke(MSG_FAILED); } } @JSMethod(uiThread = true) void open(JSONObject options, JSCallback success, JSCallback failure); @JSMethod(uiThread = true) void close(JSONObject options, JSCallback success, JSCallback failure); @JSMethod(uiThread = true) void push(String param, JSCallback callback); @JSMethod(uiThread = true) void pop(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarRightItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarRightItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarLeftItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarLeftItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarMoreItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarMoreItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarTitle(String param, JSCallback callback); @JSMethod void setNavBarHidden(String param, final String callback); static final String MSG_SUCCESS; static final String MSG_FAILED; static final String MSG_PARAM_ERR; static final String CALLBACK_RESULT; static final String CALLBACK_MESSAGE; } | @Test public void testSetNavBarRightItem() throws Exception { mockSetter(); module.setNavBarRightItem("{}",callback); } |
WXNavigatorModule extends WXModule { @JSMethod(uiThread = true) public void clearNavBarRightItem(String param, JSCallback callback) { if (WXSDKEngine.getActivityNavBarSetter() != null) { if (WXSDKEngine.getActivityNavBarSetter().clearNavBarRightItem(param)) { if (callback != null) { callback.invoke(MSG_SUCCESS); } return; } } if (callback != null) { callback.invoke(MSG_FAILED); } } @JSMethod(uiThread = true) void open(JSONObject options, JSCallback success, JSCallback failure); @JSMethod(uiThread = true) void close(JSONObject options, JSCallback success, JSCallback failure); @JSMethod(uiThread = true) void push(String param, JSCallback callback); @JSMethod(uiThread = true) void pop(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarRightItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarRightItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarLeftItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarLeftItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarMoreItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarMoreItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarTitle(String param, JSCallback callback); @JSMethod void setNavBarHidden(String param, final String callback); static final String MSG_SUCCESS; static final String MSG_FAILED; static final String MSG_PARAM_ERR; static final String CALLBACK_RESULT; static final String CALLBACK_MESSAGE; } | @Test public void testClearNavBarRightItem() throws Exception { mockSetter(); module.clearNavBarRightItem("{}",callback); } |
WXNavigatorModule extends WXModule { @JSMethod(uiThread = true) public void setNavBarLeftItem(String param, JSCallback callback) { if (!TextUtils.isEmpty(param)) { if (WXSDKEngine.getActivityNavBarSetter() != null) { if (WXSDKEngine.getActivityNavBarSetter().setNavBarLeftItem(param)) { if (callback != null) { callback.invoke(MSG_SUCCESS); } return; } } } if (callback != null) { callback.invoke(MSG_FAILED); } } @JSMethod(uiThread = true) void open(JSONObject options, JSCallback success, JSCallback failure); @JSMethod(uiThread = true) void close(JSONObject options, JSCallback success, JSCallback failure); @JSMethod(uiThread = true) void push(String param, JSCallback callback); @JSMethod(uiThread = true) void pop(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarRightItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarRightItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarLeftItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarLeftItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarMoreItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarMoreItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarTitle(String param, JSCallback callback); @JSMethod void setNavBarHidden(String param, final String callback); static final String MSG_SUCCESS; static final String MSG_FAILED; static final String MSG_PARAM_ERR; static final String CALLBACK_RESULT; static final String CALLBACK_MESSAGE; } | @Test public void testSetNavBarLeftItem() throws Exception { mockSetter(); module.setNavBarLeftItem("{}",callback); } |
WXNavigatorModule extends WXModule { @JSMethod(uiThread = true) public void clearNavBarLeftItem(String param, JSCallback callback) { if (WXSDKEngine.getActivityNavBarSetter() != null) { if (WXSDKEngine.getActivityNavBarSetter().clearNavBarLeftItem(param)) { if (callback != null) { callback.invoke(MSG_SUCCESS); } return; } } if (callback != null) { callback.invoke(MSG_FAILED); } } @JSMethod(uiThread = true) void open(JSONObject options, JSCallback success, JSCallback failure); @JSMethod(uiThread = true) void close(JSONObject options, JSCallback success, JSCallback failure); @JSMethod(uiThread = true) void push(String param, JSCallback callback); @JSMethod(uiThread = true) void pop(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarRightItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarRightItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarLeftItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarLeftItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarMoreItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarMoreItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarTitle(String param, JSCallback callback); @JSMethod void setNavBarHidden(String param, final String callback); static final String MSG_SUCCESS; static final String MSG_FAILED; static final String MSG_PARAM_ERR; static final String CALLBACK_RESULT; static final String CALLBACK_MESSAGE; } | @Test public void testClearNavBarLeftItem() throws Exception { mockSetter(); module.clearNavBarLeftItem("{}",callback); } |
WXNavigatorModule extends WXModule { @JSMethod(uiThread = true) public void setNavBarMoreItem(String param, JSCallback callback) { if (!TextUtils.isEmpty(param)) { if (WXSDKEngine.getActivityNavBarSetter() != null) { if (WXSDKEngine.getActivityNavBarSetter().setNavBarMoreItem(param)) { if (callback != null) { callback.invoke(MSG_SUCCESS); } return; } } } if (callback != null) { callback.invoke(MSG_FAILED); } } @JSMethod(uiThread = true) void open(JSONObject options, JSCallback success, JSCallback failure); @JSMethod(uiThread = true) void close(JSONObject options, JSCallback success, JSCallback failure); @JSMethod(uiThread = true) void push(String param, JSCallback callback); @JSMethod(uiThread = true) void pop(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarRightItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarRightItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarLeftItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarLeftItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarMoreItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarMoreItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarTitle(String param, JSCallback callback); @JSMethod void setNavBarHidden(String param, final String callback); static final String MSG_SUCCESS; static final String MSG_FAILED; static final String MSG_PARAM_ERR; static final String CALLBACK_RESULT; static final String CALLBACK_MESSAGE; } | @Test public void testSetNavBarMoreItem() throws Exception { mockSetter(); module.setNavBarMoreItem("{}",callback); } |
WXNavigatorModule extends WXModule { @JSMethod(uiThread = true) public void clearNavBarMoreItem(String param, JSCallback callback) { if (WXSDKEngine.getActivityNavBarSetter() != null) { if (WXSDKEngine.getActivityNavBarSetter().clearNavBarMoreItem(param)) { if (callback != null) { callback.invoke(MSG_SUCCESS); } return; } } if (callback != null) { callback.invoke(MSG_FAILED); } } @JSMethod(uiThread = true) void open(JSONObject options, JSCallback success, JSCallback failure); @JSMethod(uiThread = true) void close(JSONObject options, JSCallback success, JSCallback failure); @JSMethod(uiThread = true) void push(String param, JSCallback callback); @JSMethod(uiThread = true) void pop(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarRightItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarRightItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarLeftItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarLeftItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarMoreItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarMoreItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarTitle(String param, JSCallback callback); @JSMethod void setNavBarHidden(String param, final String callback); static final String MSG_SUCCESS; static final String MSG_FAILED; static final String MSG_PARAM_ERR; static final String CALLBACK_RESULT; static final String CALLBACK_MESSAGE; } | @Test public void testClearNavBarMoreItem() throws Exception { mockSetter(); module.clearNavBarMoreItem("{}",callback); } |
WXNavigatorModule extends WXModule { @JSMethod(uiThread = true) public void setNavBarTitle(String param, JSCallback callback) { if (!TextUtils.isEmpty(param)) { if (WXSDKEngine.getActivityNavBarSetter() != null) { if (WXSDKEngine.getActivityNavBarSetter().setNavBarTitle(param)) { if (callback != null) { callback.invoke(MSG_SUCCESS); } return; } } } if (callback != null) { callback.invoke(MSG_FAILED); } } @JSMethod(uiThread = true) void open(JSONObject options, JSCallback success, JSCallback failure); @JSMethod(uiThread = true) void close(JSONObject options, JSCallback success, JSCallback failure); @JSMethod(uiThread = true) void push(String param, JSCallback callback); @JSMethod(uiThread = true) void pop(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarRightItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarRightItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarLeftItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarLeftItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarMoreItem(String param, JSCallback callback); @JSMethod(uiThread = true) void clearNavBarMoreItem(String param, JSCallback callback); @JSMethod(uiThread = true) void setNavBarTitle(String param, JSCallback callback); @JSMethod void setNavBarHidden(String param, final String callback); static final String MSG_SUCCESS; static final String MSG_FAILED; static final String MSG_PARAM_ERR; static final String CALLBACK_RESULT; static final String CALLBACK_MESSAGE; } | @Test public void testSetNavBarTitle() throws Exception { mockSetter(); module.setNavBarTitle("{}",callback); } |
WXSDKInstance implements IWXActivityStateListener,DomContext, View.OnLayoutChangeListener { public void setSize(int width, int height) { if (width < 0 || height < 0 || isDestroy || !mRendered) { return; } float realWidth = WXViewUtils.getWebPxByWidth(width,getInstanceViewPortWidth()); float realHeight = WXViewUtils.getWebPxByWidth(height,getInstanceViewPortWidth()); View godView = mRenderContainer; if (godView != null) { ViewGroup.LayoutParams layoutParams = godView.getLayoutParams(); if (layoutParams != null) { if(godView.getWidth() != width || godView.getHeight() != height) { layoutParams.width = width; layoutParams.height = height; godView.setLayoutParams(layoutParams); } JSONObject style = new JSONObject(); WXComponent rootComponent = mRootComp; if(rootComponent == null){ return; } style.put(Constants.Name.DEFAULT_WIDTH, realWidth); style.put(Constants.Name.DEFAULT_HEIGHT, realHeight); updateRootComponentStyle(style); } } } WXSDKInstance(Context context); WXSDKInstance(Context context,String id); void setRenderContainer(RenderContainer a); boolean isTrackComponent(); void setTrackComponent(boolean trackComponent); boolean isLayerTypeEnabled(); void enableLayerType(boolean enable); boolean isNeedValidate(); @Deprecated void setViewPortWidth(int viewPortWidth); @Deprecated static int getViewPortWidth(); void setInstanceViewPortWidth(int instanceViewPortWidth); int getInstanceViewPortWidth(); WXComponent getRootComponent(); void setNestedInstanceInterceptor(NestedInstanceInterceptor interceptor); final WXSDKInstance createNestedInstance(NestedContainer container); void addOnInstanceVisibleListener(OnInstanceVisibleListener l); void removeOnInstanceVisibleListener(OnInstanceVisibleListener l); void init(Context context); void setComponentObserver(ComponentObserver observer); ComponentObserver getComponentObserver(); NativeInvokeHelper getNativeInvokeHelper(); void setBizType(String bizType); ScrollView getScrollView(); void setRootScrollView(ScrollView scrollView); @Deprecated void registerScrollViewListener(WXScrollViewListener scrollViewListener); @Deprecated WXScrollViewListener getScrollViewListener(); @Deprecated void setIWXUserTrackAdapter(IWXUserTrackAdapter adapter); void render(String template, Map<String, Object> options, String jsonInitData); @Deprecated void render(String template, Map<String, Object> options, String jsonInitData, WXRenderStrategy flag); void render(String pageName, String template, Map<String, Object> options, String jsonInitData, WXRenderStrategy flag); @Deprecated void render(String pageName, String template, Map<String, Object> options, String jsonInitData, int width, int height, WXRenderStrategy flag); void render(String template); @Deprecated void render(String template, int width, int height); @Deprecated void renderByUrl(String pageName, final String url, Map<String, Object> options, final String jsonInitData, final int width, final int height, final WXRenderStrategy flag); void renderByUrl(String pageName, final String url, Map<String, Object> options, final String jsonInitData, final WXRenderStrategy flag); void refreshInstance(Map<String, Object> data); void refreshInstance(String jsonData); WXRenderStrategy getRenderStrategy(); @Override Context getUIContext(); String getInstanceId(); Context getContext(); int getWeexHeight(); int getWeexWidth(); IWXImgLoaderAdapter getImgLoaderAdapter(); IDrawableLoader getDrawableLoader(); URIAdapter getURIAdapter(); Uri rewriteUri(Uri uri,String type); IWXHttpAdapter getWXHttpAdapter(); IWXStatisticsListener getWXStatisticsListener(); @Nullable IWebSocketAdapter getWXWebSocketAdapter(); @Deprecated void reloadImages(); boolean isPreRenderMode(); void setPreRenderMode(final boolean isPreRenderMode); void setContext(@NonNull Context context); void registerRenderListener(IWXRenderListener listener); @Deprecated void registerActivityStateListener(IWXActivityStateListener listener); void registerStatisticsListener(IWXStatisticsListener listener); void setLayoutFinishListener(@Nullable LayoutFinishListener listener); LayoutFinishListener getLayoutFinishListener(); void setRenderStartTime(long renderStartTime); @Override void onActivityCreate(); @Override void onActivityStart(); boolean onCreateOptionsMenu(Menu menu); @Override void onActivityPause(); @Override void onActivityResume(); @Override void onActivityStop(); @Override void onActivityDestroy(); @Override boolean onActivityBack(); boolean onBackPressed(); void onActivityResult(int requestCode, int resultCode, Intent data); void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults); void onViewDisappear(); void onViewAppear(); void onCreateFinish(); void onUpdateFinish(); void runOnUiThread(Runnable action); void onRenderSuccess(final int width, final int height); void onRefreshSuccess(final int width, final int height); void onRenderError(final String errCode, final String msg); void onJSException(final String errCode, final String function, final String exception); @Override final void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int
oldTop, int oldRight, int oldBottom); void onLayoutChange(View godView); void firstScreenCreateInstanceTime(long time); void callNativeTime(long time); void jsonParseTime(long time); void firstScreenRenderFinished(); void batchTime(long time); void cssLayoutTime(long time); void applyUpdateTime(long time); void updateDomObjTime(long time); void createInstanceFinished(long time); void commitUTStab(final String type, final WXErrorCode errorCode); synchronized void destroy(); boolean isDestroy(); @Nullable String getBundleUrl(); View getRootView(); View getContainerView(); @Deprecated void setBundleUrl(String url); void onRootCreated(WXComponent root); void moveFixedView(View fixedChild); void removeFixedView(View fixedChild); synchronized List<OnWXScrollListener> getWXScrollListeners(); synchronized void registerOnWXScrollListener(OnWXScrollListener wxScrollListener); void setSize(int width, int height); void fireGlobalEventCallback(String eventName, Map<String,Object> params); void fireEvent(String elementRef,final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEvent(String elementRef,final String type, final Map<String, Object> data); void fireEvent(String ref, String type); void fireModuleEvent(String eventName, WXModule module,Map<String, Object> params); boolean checkModuleEventRegistered(String eventName,WXModule module); WXPerformance getWXPerformance(); Map<String, Serializable> getUserTrackParams(); void addUserTrackParameter(String key,Serializable value); void clearUserTrackParameters(); void removeUserTrackParameter(String key); int getMaxDeepLayer(); void setMaxDeepLayer(int maxDeepLayer); public boolean mEnd; static final String BUNDLE_URL; } | @Test public void testSetSize() throws Exception { setupRoot(mInstance); mInstance.setSize(10,10); } |
WXSDKInstance implements IWXActivityStateListener,DomContext, View.OnLayoutChangeListener { @Deprecated public void renderByUrl(String pageName, final String url, Map<String, Object> options, final String jsonInitData, final int width, final int height, final WXRenderStrategy flag){ renderByUrl(pageName,url,options,jsonInitData,flag); } WXSDKInstance(Context context); WXSDKInstance(Context context,String id); void setRenderContainer(RenderContainer a); boolean isTrackComponent(); void setTrackComponent(boolean trackComponent); boolean isLayerTypeEnabled(); void enableLayerType(boolean enable); boolean isNeedValidate(); @Deprecated void setViewPortWidth(int viewPortWidth); @Deprecated static int getViewPortWidth(); void setInstanceViewPortWidth(int instanceViewPortWidth); int getInstanceViewPortWidth(); WXComponent getRootComponent(); void setNestedInstanceInterceptor(NestedInstanceInterceptor interceptor); final WXSDKInstance createNestedInstance(NestedContainer container); void addOnInstanceVisibleListener(OnInstanceVisibleListener l); void removeOnInstanceVisibleListener(OnInstanceVisibleListener l); void init(Context context); void setComponentObserver(ComponentObserver observer); ComponentObserver getComponentObserver(); NativeInvokeHelper getNativeInvokeHelper(); void setBizType(String bizType); ScrollView getScrollView(); void setRootScrollView(ScrollView scrollView); @Deprecated void registerScrollViewListener(WXScrollViewListener scrollViewListener); @Deprecated WXScrollViewListener getScrollViewListener(); @Deprecated void setIWXUserTrackAdapter(IWXUserTrackAdapter adapter); void render(String template, Map<String, Object> options, String jsonInitData); @Deprecated void render(String template, Map<String, Object> options, String jsonInitData, WXRenderStrategy flag); void render(String pageName, String template, Map<String, Object> options, String jsonInitData, WXRenderStrategy flag); @Deprecated void render(String pageName, String template, Map<String, Object> options, String jsonInitData, int width, int height, WXRenderStrategy flag); void render(String template); @Deprecated void render(String template, int width, int height); @Deprecated void renderByUrl(String pageName, final String url, Map<String, Object> options, final String jsonInitData, final int width, final int height, final WXRenderStrategy flag); void renderByUrl(String pageName, final String url, Map<String, Object> options, final String jsonInitData, final WXRenderStrategy flag); void refreshInstance(Map<String, Object> data); void refreshInstance(String jsonData); WXRenderStrategy getRenderStrategy(); @Override Context getUIContext(); String getInstanceId(); Context getContext(); int getWeexHeight(); int getWeexWidth(); IWXImgLoaderAdapter getImgLoaderAdapter(); IDrawableLoader getDrawableLoader(); URIAdapter getURIAdapter(); Uri rewriteUri(Uri uri,String type); IWXHttpAdapter getWXHttpAdapter(); IWXStatisticsListener getWXStatisticsListener(); @Nullable IWebSocketAdapter getWXWebSocketAdapter(); @Deprecated void reloadImages(); boolean isPreRenderMode(); void setPreRenderMode(final boolean isPreRenderMode); void setContext(@NonNull Context context); void registerRenderListener(IWXRenderListener listener); @Deprecated void registerActivityStateListener(IWXActivityStateListener listener); void registerStatisticsListener(IWXStatisticsListener listener); void setLayoutFinishListener(@Nullable LayoutFinishListener listener); LayoutFinishListener getLayoutFinishListener(); void setRenderStartTime(long renderStartTime); @Override void onActivityCreate(); @Override void onActivityStart(); boolean onCreateOptionsMenu(Menu menu); @Override void onActivityPause(); @Override void onActivityResume(); @Override void onActivityStop(); @Override void onActivityDestroy(); @Override boolean onActivityBack(); boolean onBackPressed(); void onActivityResult(int requestCode, int resultCode, Intent data); void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults); void onViewDisappear(); void onViewAppear(); void onCreateFinish(); void onUpdateFinish(); void runOnUiThread(Runnable action); void onRenderSuccess(final int width, final int height); void onRefreshSuccess(final int width, final int height); void onRenderError(final String errCode, final String msg); void onJSException(final String errCode, final String function, final String exception); @Override final void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int
oldTop, int oldRight, int oldBottom); void onLayoutChange(View godView); void firstScreenCreateInstanceTime(long time); void callNativeTime(long time); void jsonParseTime(long time); void firstScreenRenderFinished(); void batchTime(long time); void cssLayoutTime(long time); void applyUpdateTime(long time); void updateDomObjTime(long time); void createInstanceFinished(long time); void commitUTStab(final String type, final WXErrorCode errorCode); synchronized void destroy(); boolean isDestroy(); @Nullable String getBundleUrl(); View getRootView(); View getContainerView(); @Deprecated void setBundleUrl(String url); void onRootCreated(WXComponent root); void moveFixedView(View fixedChild); void removeFixedView(View fixedChild); synchronized List<OnWXScrollListener> getWXScrollListeners(); synchronized void registerOnWXScrollListener(OnWXScrollListener wxScrollListener); void setSize(int width, int height); void fireGlobalEventCallback(String eventName, Map<String,Object> params); void fireEvent(String elementRef,final String type, final Map<String, Object> data,final Map<String, Object> domChanges); void fireEvent(String elementRef,final String type, final Map<String, Object> data); void fireEvent(String ref, String type); void fireModuleEvent(String eventName, WXModule module,Map<String, Object> params); boolean checkModuleEventRegistered(String eventName,WXModule module); WXPerformance getWXPerformance(); Map<String, Serializable> getUserTrackParams(); void addUserTrackParameter(String key,Serializable value); void clearUserTrackParameters(); void removeUserTrackParameter(String key); int getMaxDeepLayer(); void setMaxDeepLayer(int maxDeepLayer); public boolean mEnd; static final String BUNDLE_URL; } | @Test public void testRenderByUrl() throws Exception { mInstance.renderByUrl(WXPerformance.DEFAULT,"file: mInstance.renderByUrl(WXPerformance.DEFAULT,"http: } |
WXSDKEngine { @Deprecated public static void init(Application application) { init(application, null); } @Deprecated static void init(Application application); @Deprecated static void init(Application application, IWXUserTrackAdapter utAdapter); @Deprecated static void init(Application application, IWXUserTrackAdapter utAdapter, String framework); static boolean isInitialized(); static void initialize(Application application,InitConfig config); @Deprecated static void init(Application application, String framework, IWXUserTrackAdapter utAdapter, IWXImgLoaderAdapter imgLoaderAdapter, IWXHttpAdapter httpAdapter); static void setJSExcetptionAdapter(IWXJSExceptionAdapter excetptionAdapter); static boolean registerComponent(String type, Class<? extends WXComponent> clazz, boolean appendTree); static boolean registerComponent(String type, IExternalComponentGetter componentGetter, boolean appendTree); static boolean registerComponent(Class<? extends WXComponent> clazz, boolean appendTree,String ... names); static boolean registerComponent(IFComponentHolder holder, boolean appendTree, String ... names); static boolean registerModule(String moduleName, Class<T> moduleClass,boolean global); static boolean registerModuleWithFactory(String moduleName, DestroyableModuleFactory factory, boolean global); static boolean registerModuleWithFactory(String moduleName, IExternalModuleGetter factory, boolean global); static boolean registerModule(String moduleName, Class<? extends WXModule> moduleClass); static boolean registerService(String name, String serviceScript, Map<String, String> options); static boolean unRegisterService(String name); static boolean registerDomObject(String type, Class<? extends WXDomObject> clazz); static void callback(String instanceId, String funcId, Map<String, Object> data); static void restartBridge(boolean debug); static boolean registerComponent(String type, Class<? extends WXComponent> clazz); static boolean registerComponent(Map<String, Object> componentInfo, Class<? extends WXComponent> clazz); static void addCustomOptions(String key, String value); static IWXUserTrackAdapter getIWXUserTrackAdapter(); static IWXImgLoaderAdapter getIWXImgLoaderAdapter(); static IDrawableLoader getDrawableLoader(); static IWXHttpAdapter getIWXHttpAdapter(); static IWXStorageAdapter getIWXStorageAdapter(); static IActivityNavBarSetter getActivityNavBarSetter(); static void setActivityNavBarSetter(IActivityNavBarSetter activityNavBarSetter); static void show3DLayer(boolean show); static void switchDebugModel(boolean debug, String debugUrl); static void reload(final Context context,String framework, boolean remoteDebug); static void reload(final Context context, boolean remoteDebug); static void reload(); static final String JS_FRAMEWORK_RELOAD; } | @Test public void testInit() throws Exception { assertFalse(WXSDKEngine.isInitialized()); WXSDKEngine.initialize(RuntimeEnvironment.application,null); assertTrue(WXSDKEngine.isInitialized()); WXSDKEngine.init(RuntimeEnvironment.application); WXSDKEngine.init(RuntimeEnvironment.application,null); WXSDKEngine.init(RuntimeEnvironment.application,null,null); WXSDKEngine.init(RuntimeEnvironment.application,null,null,null,null); } |
WXSDKEngine { public static boolean registerComponent(String type, Class<? extends WXComponent> clazz, boolean appendTree) throws WXException { return registerComponent(clazz, appendTree,type); } @Deprecated static void init(Application application); @Deprecated static void init(Application application, IWXUserTrackAdapter utAdapter); @Deprecated static void init(Application application, IWXUserTrackAdapter utAdapter, String framework); static boolean isInitialized(); static void initialize(Application application,InitConfig config); @Deprecated static void init(Application application, String framework, IWXUserTrackAdapter utAdapter, IWXImgLoaderAdapter imgLoaderAdapter, IWXHttpAdapter httpAdapter); static void setJSExcetptionAdapter(IWXJSExceptionAdapter excetptionAdapter); static boolean registerComponent(String type, Class<? extends WXComponent> clazz, boolean appendTree); static boolean registerComponent(String type, IExternalComponentGetter componentGetter, boolean appendTree); static boolean registerComponent(Class<? extends WXComponent> clazz, boolean appendTree,String ... names); static boolean registerComponent(IFComponentHolder holder, boolean appendTree, String ... names); static boolean registerModule(String moduleName, Class<T> moduleClass,boolean global); static boolean registerModuleWithFactory(String moduleName, DestroyableModuleFactory factory, boolean global); static boolean registerModuleWithFactory(String moduleName, IExternalModuleGetter factory, boolean global); static boolean registerModule(String moduleName, Class<? extends WXModule> moduleClass); static boolean registerService(String name, String serviceScript, Map<String, String> options); static boolean unRegisterService(String name); static boolean registerDomObject(String type, Class<? extends WXDomObject> clazz); static void callback(String instanceId, String funcId, Map<String, Object> data); static void restartBridge(boolean debug); static boolean registerComponent(String type, Class<? extends WXComponent> clazz); static boolean registerComponent(Map<String, Object> componentInfo, Class<? extends WXComponent> clazz); static void addCustomOptions(String key, String value); static IWXUserTrackAdapter getIWXUserTrackAdapter(); static IWXImgLoaderAdapter getIWXImgLoaderAdapter(); static IDrawableLoader getDrawableLoader(); static IWXHttpAdapter getIWXHttpAdapter(); static IWXStorageAdapter getIWXStorageAdapter(); static IActivityNavBarSetter getActivityNavBarSetter(); static void setActivityNavBarSetter(IActivityNavBarSetter activityNavBarSetter); static void show3DLayer(boolean show); static void switchDebugModel(boolean debug, String debugUrl); static void reload(final Context context,String framework, boolean remoteDebug); static void reload(final Context context, boolean remoteDebug); static void reload(); static final String JS_FRAMEWORK_RELOAD; } | @Test public void testRegisterComponent() throws Exception { assertFalse(WXSDKEngine.registerComponent(null,(Class<? extends WXComponent>) null,true)); assertTrue(WXSDKEngine.registerComponent("test", TestComponent.class,true)); assertTrue(WXSDKEngine.registerComponent("test1",TestComponent.class)); assertTrue(WXSDKEngine.registerComponent(TestComponent.class,false,"testA","testB","testC")); Map<String,Object> compInfo = new HashMap<>(); assertFalse(WXSDKEngine.registerComponent(compInfo,TestComponent.class)); } |
WXSDKEngine { public static <T extends WXModule> boolean registerModule(String moduleName, Class<T> moduleClass,boolean global) throws WXException { return moduleClass != null && registerModule(moduleName, new TypeModuleFactory<>(moduleClass), global); } @Deprecated static void init(Application application); @Deprecated static void init(Application application, IWXUserTrackAdapter utAdapter); @Deprecated static void init(Application application, IWXUserTrackAdapter utAdapter, String framework); static boolean isInitialized(); static void initialize(Application application,InitConfig config); @Deprecated static void init(Application application, String framework, IWXUserTrackAdapter utAdapter, IWXImgLoaderAdapter imgLoaderAdapter, IWXHttpAdapter httpAdapter); static void setJSExcetptionAdapter(IWXJSExceptionAdapter excetptionAdapter); static boolean registerComponent(String type, Class<? extends WXComponent> clazz, boolean appendTree); static boolean registerComponent(String type, IExternalComponentGetter componentGetter, boolean appendTree); static boolean registerComponent(Class<? extends WXComponent> clazz, boolean appendTree,String ... names); static boolean registerComponent(IFComponentHolder holder, boolean appendTree, String ... names); static boolean registerModule(String moduleName, Class<T> moduleClass,boolean global); static boolean registerModuleWithFactory(String moduleName, DestroyableModuleFactory factory, boolean global); static boolean registerModuleWithFactory(String moduleName, IExternalModuleGetter factory, boolean global); static boolean registerModule(String moduleName, Class<? extends WXModule> moduleClass); static boolean registerService(String name, String serviceScript, Map<String, String> options); static boolean unRegisterService(String name); static boolean registerDomObject(String type, Class<? extends WXDomObject> clazz); static void callback(String instanceId, String funcId, Map<String, Object> data); static void restartBridge(boolean debug); static boolean registerComponent(String type, Class<? extends WXComponent> clazz); static boolean registerComponent(Map<String, Object> componentInfo, Class<? extends WXComponent> clazz); static void addCustomOptions(String key, String value); static IWXUserTrackAdapter getIWXUserTrackAdapter(); static IWXImgLoaderAdapter getIWXImgLoaderAdapter(); static IDrawableLoader getDrawableLoader(); static IWXHttpAdapter getIWXHttpAdapter(); static IWXStorageAdapter getIWXStorageAdapter(); static IActivityNavBarSetter getActivityNavBarSetter(); static void setActivityNavBarSetter(IActivityNavBarSetter activityNavBarSetter); static void show3DLayer(boolean show); static void switchDebugModel(boolean debug, String debugUrl); static void reload(final Context context,String framework, boolean remoteDebug); static void reload(final Context context, boolean remoteDebug); static void reload(); static final String JS_FRAMEWORK_RELOAD; } | @Test public void testRegisterModule() throws Exception { assertTrue(WXSDKEngine.registerModule("test", TestModule.class)); assertFalse(WXSDKEngine.registerModule(null,TestModule.class)); assertFalse(WXSDKEngine.registerModule("test",null)); assertFalse(WXSDKEngine.registerModuleWithFactory(null,new TestModuleFactory(TestModule.class),true)); assertTrue(WXSDKEngine.registerModuleWithFactory("test1",new TestModuleFactory(TestModule.class),true)); } |