WXImage extends WXComponent<ImageView> { @WXComponentProp(name = Constants.Name.SRC) public void setSrc(String src) { WXImageStrategy imageStrategy = new WXImageStrategy(); imageStrategy.isClipping = true; WXImageSharpen imageSharpen = getDomObject().getAttrs().getImageSharpen(); imageStrategy.isSharpen = imageSharpen == WXImageSharpen.SHARPEN; imageStrategy.setImageListener(new WXImageStrategy.ImageListener() { @Override public void onImageFinish(String url,ImageView imageView, boolean result, Map extra) { if(!result && imageView!=null){ imageView.setImageDrawable(null); } if(getDomObject()!=null && getDomObject().containsEvent(Constants.Event.ONLOAD)){ Map<String,Object> params=new HashMap<String, Object>(); params.put("success",result); getInstance().fireEvent(getDomObject().getRef(), Constants.Event.ONLOAD,params); } } }); if( getDomObject().getAttrs().containsKey(Constants.Name.PLACE_HOLDER)){ String placeHolder= (String) getDomObject().getAttrs().get(Constants.Name.PLACE_HOLDER); imageStrategy.placeHolder=placeHolder; } IWXImgLoaderAdapter imgLoaderAdapter = getInstance().getImgLoaderAdapter(); if (imgLoaderAdapter != null) { imgLoaderAdapter.setImage(src, getHostView(), getDomObject().getAttrs().getImageQuality(), imageStrategy); } } @Deprecated  WXImage(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy);  WXImage(WXSDKInstance instance, WXDomObject node,
                   WXVContainer parent, boolean lazy); @Override void refreshData(WXComponent component); @WXComponentProp(name = Constants.Name.RESIZE_MODE) void setResizeMode(String resizeMode); @WXComponentProp(name = Constants.Name.RESIZE) void setResize(String resize); @WXComponentProp(name = Constants.Name.SRC) void setSrc(String src);  }
@Test public void testSetSrc() throws Exception { mWXImage.mDomObj = new WXDomObject(); mWXImage.mDomObj.attr = PowerMockito.mock(WXAttr.class); PowerMockito.when(mWXImage.mDomObj.attr.getImageSharpen()).thenReturn(WXImageSharpen.SHARPEN); mWXImage.setSrc(""); }