From 601fcb261004ba76119b221666d9ac88b57283d3 Mon Sep 17 00:00:00 2001 From: YorkShen Date: Wed, 25 Sep 2019 15:29:48 +0800 Subject: [PATCH] * [Android] Remove android test files as they are not runnable anyway and could lead confusion by the package name `com.taobao.weex (#2932) --- .../java/com/taobao/weex/TestActivity.java | 29 -- .../java/com/taobao/weex/TestApplication.java | 27 -- .../java/com/taobao/weex/WXSDKEngineTest.java | 108 ----- .../com/taobao/weex/WXSDKInstanceTest.java | 198 --------- .../com/taobao/weex/WXSDKManagerTest.java | 49 --- .../weex/adapter/DefaultUriAdapterTest.java | 116 ------ .../clipboard/WXClipboardModuleTest.java | 75 ---- .../navigator/WXNavigatorModuleTest.java | 174 -------- .../appfram/storage/DefaultWXStorageTest.java | 107 ----- .../appfram/storage/WXStorageModuleTest.java | 130 ------ .../weex/bridge/WXBridgeManagerTest.java | 168 -------- .../com/taobao/weex/bridge/WXBridgeTest.java | 77 ---- .../com/taobao/weex/bridge/WXHashMapTest.java | 85 ---- .../weex/bridge/WXModuleManagerTest.java | 103 ----- .../com/taobao/weex/common/TestModule.java | 44 -- .../taobao/weex/common/TestModuleFactory.java | 37 -- .../com/taobao/weex/common/WXModuleTest.java | 28 -- .../java/com/taobao/weex/dom/WXAttrTest.java | 137 ------- .../com/taobao/weex/dom/WXDomManagerTest.java | 69 ---- .../taobao/weex/dom/WXDomStatementTest.java | 292 -------------- .../java/com/taobao/weex/dom/WXStyleTest.java | 138 ------- .../taobao/weex/dom/WXTextDomObjectTest.java | 87 ---- .../taobao/weex/http/WXStreamModuleTest.java | 188 --------- .../taobao/weex/ui/ComponentHolderTest.java | 66 --- .../taobao/weex/ui/WXRenderStatementTest.java | 137 ------- .../ui/animation/WXAnimationModuleTest.java | 61 --- .../weex/ui/component/ComponentTest.java | 94 ----- .../weex/ui/component/EditComponentTest.java | 136 ------- .../weex/ui/component/TestComponent.java | 35 -- .../weex/ui/component/TestConstants.java | 36 -- .../weex/ui/component/TextareaTest.java | 69 ---- .../weex/ui/component/WXComponentTest.java | 114 ------ .../taobao/weex/ui/component/WXDivTest.java | 120 ------ .../taobao/weex/ui/component/WXEmbedTest.java | 69 ---- .../weex/ui/component/WXHeaderTest.java | 35 -- .../taobao/weex/ui/component/WXImageTest.java | 155 ------- .../weex/ui/component/WXLoadingTest.java | 70 ---- .../weex/ui/component/WXRefreshTest.java | 74 ---- .../weex/ui/component/WXScrollerTest.java | 80 ---- .../ui/component/WXSliderNeighborTest.java | 101 ----- .../weex/ui/component/WXSliderTest.java | 151 ------- .../weex/ui/component/WXSwitchTest.java | 72 ---- .../taobao/weex/ui/component/WXTextTest.java | 161 -------- .../taobao/weex/ui/component/WXVideoTest.java | 80 ---- .../taobao/weex/ui/component/WXWebTest.java | 174 -------- .../helper/WXTimeInputHelperTest.java | 68 ---- .../component/list/DefaultDragHelperTest.java | 129 ------ .../component/list/WXListComponentTest.java | 123 ------ .../weex/ui/module/WXMetaModuleTest.java | 77 ---- .../weex/ui/module/WXModalUIModuleTest.java | 80 ---- .../weex/ui/module/WXTimerModuleTest.java | 197 --------- .../weex/ui/module/WXWebViewModuleTest.java | 65 --- .../weex/ui/view/WXCirclePageAdapterTest.java | 107 ----- .../taobao/weex/ui/view/WXScrollViewTest.java | 87 ---- .../taobao/weex/ui/view/WXWebViewTest.java | 128 ------ .../weex/ui/view/border/BorderCornerTest.java | 320 --------------- .../ui/view/border/BorderDrawableTest.java | 377 ------------------ .../weex/ui/view/gesture/WXGestureTest.java | 77 ---- .../taobao/weex/utils/FunctionParserTest.java | 40 -- .../taobao/weex/utils/TypefaceUtilTest.java | 51 --- .../taobao/weex/utils/WXFileUtilsTest.java | 65 --- .../taobao/weex/utils/WXJsonUtilsTest.java | 100 ----- .../com/taobao/weex/utils/WXLogUtilsTest.java | 95 ----- .../weex/utils/WXReflectionUtilsTest.java | 126 ------ .../weex/utils/WXResourceUtilsTest.java | 145 ------- .../com/taobao/weex/utils/WXUtilsTest.java | 184 --------- .../configuration/MockitoConfiguration.java | 29 -- 67 files changed, 7226 deletions(-) delete mode 100644 android/sdk/src/test/java/com/taobao/weex/TestActivity.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/TestApplication.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/WXSDKEngineTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/WXSDKInstanceTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/WXSDKManagerTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/adapter/DefaultUriAdapterTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/appfram/clipboard/WXClipboardModuleTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/appfram/navigator/WXNavigatorModuleTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/appfram/storage/DefaultWXStorageTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/appfram/storage/WXStorageModuleTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/bridge/WXBridgeManagerTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/bridge/WXBridgeTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/bridge/WXHashMapTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/bridge/WXModuleManagerTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/common/TestModule.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/common/TestModuleFactory.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/common/WXModuleTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/dom/WXAttrTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/dom/WXDomManagerTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/dom/WXDomStatementTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/dom/WXStyleTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/dom/WXTextDomObjectTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/http/WXStreamModuleTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/ComponentHolderTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/WXRenderStatementTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/animation/WXAnimationModuleTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/component/ComponentTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/component/EditComponentTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/component/TestComponent.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/component/TestConstants.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/component/TextareaTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/component/WXComponentTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/component/WXDivTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/component/WXEmbedTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/component/WXHeaderTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/component/WXImageTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/component/WXLoadingTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/component/WXRefreshTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/component/WXScrollerTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/component/WXSliderNeighborTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/component/WXSliderTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/component/WXSwitchTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/component/WXTextTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/component/WXVideoTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/component/WXWebTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/component/helper/WXTimeInputHelperTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/component/list/DefaultDragHelperTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/component/list/WXListComponentTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/module/WXMetaModuleTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/module/WXModalUIModuleTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/module/WXTimerModuleTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/module/WXWebViewModuleTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/view/WXCirclePageAdapterTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/view/WXScrollViewTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/view/WXWebViewTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/view/border/BorderCornerTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/view/border/BorderDrawableTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/ui/view/gesture/WXGestureTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/utils/FunctionParserTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/utils/TypefaceUtilTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/utils/WXFileUtilsTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/utils/WXJsonUtilsTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/utils/WXLogUtilsTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/utils/WXReflectionUtilsTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/utils/WXResourceUtilsTest.java delete mode 100644 android/sdk/src/test/java/com/taobao/weex/utils/WXUtilsTest.java delete mode 100644 android/sdk/src/test/java/org/mockito/configuration/MockitoConfiguration.java diff --git a/android/sdk/src/test/java/com/taobao/weex/TestActivity.java b/android/sdk/src/test/java/com/taobao/weex/TestActivity.java deleted file mode 100644 index 66b305e9f0..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/TestActivity.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex; - -import android.app.Activity; -/** - * Created by sospartan on 7/27/16. - */ -public class TestActivity extends Activity { - public void test(){ - // - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/TestApplication.java b/android/sdk/src/test/java/com/taobao/weex/TestApplication.java deleted file mode 100644 index 9ca09d9282..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/TestApplication.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex; - -import android.app.Application; - -/** - * Created by sospartan on 7/21/16. - */ -public class TestApplication extends Application { -} diff --git a/android/sdk/src/test/java/com/taobao/weex/WXSDKEngineTest.java b/android/sdk/src/test/java/com/taobao/weex/WXSDKEngineTest.java deleted file mode 100644 index 0864653ce6..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/WXSDKEngineTest.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex; - -import com.taobao.weex.bridge.WXBridgeManagerTest; -import com.taobao.weex.common.TestModule; -import com.taobao.weex.common.TestModuleFactory; -import com.taobao.weex.ui.component.TestComponent; -import com.taobao.weex.ui.component.WXComponent; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.Config; - -import java.util.HashMap; -import java.util.Map; - -import static org.junit.Assert.*; - -/** - * Created by sospartan on 7/20/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(manifest = Config.NONE) -@PrepareForTest({}) -public class WXSDKEngineTest { - - @Before - public void setUp() throws Exception { - - } - - @After - public void tearDown() throws Exception { - WXBridgeManagerTest.getLooper().idle(); - } - - @Test - public void testInit() throws Exception { - assertFalse(WXSDKEngine.isInitialized()); - WXSDKEngine.initialize(RuntimeEnvironment.application,null); - - new Thread(){ - public void run(){ - try { - Thread.sleep(60000); - assertTrue(WXSDKEngine.isInitialized()); - } catch (InterruptedException e) { } - } - }.start(); - - - //keep compatible - WXSDKEngine.init(RuntimeEnvironment.application); - WXSDKEngine.init(RuntimeEnvironment.application,null); - WXSDKEngine.init(RuntimeEnvironment.application,null,null); - WXSDKEngine.init(RuntimeEnvironment.application,null,null,null,null); - } - - @Test - public void testRegisterComponent() throws Exception { - assertFalse(WXSDKEngine.registerComponent(null,(Class) 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 compInfo = new HashMap<>(); - assertFalse(WXSDKEngine.registerComponent(compInfo,TestComponent.class)); - } - - @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)); - } - - - @Test - public void testRegisterDomObject() throws Exception { - assertFalse(WXSDKEngine.registerDomObject("test",null)); - assertFalse(WXSDKEngine.registerDomObject("", TestDomObject.class)); - assertTrue(WXSDKEngine.registerDomObject("test",TestDomObject.class)); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/WXSDKInstanceTest.java b/android/sdk/src/test/java/com/taobao/weex/WXSDKInstanceTest.java deleted file mode 100644 index 6be97aef34..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/WXSDKInstanceTest.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex; - -import static org.junit.Assert.assertEquals; -import static org.powermock.api.mockito.PowerMockito.mock; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.when; - -import android.view.View; -import android.widget.FrameLayout; -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.bridge.WXBridgeManagerTest; -import com.taobao.weex.common.WXPerformance; -import com.taobao.weex.common.WXRenderStrategy; -import com.taobao.weex.dom.WXDomManagerTest; -import com.taobao.weex.ui.component.WXComponent; -import com.taobao.weex.ui.component.WXComponentFactory; -import com.taobao.weex.ui.component.WXDivTest; -import com.taobao.weex.ui.component.WXVContainer; -import com.taobao.weex.utils.WXFileUtils; -import com.taobao.weex.utils.WXSoInstallMgrSdk; -import java.util.HashMap; -import java.util.Map; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.rule.PowerMockRule; -import org.robolectric.Robolectric; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.Config; -import org.robolectric.shadows.ShadowLooper; - - -/** - * Created by sospartan on 7/27/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19,manifest = Config.NONE) -@PowerMockIgnore({ "org.mockito.*", "org.robolectric.*", "android.*" }) -@PrepareForTest({WXFileUtils.class,WXSoInstallMgrSdk.class}) -public class WXSDKInstanceTest { - @Rule - public PowerMockRule rule = new PowerMockRule(); - - public static WXSDKInstance createInstance(){ - WXSDKInstance instance = new WXSDKInstance(Robolectric.setupActivity(TestActivity.class),"1"); - final FrameLayout container = new FrameLayout(instance.getContext()); - instance.registerRenderListener(new IWXRenderListener() { - @Override - public void onViewCreated(WXSDKInstance instance, View view) { - container.addView(view); - } - - @Override - public void onRenderSuccess(WXSDKInstance instance, int width, int height) { - - } - - @Override - public void onRefreshSuccess(WXSDKInstance instance, int width, int height) { - - } - - @Override - public void onException(WXSDKInstance instance, String errCode, String msg) { - - } - }); - instance.mContext = Robolectric.setupActivity(TestActivity.class); - - return instance; - } - - public static void setupRoot(WXSDKInstance instance){ - - WXDomObject domObject = new WXDomObject(); - WXVContainer comp = (WXVContainer) WXComponentFactory.newInstance(instance, domObject, null); - - WXComponent root = WXDivTest.create(comp); - comp.addChild(root); - comp.createView(); - - instance.onCreateFinish(); - ShadowLooper.idleMainLooper(); - } - - WXSDKInstance mInstance; - - @Before - public void setup() throws Exception { - mockStatic(WXSoInstallMgrSdk.class); - when(WXSoInstallMgrSdk.initSo("weexv8", 1, null)).thenReturn(true); - WXSDKEngine.initialize(RuntimeEnvironment.application,new InitConfig.Builder().build()); - mInstance = createInstance(); - WXBridgeManagerTest.getLooper().idle(); - - mockStatic(WXFileUtils.class); - when(WXFileUtils.loadAsset(null,null)).thenReturn("{}"); - } - - @After - public void tearDown() throws Exception { - WXBridgeManagerTest.getLooper().idle(); - WXDomManagerTest.getLooper().idle(); - mInstance.destroy(); - } - - - @Test - public void testRender() throws Exception { - assertEquals(WXFileUtils.loadAsset(null,null),"{}"); - - mInstance.render("{}",null,null,null); - - } - - @Test - public void testSetSize() throws Exception { - setupRoot(mInstance); - mInstance.setSize(10,10); - } - - @Test - public void testRenderEvent() throws Exception { - mInstance.onRenderError("test","test"); - mInstance.onRenderSuccess(10,10); - } - - @Test - public void testRenderByUrl() throws Exception { - mInstance.renderByUrl(WXPerformance.DEFAULT,"file:///test",null,null,100,100, WXRenderStrategy.APPEND_ASYNC); - mInstance.renderByUrl(WXPerformance.DEFAULT,"http://taobao.com",null,null,100,100, WXRenderStrategy.APPEND_ASYNC); - } - - @Test - public void testGlobalEvent() throws Exception { - mInstance.addEventListener(null,null); - mInstance.addEventListener(null,""); - mInstance.addEventListener("",null); - - mInstance.addEventListener("test","123"); - mInstance.fireGlobalEventCallback("test",null); - mInstance.removeEventListener("test"); - mInstance.removeEventListener("test","123"); - } - - @Test - public void testFireEvent() throws Exception { - mInstance.fireEvent("1","test"); - Map params = new HashMap<>(); - params.put("arg1",null); - params.put("arg2",123); - mInstance.fireEvent("1","test",params); - - Map domChange = new HashMap<>(); - domChange.put("attr1","123"); - mInstance.fireEvent("1","test",params,domChange); - } - - - @Test - public void testOnActivityLifecycle() throws Exception { - mInstance.registerActivityStateListener(mock(IWXActivityStateListener.class)); - mInstance.onActivityCreate(); - mInstance.onActivityStart(); - mInstance.onActivityResume(); - mInstance.onActivityPause(); - mInstance.onActivityStop(); - } - - @Test - public void testOnJSException() throws Exception { - mInstance.onJSException(null,null,null); - mInstance.onJSException("100","test","some error"); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/WXSDKManagerTest.java b/android/sdk/src/test/java/com/taobao/weex/WXSDKManagerTest.java deleted file mode 100644 index ae6442d977..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/WXSDKManagerTest.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex; - -import com.taobao.weex.ui.WXRenderManager; -import org.junit.After; -import org.junit.Before; - -import static org.junit.Assert.*; - -/** - * Created by sospartan on 8/30/16. - */ -public class WXSDKManagerTest { - - public static void setRenderManager(WXRenderManager rm){ - WXSDKManager.initInstance(rm); - } - - public static void setInstance(WXSDKManager m){ - WXSDKManager.setInstance(m); - } - - @Before - public void setUp() throws Exception { - - } - - @After - public void tearDown() throws Exception { - - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/adapter/DefaultUriAdapterTest.java b/android/sdk/src/test/java/com/taobao/weex/adapter/DefaultUriAdapterTest.java deleted file mode 100644 index 3c4d84b349..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/adapter/DefaultUriAdapterTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.adapter; - -import android.net.Uri; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXEnvironment; -import com.taobao.weex.WXSDKInstance; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.WXSDKManager; -import com.taobao.weex.WXSDKManagerTest; -import com.taobao.weex.common.WXRenderStrategy; -import com.taobao.weex.common.WXRequest; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.mockito.internal.util.MockUtil; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.Config; - -import static org.junit.Assert.assertEquals; - - -/** - * Created by sospartan on 21/11/2016. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "android.*"}) -public class DefaultUriAdapterTest { - URIAdapter adapter; - WXSDKInstance instance; - - @Before - public void setup() { - WXEnvironment.sApplication = RuntimeEnvironment.application; - WXSDKManager wxsdkManager = WXSDKManager.getInstance(); - if (!new MockUtil().isSpy(wxsdkManager)) { - WXSDKManager spy = Mockito.spy(wxsdkManager); - WXSDKManagerTest.setInstance(spy); - Mockito.when(spy.getIWXHttpAdapter()).thenReturn(new IWXHttpAdapter() { - @Override - public void sendRequest(WXRequest request, OnHttpListener listener) { - //do nothing. - } - }); - } - - adapter = new DefaultUriAdapter(); - instance = WXSDKInstanceTest.createInstance(); - } - - @Test - public void testRewrite() throws Exception { - - final String host = "http://127.0.0.1"; - 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); - } - - private void testRelative(String host, String baseWithSlash, String bundleUrl) { - Uri uri = adapter.rewrite(instance, URIAdapter.IMAGE, Uri.parse("./456")); - assertEquals(Uri.parse(baseWithSlash + "./456"), uri); - - uri = adapter.rewrite(instance, URIAdapter.IMAGE, Uri.parse("../456")); - assertEquals(Uri.parse(baseWithSlash + "../456"), uri); - - - uri = adapter.rewrite(instance, URIAdapter.IMAGE, Uri.parse("./456?k=v")); - assertEquals(Uri.parse(baseWithSlash + "./456?k=v"), uri); - - uri = adapter.rewrite(instance, URIAdapter.IMAGE, Uri.parse("./456?k=v&k2=v2")); - assertEquals(Uri.parse(baseWithSlash + "./456?k=v&k2=v2"), uri); - - uri = adapter.rewrite(instance, URIAdapter.IMAGE, Uri.parse("./456?k=v#flagment")); - assertEquals(Uri.parse(baseWithSlash + "./456?k=v#flagment"), uri); - - uri = adapter.rewrite(instance, URIAdapter.IMAGE, Uri.parse("//test.com/test/test2")); - assertEquals(Uri.parse("http://test.com/test/test2"), uri); - - uri = adapter.rewrite(instance, URIAdapter.IMAGE, Uri.parse("/test2")); - assertEquals(Uri.parse(host + "/test2"), uri); - - uri = adapter.rewrite(instance, URIAdapter.IMAGE, Uri.parse("")); - assertEquals(Uri.parse(bundleUrl), uri); - } - -} diff --git a/android/sdk/src/test/java/com/taobao/weex/appfram/clipboard/WXClipboardModuleTest.java b/android/sdk/src/test/java/com/taobao/weex/appfram/clipboard/WXClipboardModuleTest.java deleted file mode 100644 index 4f2de367b2..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/appfram/clipboard/WXClipboardModuleTest.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.appfram.clipboard; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXSDKInstance; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.bridge.JSCallback; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import static org.junit.Assert.*; - -/** - * Created by sospartan on 27/09/2016. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"}) -public class WXClipboardModuleTest { - - WXClipboardModule module; - - @Before - public void setUp() throws Exception { - module = new WXClipboardModule(); - module.mWXSDKInstance = WXSDKInstanceTest.createInstance(); - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void testSetString() throws Exception { - module.setString("test"); - } - - @Test - public void testGetString() throws Exception { - - JSCallback mock = Mockito.mock(JSCallback.class); - module.getString(mock); - Mockito.verify(mock,Mockito.times(1)).invoke(Mockito.anyObject()); - - testSetString(); - - mock = Mockito.mock(JSCallback.class); - module.getString(mock); - Mockito.verify(mock,Mockito.times(1)).invoke(Mockito.anyObject()); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/appfram/navigator/WXNavigatorModuleTest.java b/android/sdk/src/test/java/com/taobao/weex/appfram/navigator/WXNavigatorModuleTest.java deleted file mode 100644 index 9084adc0d1..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/appfram/navigator/WXNavigatorModuleTest.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.appfram.navigator; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXSDKEngine; -import com.taobao.weex.WXSDKInstance; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.bridge.JSCallback; -import com.taobao.weex.bridge.WXBridgeManager; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.rule.PowerMockRule; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import static org.junit.Assert.*; -import static org.junit.Assert.*; -import static org.mockito.Mockito.when; -import static org.powermock.api.mockito.PowerMockito.*; -import static org.mockito.Mockito.*; - -/** - * Created by sospartan on 7/28/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore({ "org.mockito.*", "org.robolectric.*", "android.*","org.json.*" }) -@PrepareForTest(WXSDKEngine.class) -public class WXNavigatorModuleTest { - - WXNavigatorModule module; - JSCallback callback; - - @Rule - public PowerMockRule rule = new PowerMockRule(); - - @Before - public void setUp() throws Exception { - mockStatic(WXSDKEngine.class); - callback = Mockito.mock(JSCallback.class); - - - module = new WXNavigatorModule(); - module.mWXSDKInstance = WXSDKInstanceTest.createInstance(); - } - - private void mockSetter(){ - when(WXSDKEngine.getActivityNavBarSetter()).thenReturn(new IActivityNavBarSetter() { - @Override - public boolean push(String param) { - return true; - } - - @Override - public boolean pop(String param) { - return true; - } - - @Override - public boolean setNavBarRightItem(String param) { - return true; - } - - @Override - public boolean clearNavBarRightItem(String param) { - return true; - } - - @Override - public boolean setNavBarLeftItem(String param) { - return true; - } - - @Override - public boolean clearNavBarLeftItem(String param) { - return true; - } - - @Override - public boolean setNavBarMoreItem(String param) { - return true; - } - - @Override - public boolean clearNavBarMoreItem(String param) { - return true; - } - - @Override - public boolean setNavBarTitle(String param) { - return true; - } - }); - } - - @Test - public void testPush() throws Exception { - module.push("{}",callback); - module.push("{'url':'kdkdkdkdkd'}",callback); - mockSetter(); - module.push("{}",callback); - } - - - @Test - public void testPop() throws Exception { - mockSetter(); - module.pop("{}",callback); - } - - @Test - public void testSetNavBarRightItem() throws Exception { - mockSetter(); - module.setNavBarRightItem("{}",callback); - } - - @Test - public void testClearNavBarRightItem() throws Exception { - mockSetter(); - module.clearNavBarRightItem("{}",callback); - } - - @Test - public void testSetNavBarLeftItem() throws Exception { - mockSetter(); - module.setNavBarLeftItem("{}",callback); - } - - @Test - public void testClearNavBarLeftItem() throws Exception { - mockSetter(); - module.clearNavBarLeftItem("{}",callback); - } - - @Test - public void testSetNavBarMoreItem() throws Exception { - mockSetter(); - module.setNavBarMoreItem("{}",callback); - } - - @Test - public void testClearNavBarMoreItem() throws Exception { - mockSetter(); - module.clearNavBarMoreItem("{}",callback); - } - - @Test - public void testSetNavBarTitle() throws Exception { - mockSetter(); - module.setNavBarTitle("{}",callback); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/appfram/storage/DefaultWXStorageTest.java b/android/sdk/src/test/java/com/taobao/weex/appfram/storage/DefaultWXStorageTest.java deleted file mode 100644 index fae69b8155..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/appfram/storage/DefaultWXStorageTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.appfram.storage; - -import static org.mockito.Mockito.anyMapOf; -import static org.mockito.Mockito.timeout; -import static org.mockito.Mockito.verify; -import static org.powermock.api.mockito.PowerMockito.mockStatic; -import static org.powermock.api.mockito.PowerMockito.whenNew; - -import com.taobao.weappplus_sdk.BuildConfig; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.modules.junit4.rule.PowerMockRule; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.Config; - -/** - * Created by sospartan on 7/28/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore({ "org.mockito.*", "org.robolectric.*", "android.*" }) -public class DefaultWXStorageTest { - - @Mock - WXSQLiteOpenHelper supplier; - @Mock - IWXStorageAdapter.OnResultReceivedListener listener; - DefaultWXStorage storage; - - @Rule - public PowerMockRule rule = new PowerMockRule(); - - @Before - public void setup() throws Exception{ - MockitoAnnotations.initMocks(this); - storage = new DefaultWXStorage(RuntimeEnvironment.application); - mockStatic(WXSQLiteOpenHelper.class); - whenNew(WXSQLiteOpenHelper.class) - .withArguments(RuntimeEnvironment.application) - .thenReturn(supplier); - } - - - @Test - public void testSetItem() throws Exception { - storage.setItem("","",listener); - - verify(listener,timeout(3000).times(1)).onReceived(anyMapOf(String.class,Object.class)); - storage.close(); - } - - @Test - public void testGetItem() throws Exception { - storage.getItem("",listener); - - verify(listener,timeout(3000).times(1)).onReceived(anyMapOf(String.class,Object.class)); - storage.close(); - } - - @Test - public void testRemoveItem() throws Exception { - storage.removeItem("",listener); - - verify(listener,timeout(3000).times(1)).onReceived(anyMapOf(String.class,Object.class)); - storage.close(); - } - - @Test - public void testLength() throws Exception { - storage.length(listener); - - verify(listener,timeout(3000).times(1)).onReceived(anyMapOf(String.class,Object.class)); - storage.close(); - } - - @Test - public void testGetAllKeys() throws Exception { - storage.getAllKeys(listener); - - verify(listener,timeout(3000).times(1)).onReceived(anyMapOf(String.class,Object.class)); - storage.close(); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/appfram/storage/WXStorageModuleTest.java b/android/sdk/src/test/java/com/taobao/weex/appfram/storage/WXStorageModuleTest.java deleted file mode 100644 index 1ff7c89988..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/appfram/storage/WXStorageModuleTest.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.appfram.storage; - -import static org.mockito.Mockito.any; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.bridge.JSCallback; -import com.taobao.weex.bridge.WXBridgeManager; -import java.util.Map; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -/** - * Created by sospartan on 7/28/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore({ "org.mockito.*", "org.robolectric.*", "android.*" }) -@PrepareForTest(WXBridgeManager.class) -public class WXStorageModuleTest { - - - WXStorageModule module; - JSCallback callback; - - @Before - public void setUp() throws Exception { - module = new WXStorageModule(); - module.mWXSDKInstance = WXSDKInstanceTest.createInstance(); - module.mStorageAdapter = new IWXStorageAdapter() { - @Override - public void setItem(String key, String value, OnResultReceivedListener listener) { - Map data = StorageResultHandler.setItemResult(true); - listener.onReceived(data); - } - - @Override - public void getItem(String key, OnResultReceivedListener listener) { - Map data = StorageResultHandler.setItemResult(true); - listener.onReceived(data); - } - - @Override - public void removeItem(String key, OnResultReceivedListener listener) { - Map data = StorageResultHandler.setItemResult(true); - listener.onReceived(data); - } - - @Override - public void length(OnResultReceivedListener listener) { - Map data = StorageResultHandler.setItemResult(true); - listener.onReceived(data); - } - - @Override - public void getAllKeys(OnResultReceivedListener listener) { - Map data = StorageResultHandler.setItemResult(true); - listener.onReceived(data); - } - - @Override - public void setItemPersistent(String key, String value, OnResultReceivedListener listener) { - - } - - @Override - public void close() { - - } - }; - callback = Mockito.mock(JSCallback.class); - } - - @Test - public void testSetItem() throws Exception { - module.setItem("","",callback); - verify(callback,times(1)).invoke(any()); - - } - - @Test - public void testGetItem() throws Exception { - module.getItem("",callback); - verify(callback,times(1)).invoke(any()); - } - - @Test - public void testRemoveItem() throws Exception { - module.removeItem("",callback); - verify(callback,times(1)).invoke(any()); - } - - @Test - public void testLength() throws Exception { - module.length(callback); - verify(callback,times(1)).invoke(any()); - } - - @Test - public void testGetAllKeys() throws Exception { - module.getAllKeys(callback); - verify(callback,times(1)).invoke(any()); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/bridge/WXBridgeManagerTest.java b/android/sdk/src/test/java/com/taobao/weex/bridge/WXBridgeManagerTest.java deleted file mode 100644 index 61a3f142b8..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/bridge/WXBridgeManagerTest.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.bridge; - -import static junit.framework.Assert.assertNotNull; - -import android.os.Handler; -import android.os.Message; -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.InitConfig; -import com.taobao.weex.WXSDKEngine; -import com.taobao.weex.WXSDKInstance; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.WXSDKManagerTest; -import com.taobao.weex.common.Constants; -import com.taobao.weex.common.WXJSBridgeMsgType; -import com.taobao.weex.ui.WXRenderManager; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; -import org.robolectric.Shadows; -import org.robolectric.annotation.Config; -import org.robolectric.shadows.ShadowLooper; - - -/** - * Created by lixinke on 16/2/24. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"}) -@PrepareForTest(WXModuleManager.class) -public class WXBridgeManagerTest { - - WXSDKInstance instance; - - public static ShadowLooper getLooper() { - WXBridgeManager bridgeManager = WXBridgeManager.getInstance(); - Handler handler = bridgeManager.mJSHandler; - return Shadows.shadowOf(handler.getLooper()); - } - - public static void setBridgeManager(WXBridgeManager bridge) { - WXBridgeManager.mBridgeManager = bridge; - } - - private WXBridgeManager getInstance() { - return WXBridgeManager.getInstance(); - } - - @Before - public void setUp() throws Exception { - WXSDKEngine.initialize(RuntimeEnvironment.application,new InitConfig.Builder().build()); - instance = WXSDKInstanceTest.createInstance(); - WXRenderManager rednerManager = new WXRenderManager(); - rednerManager.registerInstance(instance);// - WXSDKManagerTest.setRenderManager(rednerManager); - } - - @After - public void tearDown() throws Exception { - getLooper().idle(); - getInstance().destroy(); - } - - @Test - public void testGetInstance() throws Exception { - WXBridgeManager instance = WXBridgeManager.getInstance(); - assertNotNull(instance); - } - - @Test - public void testRestart() throws Exception { - getInstance().restart(); - } - - @Test - public void testSetStackTopInstance() throws Exception { - getInstance().setStackTopInstance(""); - } - - @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); - - } - - @Test - public void testInitScriptsFramework() throws Exception { - getInstance().initScriptsFramework(""); - } - - @Test - public void testFireEvent() throws Exception { - getInstance().fireEvent(instance.getInstanceId(),"100", Constants.Event.CLICK,null,null); - } - - @Test - public void testCallback() throws Exception { - getInstance().callbackJavascript(instance.getInstanceId(),"test",null,false); - } - - @Test - public void testRefreshInstance() throws Exception { - getInstance().refreshInstance(instance.getInstanceId(),null); - } - - @Test - public void testCreateInstance() throws Exception { - getInstance().createInstance(instance.getInstanceId(),"",null,null); - } - - @Test - public void testDestroyInstance() throws Exception { - getInstance().destroyInstance(instance.getInstanceId()); - } - - @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); - } - } - - @Test - public void testReportJSException() throws Exception { - getInstance().reportJSException(instance.getInstanceId(),"test","test exception"); - } - -} diff --git a/android/sdk/src/test/java/com/taobao/weex/bridge/WXBridgeTest.java b/android/sdk/src/test/java/com/taobao/weex/bridge/WXBridgeTest.java deleted file mode 100644 index 13feaf64b5..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/bridge/WXBridgeTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.bridge; - -import com.taobao.weappplus_sdk.BuildConfig; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import static org.junit.Assert.*; - -/** - * Created by sospartan on 27/09/2016. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"}) -public class WXBridgeTest { - - WXBridge bridge; - - @Before - public void setUp() throws Exception { - bridge = new WXBridge(); - } - - @Test - public void testCallNative() throws Exception { - bridge.callNative("1","{}","100"); - } - - @Test - public void testCallAddElement() throws Exception { - bridge.callAddElement("1","1","{}","0","100"); - } - - - @After - public void tearDown() throws Exception { - - } - - @Test - public void testReportJSException() throws Exception { - bridge.reportJSException("1","test","some exception"); - } - - @Test - public void testSetTimeoutNative() throws Exception { - bridge.setTimeoutNative("100","1024"); - } - - @Test - public void testSetJSFrmVersion() throws Exception { - bridge.setJSFrmVersion("v0.1"); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/bridge/WXHashMapTest.java b/android/sdk/src/test/java/com/taobao/weex/bridge/WXHashMapTest.java deleted file mode 100644 index 71638ae027..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/bridge/WXHashMapTest.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.bridge; - -import com.taobao.weappplus_sdk.BuildConfig; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.util.Stack; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class,manifest = Config.NONE) -public class WXHashMapTest { - private WXHashMap mWXHashMap = new WXHashMap<>(); - - @Before - public void setUp() throws Exception { - mWXHashMap.clear(); - } - - @Test - public void testPutKV() { - mWXHashMap.put("one", "1"); - assertEquals("1", mWXHashMap.get("one")); - } - - @Test - public void testRemoveObject() { - mWXHashMap.put("one", "1"); - mWXHashMap.remove("one"); - assertEquals(0, mWXHashMap.size()); - } - - @Test - public void testRemoveFromMapAndStack() { - mWXHashMap.put("one","1"); - mWXHashMap.removeFromMapAndStack("one"); - assertEquals(true,mWXHashMap.getInstanceStack().empty()); - } - - @Test - public void testGetStackTopInstanceId() { - mWXHashMap.setStackTopInstance("123456"); - mWXHashMap.setStackTopInstance("654321"); - String id=mWXHashMap.getStackTopInstanceId(); - assertEquals("654321",id); - } - - @Test - public void testSetStackTopInstance() { - mWXHashMap.setStackTopInstance("123456"); - int size=mWXHashMap.getInstanceStack().size(); - assertEquals(1,size); - } - - @Test - public void testGetInstanceStack() { - Stack instance= mWXHashMap.getInstanceStack(); - assertNotNull(instance); - } - -} diff --git a/android/sdk/src/test/java/com/taobao/weex/bridge/WXModuleManagerTest.java b/android/sdk/src/test/java/com/taobao/weex/bridge/WXModuleManagerTest.java deleted file mode 100644 index c4c92d8496..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/bridge/WXModuleManagerTest.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.bridge; - -import com.alibaba.fastjson.JSONArray; -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.InitConfig; -import com.taobao.weex.WXSDKEngine; -import com.taobao.weex.WXSDKInstance; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.common.TestModule; -import com.taobao.weex.common.TypeModuleFactory; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.modules.junit4.PowerMockRunner; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.Config; - -import static org.junit.Assert.*; - -/** - * Created by sospartan on 8/31/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class) -public class WXModuleManagerTest { - - WXSDKInstance instance; - - @Before - public void setUp() throws Exception { - WXSDKEngine.initialize(RuntimeEnvironment.application,new InitConfig.Builder().build()); - instance = WXSDKInstanceTest.createInstance(); - WXModuleManager.registerModule("test",null,false); - WXModuleManager.registerModule("test1",new TypeModuleFactory<>(TestModule.class),true); - WXModuleManager.registerModule("test2",new TypeModuleFactory<>(TestModule.class),false); - WXBridgeManagerTest.getLooper().idle(); - } - - @After - public void tearDown() throws Exception { - - } - - @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); - } - - @Test - public void testDestroyInstanceModules() throws Exception { - testCallModuleMethod();//module instance is lazy create. - WXModuleManager.destroyInstanceModules(instance.getInstanceId()); - } - - @Test - public void testReload() throws Exception { - WXModuleManager.reload(); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/common/TestModule.java b/android/sdk/src/test/java/com/taobao/weex/common/TestModule.java deleted file mode 100644 index b1158d40f2..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/common/TestModule.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.common; - -import com.taobao.weex.WXSDKEngine; -import com.taobao.weex.annotation.JSMethod; -import com.taobao.weex.bridge.JSCallback; - -/** - * Created by sospartan on 7/27/16. - */ -public class TestModule extends WXSDKEngine.DestroyableModule { - - @JSMethod - public void testMethod(String arg){ - - } - - @JSMethod(uiThread=true) - public void testCallbackMethod(String arg, JSCallback callback){ - - } - - @Override - public void destroy() { - - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/common/TestModuleFactory.java b/android/sdk/src/test/java/com/taobao/weex/common/TestModuleFactory.java deleted file mode 100644 index ae9fc65ce3..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/common/TestModuleFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.common; - -import com.taobao.weex.WXSDKEngine; -import com.taobao.weex.bridge.Invoker; -import com.taobao.weex.bridge.ModuleFactory; - -import java.util.ArrayList; -import java.util.Map; - -/** - * Created by sospartan on 7/27/16. - */ -public class TestModuleFactory extends WXSDKEngine.DestroyableModuleFactory { - - - public TestModuleFactory(Class clz) { - super(clz); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/common/WXModuleTest.java b/android/sdk/src/test/java/com/taobao/weex/common/WXModuleTest.java deleted file mode 100644 index 5860720639..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/common/WXModuleTest.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.common; - -import static org.junit.Assert.*; - -/** - * Created by sospartan on 7/27/16. - */ -public class WXModuleTest { - -} diff --git a/android/sdk/src/test/java/com/taobao/weex/dom/WXAttrTest.java b/android/sdk/src/test/java/com/taobao/weex/dom/WXAttrTest.java deleted file mode 100644 index c122418502..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/dom/WXAttrTest.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.dom; - -import static com.taobao.weex.common.Constants.Name.IMAGE_QUALITY; -import static com.taobao.weex.common.Constants.Name.SRC; -import static com.taobao.weex.common.Constants.Name.VALUE; -import static com.taobao.weex.common.Constants.Value.HIGH; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.common.Constants; -import com.taobao.weex.common.WXImageSharpen; -import com.taobao.weex.utils.WXViewUtils; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class) -public class WXAttrTest { - - WXAttr attr; - - @Before - public void setUp() throws Exception { - attr = new WXAttr(); - } - - @After - public void tearDown() throws Exception { - attr.clear(); - } - - @Test - public void testGetValue() throws Exception { - assertEquals(null,WXAttr.getValue(attr)); - - attr.put(VALUE,"test"); - - assertEquals("test",WXAttr.getValue(attr)); - } - - @Test - public void testGetImageQuality() throws Exception { - assertEquals(WXImageQuality.AUTO,attr.getImageQuality()); - - attr.put(IMAGE_QUALITY,HIGH); - assertEquals(WXImageQuality.HIGH,attr.getImageQuality()); - } - - @Test - public void testGetImageSharpen() throws Exception { - assertEquals(WXImageSharpen.UNSHARPEN,attr.getImageSharpen()); - - } - - @Test - public void testGetImageSrc() throws Exception { - assertEquals(null,attr.getImageSrc()); - - attr.put(SRC,"test"); - assertEquals("test",attr.getImageSrc()); - } - - @Test - public void testShowIndicators() throws Exception { - assertEquals(true,attr.showIndicators()); - } - - @Test - public void testAutoPlay() throws Exception { - assertEquals(false,attr.autoPlay()); - } - - @Test - public void testGetScope() throws Exception { - assertEquals(null,attr.getScope()); - } - - @Test - public void testGetLoadMoreRetry() throws Exception { - assertEquals(null,attr.getLoadMoreRetry()); - } - - @Test - public void testGetLoadMoreOffset() throws Exception { - assertEquals(null,attr.getLoadMoreOffset()); - } - - @Test - public void testGetIsRecycleImage() throws Exception { - assertEquals(true,attr.getIsRecycleImage()); - } - - @Test - public void testGetScrollDirection() throws Exception { - assertEquals("vertical",attr.getScrollDirection()); - } - - @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)); - } - -} diff --git a/android/sdk/src/test/java/com/taobao/weex/dom/WXDomManagerTest.java b/android/sdk/src/test/java/com/taobao/weex/dom/WXDomManagerTest.java deleted file mode 100644 index 261b5b767b..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/dom/WXDomManagerTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.dom; - -import com.taobao.weex.WXSDKInstance; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.WXSDKManager; -import com.taobao.weex.bridge.WXBridgeManager; -import com.taobao.weex.ui.WXRenderManager; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.Shadows; -import org.robolectric.shadows.ShadowLooper; - -import static org.junit.Assert.*; - -/** - * Created by sospartan on 8/31/16. - */ -@RunWith(RobolectricTestRunner.class) -public class WXDomManagerTest { - - public static ShadowLooper getLooper() { - return Shadows.shadowOf(WXSDKManager.getInstance().getWXDomManager().mDomHandler.getLooper()); - } - - WXDomManager dm; - WXSDKInstance instance; - - @Before - public void setUp() throws Exception { - WXRenderManager rm = new WXRenderManager(); - instance = WXSDKInstanceTest.createInstance(); - rm.registerInstance(instance); - dm = new WXDomManager(rm); - } - - @Test - public void testRemoveDomStatement() throws Exception { - dm.removeDomStatement(instance.getInstanceId()); - } - - @After - public void tearDown() throws Exception { - getLooper().idle(); - dm.destroy(); - } - - -} diff --git a/android/sdk/src/test/java/com/taobao/weex/dom/WXDomStatementTest.java b/android/sdk/src/test/java/com/taobao/weex/dom/WXDomStatementTest.java deleted file mode 100644 index 4bdd77a334..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/dom/WXDomStatementTest.java +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.dom; - -import com.alibaba.fastjson.JSONObject; -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.InitConfig; -import com.taobao.weex.WXSDKEngine; -import com.taobao.weex.WXSDKInstance; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.WXSDKManager; -import com.taobao.weex.WXSDKManagerTest; -import com.taobao.weex.bridge.WXBridgeManagerTest; -import com.taobao.weex.ui.WXRenderManager; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.Config; -import org.robolectric.shadows.ShadowLooper; - -/** - * Created by sospartan on 8/29/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"}) -public class WXDomStatementTest { - - DOMActionContextImpl stmt; - WXRenderManager rednerManager; - WXSDKInstance instance; - - @Before - public void setUp() throws Exception { - WXSDKEngine.initialize(RuntimeEnvironment.application,new InitConfig.Builder().build()); - ShadowLooper looper = WXBridgeManagerTest.getLooper(); - looper.idle(); - ShadowLooper.runUiThreadTasksIncludingDelayedTasks(); - instance = WXSDKInstanceTest.createInstance(); - rednerManager = new WXRenderManager(); - rednerManager.registerInstance(instance);// - WXSDKManagerTest.setRenderManager(rednerManager); - stmt = new DOMActionContextImpl(instance.getInstanceId(),rednerManager ); - } - - @After - public void tearDown() throws Exception { - stmt.destroy(); - } - - void createBody(){ - JSONObject body = new JSONObject(); - body.put("type","div"); - body.put("ref",WXDomObject.ROOT); - WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(), TestActions.body(body),true); - } - - void addDom(JSONObject obj,String parentRef,int index){ - WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(),TestActions.addDom(obj,parentRef,index),false); - } - - void removeDom(String ref){ - WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(),TestActions.remove(ref),false); - } - - void updateAttrs(String ref,JSONObject data){ - WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(),TestActions.updateAttr(ref,data),false); - } - - void updateStyle(String ref,JSONObject data,boolean byPesudo){ - WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(),TestActions.updateStyle(ref,data,byPesudo),false); - } - - void moveDom(String ref,String parent,int index){ - WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(),TestActions.moveDom(ref,parent,index),false); - } - - private void scrollToDom(String s, JSONObject o) { - WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(),TestActions.scrollTo(s,o),false); - } - - private void addEvent(String ref,String event){ - WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(),TestActions.addEvent(ref,event),false); - } - - private void removeEvent(String ref,String event){ - WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(),TestActions.removeEvent(ref,event),false); - } - - private void updateFinish(){ - WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(),TestActions.updateFinish(),false); - } - - private void createFinish(){ - WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(),TestActions.createFinish(),false); - } - - private void refreshFinish(){ - WXSDKManager.getInstance().getWXDomManager().executeAction(instance.getInstanceId(),TestActions.refreshFinish(),false); - } - - @Test - public void testCustomDomObject() throws Exception { - WXDomObject root = new TestDomObject(); - root.add(new WXListDomObject(),0); - root.add(new WXScrollerDomObject(),0); - root.add(new WXTextDomObject(),0); - root.add(new WXSwitchDomObject(),0); - root.add(new TextAreaEditTextDomObject(),0); - stmt.layout(root); - root.traverseTree(ApplyStyleConsumer.getInstance()); - } - - @Test - public void testCreateBody() throws Exception { - createBody(); - - stmt.batch(); - } - - @Test - public void testAddDom() throws Exception { - createBody(); - - JSONObject obj = new JSONObject(); - obj.put("type","div"); - obj.put("ref","100"); - - addDom(obj,WXDomObject.ROOT,0); - - stmt.batch(); - } - - @Test - public void testMoveDom() throws Exception { - createBody(); - JSONObject obj; - obj = new JSONObject(); - obj.put("type","div"); - obj.put("ref","100"); - addDom(obj,WXDomObject.ROOT,0); - - obj = new JSONObject(); - obj.put("type","div"); - obj.put("ref","101"); - addDom(obj,WXDomObject.ROOT,0); - - moveDom("100",WXDomObject.ROOT,1); - stmt.batch(); - } - - @Test - public void testRemoveDom() throws Exception { - createBody(); - JSONObject obj; - obj = new JSONObject(); - obj.put("type","div"); - obj.put("ref","100"); - addDom(obj,WXDomObject.ROOT,0); - - obj = new JSONObject(); - obj.put("type","div"); - obj.put("ref","101"); - addDom(obj,WXDomObject.ROOT,0); - - removeDom("101"); - - stmt.batch(); - } - - @Test - public void testUpdateAttrs() throws Exception { - createBody(); - JSONObject obj; - obj = new JSONObject(); - obj.put("type","div"); - obj.put("ref","100"); - addDom(obj,WXDomObject.ROOT,0); - - - updateAttrs("100",new JSONObject()); - updateAttrs("100",null); - - stmt.batch(); - } - - @Test - public void testUpdateStyle() throws Exception { - createBody(); - JSONObject obj; - obj = new JSONObject(); - obj.put("type","div"); - obj.put("ref","100"); - addDom(obj,WXDomObject.ROOT,0); - - updateStyle("100",new JSONObject(),false); - updateStyle("100",null,false); - - stmt.batch(); - } - - @Test - public void testAddEvent() throws Exception { - createBody(); - JSONObject obj; - obj = new JSONObject(); - obj.put("type","div"); - obj.put("ref","100"); - addDom(obj,WXDomObject.ROOT,0); - - addEvent("100","click"); - addEvent("100",null); - - stmt.batch(); - } - - @Test - public void testRemoveEvent() throws Exception { - createBody(); - JSONObject obj; - obj = new JSONObject(); - obj.put("type","div"); - obj.put("ref","100"); - addDom(obj,WXDomObject.ROOT,0); - - removeEvent("100",null); - addEvent("100","click"); - removeEvent("100","click"); - - stmt.batch(); - } - - @Test - public void testScrollToDom() throws Exception { - createBody(); - JSONObject obj; - obj = new JSONObject(); - obj.put("type","div"); - obj.put("ref","100"); - addDom(obj,WXDomObject.ROOT,0); - - scrollToDom("100",null); - stmt.batch(); - } - - - - @Test - public void testCreateFinish() throws Exception { - createBody(); - createFinish(); - - stmt.batch(); - } - - @Test - public void testRefreshFinish() throws Exception { - createBody(); - refreshFinish(); - - stmt.batch(); - } - - @Test - public void testUpdateFinish() throws Exception { - createBody(); - - updateFinish(); - stmt.batch(); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/dom/WXStyleTest.java b/android/sdk/src/test/java/com/taobao/weex/dom/WXStyleTest.java deleted file mode 100644 index f6641d4e13..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/dom/WXStyleTest.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.dom; - -import android.graphics.Typeface; - -import com.taobao.weex.common.Constants; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import java.util.HashMap; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; -import static org.hamcrest.CoreMatchers.*; - - -/** - * Description: - * - * Created by rowandjj(chuyi)
- */ - -public class WXStyleTest { - WXStyle style; - - @Before - public void setUp() throws Exception { - style = new WXStyle(); - } - - - @Test - public void testBlur() { - assertEquals(0,style.size()); - assertEquals(null,style.getBlur()); - style.put(Constants.Name.FILTER,"blur(5px)"); - assertEquals("blur(5px)",style.getBlur()); - - } - - @Test - public void testFontWeight(){ - WXStyle none = new WXStyle(); - assertThat(WXStyle.getFontWeight(none), is(Typeface.NORMAL)); - - WXStyle normal = new WXStyle(); - normal.put(Constants.Name.FONT_WEIGHT, Constants.Value.NORMAL); - assertThat(WXStyle.getFontWeight(normal), is(Typeface.NORMAL)); - - WXStyle bold = new WXStyle(); - bold.put(Constants.Name.FONT_WEIGHT, Constants.Value.BOLD); - assertThat(WXStyle.getFontWeight(bold), is(Typeface.BOLD)); - - WXStyle illegal = new WXStyle(); - illegal.put(Constants.Name.FONT_WEIGHT, "f"); - assertThat(WXStyle.getFontWeight(illegal), is(Typeface.NORMAL)); - - WXStyle number100 = new WXStyle(); - number100.put(Constants.Name.FONT_WEIGHT, "100"); - assertThat(WXStyle.getFontWeight(number100), is(Typeface.NORMAL)); - - WXStyle number200 = new WXStyle(); - number200.put(Constants.Name.FONT_WEIGHT, "200"); - assertThat(WXStyle.getFontWeight(number200), is(Typeface.NORMAL)); - - WXStyle number300 = new WXStyle(); - number300.put(Constants.Name.FONT_WEIGHT, "300"); - assertThat(WXStyle.getFontWeight(number300), is(Typeface.NORMAL)); - - WXStyle number400 = new WXStyle(); - number400.put(Constants.Name.FONT_WEIGHT, "400"); - assertThat(WXStyle.getFontWeight(number400), is(Typeface.NORMAL)); - - WXStyle number500 = new WXStyle(); - number500.put(Constants.Name.FONT_WEIGHT, "500"); - assertThat(WXStyle.getFontWeight(number500), is(Typeface.NORMAL)); - - WXStyle number600 = new WXStyle(); - number600.put(Constants.Name.FONT_WEIGHT, "600"); - assertThat(WXStyle.getFontWeight(number600), is(Typeface.BOLD)); - - WXStyle number700 = new WXStyle(); - number700.put(Constants.Name.FONT_WEIGHT, "700"); - assertThat(WXStyle.getFontWeight(number700), is(Typeface.BOLD)); - - WXStyle number800 = new WXStyle(); - number800.put(Constants.Name.FONT_WEIGHT, "800"); - assertThat(WXStyle.getFontWeight(number800), is(Typeface.BOLD)); - - WXStyle number900 = new WXStyle(); - number900.put(Constants.Name.FONT_WEIGHT, "900"); - assertThat(WXStyle.getFontWeight(number900), is(Typeface.BOLD)); - } - - @After - public void tearDown() throws Exception { - style.clear(); - } - - @Test - public void testPesudoParsing() throws Exception { - Map styles = new HashMap<>(); - styles.put("color","#FF0000"); - styles.put("color:active","#008000"); - styles.put("fontSize:active:some_clz",20); - styles.put("color:active:enabled",15); - styles.put("color:active:disabled","#008000"); - styles.put("fontSize:active:disabled",30); - - WXStyle style = new WXStyle(); - style.putAll(styles,false); - - assertEquals(style.getPesudoStyles().get(":active").keySet().size(),1); - assertEquals(style.getPesudoStyles().get(":active:some_clz").get("fontSize"),20); - assertEquals(style.getPesudoStyles().get(":active:disabled").get("fontSize"),30); - assertEquals(style.getPesudoStyles().get(":active:disabled").keySet().size(),2); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/dom/WXTextDomObjectTest.java b/android/sdk/src/test/java/com/taobao/weex/dom/WXTextDomObjectTest.java deleted file mode 100644 index c01259a177..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/dom/WXTextDomObjectTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.dom; - -import com.taobao.weappplus_sdk.BuildConfig; - -import static com.taobao.weex.common.Constants.Name.*; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.api.mockito.PowerMockito; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import static org.junit.Assert.*; - -/** - * Created by sospartan on 26/09/2016. - */ - -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -public class WXTextDomObjectTest { - - WXTextDomObject dom; - - @Before - public void setUp() throws Exception { - dom = new WXTextDomObject(); - WXStyle styles = dom.getStyles(); - styles.put(LINES,10); - styles.put(FONT_SIZE,10); - - dom.getAttrs().put(VALUE,"test"); - } - - @Test - public void testLayoutBefore() throws Exception { - dom.layoutBefore(); - } - - @Test - public void testMeasure() throws Exception { - testLayoutBefore(); - MeasureOutput output = new MeasureOutput(); - WXTextDomObject mock = PowerMockito.spy(dom); - PowerMockito.when(mock,"getTextWidth",dom.getTextPaint(),100f,false).thenReturn(10f); - WXTextDomObject.TEXT_MEASURE_FUNCTION.measure(mock,100,output); - - assertEquals(output.width,10f,0.1f); - } - - @Test - public void testLayoutAfter() throws Exception { - dom.layoutAfter(); - } - - @Test - public void testClone() throws Exception { - WXTextDomObject cloneDom = dom.clone(); - - assertFalse(cloneDom == dom); - } - - @After - public void tearDown() throws Exception { - - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/http/WXStreamModuleTest.java b/android/sdk/src/test/java/com/taobao/weex/http/WXStreamModuleTest.java deleted file mode 100644 index e0a2aa3259..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/http/WXStreamModuleTest.java +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.http; - -import android.os.Looper; -import android.telecom.Call; - -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.adapter.DefaultWXHttpAdapter; -import com.taobao.weex.adapter.IWXHttpAdapter; -import com.taobao.weex.bridge.JSCallback; -import com.taobao.weex.bridge.WXBridgeManager; -import com.taobao.weex.common.WXRequest; -import com.taobao.weex.common.WXResponse; -import com.taobao.weex.common.WXThread; -import junit.framework.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.util.*; -import java.util.logging.Level; -import java.util.logging.Logger; - -import static org.mockito.Mockito.*; -import static junit.framework.Assert.*; - - -/** - * Created by sospartan on 5/24/16. - */ -@RunWith(RobolectricTestRunner.class) -@PrepareForTest({WXStreamModule.class, IWXHttpAdapter.class}) -@Config(manifest= Config.NONE) -public class WXStreamModuleTest { - - @Before - public void setup() throws Exception{ - - } - - private WXResponse successResponse(){ - WXResponse resp = new WXResponse(); - resp.data = "data"; - resp.statusCode = "200"; - return resp; - } - - static class Callback implements JSCallback{ - Map mData; - - @Override - public void invoke(Object data) { - mData = (Map)data; - } - - @Override - public void invokeAndKeepAlive(Object data) { - mData = (Map)data; - } - } - - - @Test - public void testFetchInvaildOptions() throws Exception{ - IWXHttpAdapter adapter = new IWXHttpAdapter() { - @Override - public void sendRequest(WXRequest request, OnHttpListener listener) { - listener.onHttpFinish(successResponse()); - } - }; - - WXStreamModule streamModule = new WXStreamModule(adapter); - Callback cb = new Callback(); - streamModule.fetch("",cb,null); - - assert !(boolean)cb.mData.get("ok"); - } - - private WXStreamModule createModule(IWXHttpAdapter adapter){ - WXStreamModule m = new WXStreamModule(adapter); - m.mWXSDKInstance = WXSDKInstanceTest.createInstance(); - return m; - } - - @Test - public void testFetchSuccessFinish() throws Exception{ - IWXHttpAdapter adapter = new IWXHttpAdapter() { - @Override - public void sendRequest(WXRequest request, OnHttpListener listener) { - listener.onHttpFinish(successResponse()); - } - }; - - WXStreamModule streamModule = createModule(adapter); - Callback cb = new Callback(); - streamModule.fetch("{'url':'http://www.taobao.com'}",cb,null); - - assert (boolean)cb.mData.get("ok"); - } - - - @Test - public void testFetchHeaderReceived() throws Exception{ - IWXHttpAdapter adapter = new IWXHttpAdapter() { - @Override - public void sendRequest(WXRequest request, OnHttpListener listener) { - Map> headers = new HashMap<>(); - headers.put("key", Arrays.asList("someval")); - listener.onHeadersReceived(200,headers); - } - }; - - WXStreamModule streamModule = createModule(adapter); - Callback cb = new Callback(); - streamModule.fetch("{'url':'http://www.taobao.com'}",null,cb); - - assert ((Map)cb.mData.get("headers")).get("key").equals("someval"); - } - - @Test - public void testFetchRequestHttpbinCallback() throws Exception{ - WXStreamModule streamModule = createModule(new DefaultWXHttpAdapter()); - JSCallback progress = mock(JSCallback.class); - JSCallback finish = mock(JSCallback.class); - System.out.print("request start "+System.currentTimeMillis()); - streamModule.fetch("{method: 'POST',url: 'http://httpbin.org/post',type:'json'}",finish,progress); - verify(progress,timeout(10*1000).atLeastOnce()).invokeAndKeepAlive(anyMapOf(String.class, Object.class)); - verify(finish,timeout(10*1000).times(1)).invoke(anyMapOf(String.class, Object.class)); - System.out.print("\nrequest finish"+System.currentTimeMillis()); - } - - - @Test - public void testFetchStatus() throws Exception{ - WXStreamModule streamModule = createModule(new IWXHttpAdapter() { - @Override - public void sendRequest(WXRequest request, OnHttpListener listener) { - WXResponse response = new WXResponse(); - response.statusCode = "-1"; - listener.onHttpFinish(response); - } - }); - Callback finish = new Callback(); - - streamModule.fetch("",finish,null); - assertEquals(finish.mData.get(WXStreamModule.STATUS_TEXT),Status.ERR_INVALID_REQUEST); - - streamModule.fetch("{method: 'POST',url: 'http://httpbin.org/post',type:'json'}",finish,null); - assertEquals(finish.mData.get(WXStreamModule.STATUS_TEXT),Status.ERR_CONNECT_FAILED); - - streamModule = createModule(new IWXHttpAdapter() { - @Override - public void sendRequest(WXRequest request, OnHttpListener listener) { - WXResponse response = new WXResponse(); - response.statusCode = "302"; - listener.onHttpFinish(response); - } - }); - streamModule.fetch("{method: 'POST',url: 'http://httpbin.org/post',type:'json'}",finish,null); - assertEquals(finish.mData.get(WXStreamModule.STATUS),302); - assertEquals(finish.mData.get(WXStreamModule.STATUS).getClass(),Integer.class); - assertEquals(finish.mData.get(WXStreamModule.STATUS_TEXT),Status.getStatusText("302")); - } - -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/ComponentHolderTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/ComponentHolderTest.java deleted file mode 100644 index 1ddb122bbe..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/ComponentHolderTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui; - -import com.taobao.weex.WXSDKInstance; -import com.taobao.weex.bridge.Invoker; -import com.taobao.weex.ui.component.WXComponent; -import com.taobao.weex.ui.component.WXVContainer; - -import java.lang.reflect.InvocationTargetException; - -/** - * Created by sospartan on 8/4/16. - */ -public class ComponentHolderTest { - public static class TestComponentHolder implements IFComponentHolder{ - - WXComponent mComponent; - TestComponentHolder(WXComponent comp){ - mComponent = comp; - } - - @Override - public void loadIfNonLazy() { - - } - - @Override - public Invoker getPropertyInvoker(String name) { - return null; - } - - @Override - public Invoker getMethodInvoker(String name) { - return null; - } - - @Override - public String[] getMethods() { - return new String[0]; - } - - @Override - public WXComponent createInstance(WXSDKInstance instance, WXDomObject node, WXVContainer parent) throws IllegalAccessException, InvocationTargetException, InstantiationException { - mComponent.bindHolder(this); - return mComponent; - } - } - -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/WXRenderStatementTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/WXRenderStatementTest.java deleted file mode 100644 index 1c4fef9ed0..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/WXRenderStatementTest.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui; - -import android.text.TextUtils; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXSDKInstance; -import com.taobao.weex.ui.component.WXComponentFactory; -import com.taobao.weex.utils.WXSoInstallMgrSdk; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.robolectric.annotation.Config; - -/** - * Created by lixinke on 16/3/2. - */ -@RunWith(PowerMockRunner.class) -@Config(constants = BuildConfig.class) -@PrepareForTest({WXSoInstallMgrSdk.class, TextUtils.class,WXComponentFactory.class}) -public class WXRenderStatementTest { - - RenderContextImpl mWXRenderStatement; - - @Before - public void setUp() throws Exception { - PowerMockito.mockStatic(WXSoInstallMgrSdk.class); - PowerMockito.mockStatic(TextUtils.class); - PowerMockito.mockStatic(WXComponentFactory.class); - PowerMockito.when(TextUtils.isEmpty("124")).thenReturn(true); - PowerMockito.when(WXSoInstallMgrSdk.initSo(null, 1, null)).thenReturn(true); - WXSDKInstance instance = Mockito.mock(WXSDKInstance.class); - mWXRenderStatement = new RenderContextImpl(instance); - } - - public void testCreateBody() throws Exception { - - } - - @Test - public void testCreateBodyOnDomThread() throws Exception { - - } - - public void testSetPadding() throws Exception { - - } - - public void testSetLayout() throws Exception { - - } - - public void testSetExtra() throws Exception { - - } - - public void testAddComponent() throws Exception { - - } - - @Test - public void testCreateComponentOnDomThread() throws Exception { - - -// PowerMockito.mockStatic(TextUtils.class); -// PowerMockito.mockStatic(WXComponentFactory.class); -// PowerMockito.when(TextUtils.isEmpty("1234")).thenReturn(true); -// PowerMockito.when(WXComponentFactory.newInstance(null, null, null, null)).thenReturn(PowerMockito.mock(WXDiv.class)); -// -// WXDomObject object = PowerMockito.mock(WXDomObject.class); -// WXComponent wxComponent = mWXRenderStatement.createBodyOnDomThread(object); -// assertNotNull(wxComponent); - - } - - public void testAddComponent1() throws Exception { - - } - - public void testRemoveComponent() throws Exception { - - } - - public void testMove() throws Exception { - - } - - public void testAddEvent() throws Exception { - - } - - public void testRemoveEvent() throws Exception { - - } - - public void testUpdateAttrs() throws Exception { - - } - - public void testUpdateStyle() throws Exception { - - } - - public void testScrollTo() throws Exception { - - } - - public void testCreateFinish() throws Exception { - - } - - public void testRefreshFinish() throws Exception { - - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/animation/WXAnimationModuleTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/animation/WXAnimationModuleTest.java deleted file mode 100644 index 7dd485834b..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/animation/WXAnimationModuleTest.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.animation; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXSDKInstanceTest; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -/** - * Created by sospartan on 7/29/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore({ "org.mockito.*", "org.robolectric.*", "android.*","org.json.*" }) -@PrepareForTest() -public class WXAnimationModuleTest { - - - WXAnimationModule module; - @Before - public void setUp() throws Exception { - module = new WXAnimationModule(); - module.mWXSDKInstance = WXSDKInstanceTest.createInstance(); - - - } - - @Test - public void testTransition() throws Exception { - module.transition("","",""); - module.transition("test","test",""); - } - - @Test - public void testCreateAnimatorListener() throws Exception { - - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/ComponentTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/ComponentTest.java deleted file mode 100644 index bcafc2a19f..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/component/ComponentTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.component; - -import android.view.View; - -import com.taobao.weex.WXSDKInstance; - -import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; -import java.util.Map; - -/** - * Created by sospartan on 8/3/16. - */ -public class ComponentTest { - public static void create(WXComponent comp){ - create(comp,null); - } - public static void create(WXComponent comp,View view){ - TestDomObject domObject = new TestDomObject(); - WXVContainer parent; - - if((parent = comp.getParent())!=null){ - if(view != null) { - comp.mHost = view; - }else{ - comp.createView(); - } - }else{ - parent = WXDivTest.create(); - parent.addChild(comp); - parent.createChildViewAt(-1); - } - - comp.setSafeLayout(comp); - -// domObject = new TestDomObject(); -// comp.updateDom(domObject); - comp.applyLayoutAndEvent(comp); - - addEvent(comp); - } - - - public static void setProperty(WXComponent comp,String[] propNames,Object[][] valueGroups){ - Map props = new HashMap<>(); - int len = propNames.length; - - if(propNames.length != valueGroups.length){ - throw new RuntimeException("Property name and value group length not match"); - } - for (int i=0;i T createComponent(WXDomObject dom, WXVContainer parent, Class type) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { - return type - .getConstructor(WXSDKInstance.class,WXDomObject.class,WXVContainer.class) - .newInstance(parent.getInstance(),dom,parent); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/EditComponentTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/EditComponentTest.java deleted file mode 100644 index 8a40791f56..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/component/EditComponentTest.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.component; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.common.Constants; -import com.taobao.weex.ui.SimpleComponentHolder; -import com.taobao.weex.ui.view.WXEditText; - -import junit.framework.Assert; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.lang.reflect.InvocationTargetException; - -import static com.taobao.weex.common.Constants.Name.*; -import static com.taobao.weex.common.Constants.Value.*; - -/** - * Created by sospartan on 8/3/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"}) -@PrepareForTest -public class EditComponentTest { - static final String[] PROPS = { - TEXT_ALIGN, - FONT_SIZE, - COLOR, - TYPE, - VALUE, - PLACE_HOLDER, - PLACEHOLDER_COLOR, - AUTOFOCUS, - LINES, - SINGLELINE, - MAX_LENGTH, - ROWS}; - static final Object[][] TEST_VALUES = { - {null,CENTER, Constants.Name.LEFT, Constants.Name.RIGHT,"kdkdkdk"}, - {null,12,Integer.MAX_VALUE,0,-2}, - {"red","#000","#ffffff","rgb(12,23,45)"}, - {"DKDK", - TEXT, - PASSWORD, - TEL, - EMAIL, - URL, - DATE, - TIME, - DATETIME}, - {null,123,"dkdkdkdk"}, - {null,123,"dkdkdkdk"}, - {"red","#000","#ffffff","rgb(12,23,45)"}, - {null,true,"true","false",false,"test"}, - {null,34,Integer.MAX_VALUE,-1,"test"}, - {null,true,"true","false",false,"test"}, - {null,34,Integer.MAX_VALUE,-1,"test"}, - {null,34,Integer.MAX_VALUE,-1,"test"}, - }; - - AbstractEditComponent component; - - public static WXInput create() throws IllegalAccessException, InstantiationException, InvocationTargetException { - return (WXInput) new SimpleComponentHolder(WXInput.class).createInstance(WXSDKInstanceTest.createInstance(), new TestDomObject(), WXDivTest.create()); - } - - public static Textarea createTextarea() throws IllegalAccessException, InstantiationException, InvocationTargetException { - return (Textarea) new SimpleComponentHolder(Textarea.class).createInstance(WXSDKInstanceTest.createInstance(), new TestDomObject(), WXDivTest.create()); - } - - - @Before - public void setUp() throws Exception { - component = create(); - ComponentTest.create(component); - } - - @After - public void tearDown() throws Exception { - ComponentTest.destory(component); - } - - @Test - public void testEvent() throws Exception { - WXEditText view = component.getHostView(); - view.performClick(); - view.setText(""); - view.requestFocus(); - view.setText("hello"); - view.clearFocus(); - view.setText(null); - } - - @Test - public void testSetProperty() throws Exception { - - ComponentTest.setProperty(component,PROPS,TEST_VALUES); - } - - @Test - public void testFocus() throws Exception { - component.getParent().mHost = component.getParent().initComponentHostView(component.getContext()); - component.getParent().interceptFocus(); - component.getHostView().clearFocus(); - component.focus(); - Assert.assertEquals(component.getHostView().hasFocus(), true); - } - - -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/TestComponent.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/TestComponent.java deleted file mode 100644 index 1ac43e6cee..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/component/TestComponent.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.component; - -import com.taobao.weex.WXSDKInstance; - -/** - * Created by sospartan on 7/27/16. - */ -public class TestComponent extends WXDiv{ - public TestComponent(WXSDKInstance instance, WXDomObject dom, WXVContainer parent, String instanceId, boolean isLazy) { - super(instance, dom, parent, instanceId, isLazy); - } - - public TestComponent(WXSDKInstance instance, WXDomObject dom, WXVContainer parent) { - super(instance, dom, parent); - } - -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/TestConstants.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/TestConstants.java deleted file mode 100644 index f0d060b875..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/component/TestConstants.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.component; - -import com.taobao.weex.common.Constants; - -/** - * Created by sospartan on 8/9/16. - */ -public class TestConstants { - public static final String Events[] = {"", null, - Constants.Event.INPUT, - Constants.Event.APPEAR, - Constants.Event.BLUR, - Constants.Event.CLICK, - Constants.Event.CHANGE, - Constants.Event.FOCUS, - Constants.Event.DISAPPEAR, - }; -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/TextareaTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/TextareaTest.java deleted file mode 100644 index 33fe97d40d..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/component/TextareaTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.component; - -import com.taobao.weappplus_sdk.BuildConfig; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.util.HashMap; -import java.util.Map; - -import static org.junit.Assert.*; - -/** - * Created by sospartan on 8/9/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"}) -public class TextareaTest { - - Textarea component; - - @Before - public void setUp() throws Exception { - component = EditComponentTest.createTextarea(); - ComponentTest.create(component); - } - - @Test - public void testSetProperty() throws Exception { - Map props = new HashMap<>(); - int len = EditComponentTest.PROPS.length; - - for (int i = 0; i < len; i++) { - for (Object obj : EditComponentTest.TEST_VALUES[i]) { - props.put(EditComponentTest.PROPS[i], obj); - component.updateProperties(props); - } - - } - } - - @After - public void tearDown() throws Exception { - ComponentTest.destory(component); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXComponentTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/WXComponentTest.java deleted file mode 100644 index 8ea91f1cfd..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXComponentTest.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.component; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.common.Constants; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import static org.junit.Assert.*; - -/** - * Created by sospartan on 7/27/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"}) -public class WXComponentTest { - - WXComponent component; - - @Before - public void setUp() throws Exception { - WXVContainer root = WXDivTest.create(); - ComponentTest.create(root); - component = WXDivTest.create(root); - ComponentTest.create(component); - } - - @Test - public void testSetProperty() throws Exception { - - assertTrue(component.setProperty(Constants.Name.VISIBILITY,null)); - assertTrue(component.setProperty(Constants.Name.VISIBILITY, Constants.Value.VISIBLE)); - - assertTrue(component.setProperty(Constants.Name.DISABLED,true)); - assertTrue(component.setProperty(Constants.Name.POSITION, Constants.Value.FIXED)); - assertTrue(component.setProperty(Constants.Name.BACKGROUND_COLOR, "#ffffff")); - assertTrue(component.setProperty(Constants.Name.OPACITY, 0.5f)); - assertTrue(component.setProperty(Constants.Name.BORDER_RADIUS,0.5f)); - assertTrue(component.setProperty(Constants.Name.BORDER_RADIUS,null)); - assertTrue(component.setProperty(Constants.Name.BORDER_WIDTH,null)); - assertTrue(component.setProperty(Constants.Name.BORDER_WIDTH,10)); - assertTrue(component.setProperty(Constants.Name.BORDER_STYLE,null)); - assertTrue(component.setProperty(Constants.Name.BORDER_STYLE, "SOLID")); - assertTrue(component.setProperty(Constants.Name.BORDER_COLOR,null)); - assertTrue(component.setProperty(Constants.Name.BORDER_COLOR, "#ff0000")); - - assertTrue(component.setProperty(Constants.Name.BORDER_TOP_LEFT_RADIUS, 1)); - assertTrue(component.setProperty(Constants.Name.BORDER_TOP_RIGHT_RADIUS, 1)); - assertTrue(component.setProperty(Constants.Name.BORDER_BOTTOM_LEFT_RADIUS, 1)); - assertTrue(component.setProperty(Constants.Name.BORDER_BOTTOM_RIGHT_RADIUS, 1)); - assertTrue(component.setProperty(Constants.Name.BORDER_TOP_WIDTH, 1)); - assertTrue(component.setProperty(Constants.Name.BORDER_LEFT_WIDTH, 1)); - assertTrue(component.setProperty(Constants.Name.BORDER_BOTTOM_WIDTH, 1)); - assertTrue(component.setProperty(Constants.Name.BORDER_RIGHT_WIDTH,1)); - - assertTrue(component.setProperty(Constants.Name.BORDER_TOP_COLOR, "#ff0000")); - assertTrue(component.setProperty(Constants.Name.BORDER_BOTTOM_COLOR, "#ff0000")); - assertTrue(component.setProperty(Constants.Name.BORDER_LEFT_COLOR, "#ff0000")); - assertTrue(component.setProperty(Constants.Name.BORDER_RIGHT_COLOR, "#ff0000")); - - assertTrue(component.setProperty(Constants.Name.WIDTH, null)); - assertTrue(component.setProperty(Constants.Name.MIN_WIDTH, null)); - assertTrue(component.setProperty(Constants.Name.MAX_WIDTH, null)); - assertTrue(component.setProperty(Constants.Name.HEIGHT, null)); - assertTrue(component.setProperty(Constants.Name.MIN_HEIGHT, null)); - assertTrue(component.setProperty(Constants.Name.MAX_HEIGHT, null)); - assertTrue(component.setProperty(Constants.Name.ALIGN_ITEMS, null)); - assertTrue(component.setProperty(Constants.Name.ALIGN_SELF, null)); - assertTrue(component.setProperty(Constants.Name.FLEX, null)); - assertTrue(component.setProperty(Constants.Name.FLEX_DIRECTION, null)); - assertTrue(component.setProperty(Constants.Name.JUSTIFY_CONTENT, null)); - assertTrue(component.setProperty(Constants.Name.FLEX_WRAP, null)); - assertTrue(component.setProperty(Constants.Name.MARGIN, null)); - assertTrue(component.setProperty(Constants.Name.MARGIN_TOP, null)); - assertTrue(component.setProperty(Constants.Name.MARGIN_LEFT, null)); - assertTrue(component.setProperty(Constants.Name.MARGIN_RIGHT, null)); - assertTrue(component.setProperty(Constants.Name.MARGIN_BOTTOM, null)); - assertTrue(component.setProperty(Constants.Name.PADDING, null)); - assertTrue(component.setProperty(Constants.Name.PADDING_TOP, null)); - assertTrue(component.setProperty(Constants.Name.PADDING_LEFT, null)); - assertTrue(component.setProperty(Constants.Name.PADDING_RIGHT, null)); - assertTrue(component.setProperty(Constants.Name.PADDING_BOTTOM, null)); - - } - - - @Test - public void testAddEvent() throws Exception { - component.addEvent(Constants.Event.FOCUS); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXDivTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/WXDivTest.java deleted file mode 100644 index 310af8e1f1..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXDivTest.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.component; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXSDKInstance; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.dom.WXEvent; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.Config; - -import static org.junit.Assert.*; - -/** - * Created by gulin on 16/2/24. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -public class WXDivTest { - - private WXDiv mWXDiv; - private WXText child2; - - - public static WXDiv create(){ - return create(null); - } - - public static WXDiv create(WXVContainer parent){ - WXDiv div = new WXDiv(WXSDKInstanceTest.createInstance(),new TestDomObject(),parent); - return div; - } - - - @Before - public void setUp() throws Exception { - WXSDKInstance instance = Mockito.mock(WXSDKInstance.class); - Mockito.when(instance.getContext()).thenReturn(RuntimeEnvironment.application); - - WXDomObject divDom = new WXDomObject(); - WXDomObject spy = Mockito.spy(divDom); - Mockito.when(spy.getPadding()).thenReturn(new Spacing()); - Mockito.when(spy.getEvents()).thenReturn(new WXEvent()); - Mockito.when(spy.clone()).thenReturn(divDom); - TestDomObject.setRef(divDom,"1"); - mWXDiv = new WXDiv(instance, divDom, null); - mWXDiv.initView(); - } - - @Test - public void testAddChild(){ - WXSDKInstance instance = Mockito.mock(WXSDKInstance.class); - Mockito.when(instance.getContext()).thenReturn(RuntimeEnvironment.application); - - WXDomObject testDom = Mockito.mock(WXDomObject.class); - Mockito.when(testDom.getPadding()).thenReturn(new Spacing()); - Mockito.when(testDom.clone()).thenReturn(testDom); - TestDomObject.setRef(testDom,"2"); - WXText child1 = new WXText(instance, testDom, mWXDiv); - child1.initView(); - - mWXDiv.addChild(child1, 0); - - assertEquals(1, mWXDiv.childCount()); - - WXDomObject testDom2 = Mockito.spy(new WXDomObject()); - Mockito.when(testDom2.getPadding()).thenReturn(new Spacing()); - Mockito.when(testDom2.clone()).thenReturn(testDom2); - TestDomObject.setRef(testDom2,"3"); - child2 = new WXText(instance, testDom2, mWXDiv); - child2.initView(); - - mWXDiv.addChild(child2, -1); - - assertEquals(2, mWXDiv.childCount()); - assertEquals(child2, mWXDiv.getChild(1)); - - WXDomObject testDom3 = Mockito.mock(WXDomObject.class); - Mockito.when(testDom3.getPadding()).thenReturn(new Spacing()); - Mockito.when(testDom3.clone()).thenReturn(testDom3); - TestDomObject.setRef(testDom3,"4"); - WXText child3 = new WXText(instance, testDom3, mWXDiv); - child3.initView(); - - mWXDiv.addChild(child3, 1); - - assertEquals(3, mWXDiv.childCount()); - assertEquals(child3, mWXDiv.getChild(1)); - } - - @Test - public void testRemove(){ - testAddChild(); - mWXDiv.remove(child2,true); - - assertEquals(2, mWXDiv.childCount()); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXEmbedTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/WXEmbedTest.java deleted file mode 100644 index 752b42587a..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXEmbedTest.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.component; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXEnvironment; -import com.taobao.weex.common.Constants; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.Config; - -/** - * Created by sospartan on 26/09/2016. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -public class WXEmbedTest { - - WXEmbed component; - - @Before - public void setUp() throws Exception { - - WXEnvironment.sApplication = RuntimeEnvironment.application; - WXDiv div = WXDivTest.create(); - ComponentTest.create(div); - component = new WXEmbed(div.getInstance(),new TestDomObject(),div); - ComponentTest.create(component); - component.getDomObject().getStyles().put(Constants.Name.VISIBILITY, Constants.Value.VISIBLE); - } - - @Test - public void testSetProperty() throws Exception { - component.setProperty(Constants.Name.SRC,"http://www.taobao.com"); - } - - @Test - public void testSetVisibility() throws Exception { - component.setProperty(Constants.Name.VISIBILITY,Constants.Value.HIDDEN); - component.setProperty(Constants.Name.SRC,"http://www.taobao.com"); - component.setProperty(Constants.Name.VISIBILITY,Constants.Value.VISIBLE); - } - - @After - public void tearDown() throws Exception { - component.destroy(); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXHeaderTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/WXHeaderTest.java deleted file mode 100644 index 740f7c4a12..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXHeaderTest.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.component; - -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.ui.SimpleComponentHolder; - -import java.lang.reflect.InvocationTargetException; - -/** - * Created by sospartan on 8/29/16. - */ -public class WXHeaderTest { - - public static WXHeader create(WXVContainer parent) throws IllegalAccessException, InstantiationException, InvocationTargetException { - return (WXHeader) new SimpleComponentHolder(WXHeader.class).createInstance(WXSDKInstanceTest.createInstance(), new TestDomObject(), parent); - } - -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXImageTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/WXImageTest.java deleted file mode 100644 index 9999f7131b..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXImageTest.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.component; - -import static junit.framework.Assert.assertEquals; -import static junit.framework.Assert.assertNotNull; -import static junit.framework.Assert.assertNull; - -import android.graphics.Bitmap; -import android.graphics.drawable.Drawable; -import android.view.ViewGroup; -import android.widget.ImageView; -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.TestActivity; -import com.taobao.weex.WXSDKInstance; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.common.Constants; -import com.taobao.weex.common.WXImageSharpen; -import com.taobao.weex.dom.WXAttr; -import com.taobao.weex.ui.view.WXImageView; -import com.taobao.weex.ui.view.border.BorderDrawable; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.rule.PowerMockRule; -import org.robolectric.Robolectric; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "android.*"}) -public class WXImageTest { - - @Rule - public PowerMockRule rule = new PowerMockRule(); - - WXImage mWXImage; - WXSDKInstance mInstance; - WXDiv mWXDiv; - WXDomObject mDomObject; - - @Before - public void setUp() throws Exception { - - mInstance = WXSDKInstanceTest.createInstance(); - mDomObject = new TestDomObject(); - PowerMockito.when(Mockito.spy(mDomObject).clone()).thenReturn(mDomObject); - mWXDiv = PowerMockito.mock(WXDiv.class); - mWXImage = new WXImage(mInstance, mDomObject, mWXDiv); - - } - - - @Test - @PrepareForTest(WXImageView.class) - public void testInitComponentHostView() throws Exception { - - ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class)); - assertEquals(imageView.getClass(), WXImageView.class); - - } - - @Test - @PrepareForTest(WXImageView.class) - public void testSetBackgroundColor() throws Exception { - - ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class)); - mWXImage.mHost = imageView; - - mWXImage.setBackgroundColor("#FFFFFF"); - - Drawable drawable = mWXImage.getHostView().getBackground(); - assertEquals(drawable instanceof BorderDrawable, true); - } - - - @Test - public void testSetProperty() throws Exception { - - ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class)); - mWXImage.mHost = imageView; - - mWXImage.setProperty(Constants.Name.RESIZE_MODE, "cover"); - ImageView.ScaleType scaleType = mWXImage.getHostView().getScaleType(); - assertEquals(scaleType, ImageView.ScaleType.CENTER_CROP); - - - } - - - @Test - public void testSetResizeMode() throws Exception { - - ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class)); - mWXImage.mHost = imageView; - - mWXImage.setResizeMode("cover"); - ImageView.ScaleType scaleType = mWXImage.getHostView().getScaleType(); - assertEquals(scaleType, ImageView.ScaleType.CENTER_CROP); - - } - - @Test - public void testSetResize() throws Exception { - ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class)); - mWXImage.mHost = imageView; - - mWXImage.setResize("cover"); - ImageView.ScaleType scaleType = mWXImage.getHostView().getScaleType(); - assertEquals(scaleType, ImageView.ScaleType.CENTER_CROP); - } - - @Test - public void testSetSrc() throws Exception { - TestDomObject.setAttribute((WXDomObject)mWXImage.getDomObject(),PowerMockito.mock(WXAttr.class)); - PowerMockito.when(mWXImage.getDomObject().getAttrs().getImageSharpen()).thenReturn(WXImageSharpen.SHARPEN); - mWXImage.setSrc(""); - - } - - @Test - public void testSetImageBitmap(){ - ImageView imageView = mWXImage.initComponentHostView(Robolectric.setupActivity(TestActivity.class)); - imageView.setLayoutParams(new ViewGroup.LayoutParams( - ViewGroup.LayoutParams.WRAP_CONTENT, - ViewGroup.LayoutParams.WRAP_CONTENT)); - imageView.setImageBitmap(null); - assertNull(imageView.getDrawable()); - - imageView.setImageBitmap(Bitmap.createBitmap(100, 100, Bitmap.Config.RGB_565)); - assertNotNull(imageView.getDrawable()); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXLoadingTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/WXLoadingTest.java deleted file mode 100644 index 59d803ed5a..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXLoadingTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.component; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.common.Constants; -import com.taobao.weex.ui.SimpleComponentHolder; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.lang.reflect.InvocationTargetException; - -/** - * Created by sospartan on 28/09/2016. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"}) -public class WXLoadingTest { - - public static WXLoading create() throws IllegalAccessException, InstantiationException, InvocationTargetException { - return (WXLoading) new SimpleComponentHolder(WXLoading.class).createInstance(WXSDKInstanceTest.createInstance(), new TestDomObject(), WXDivTest.create()); - } - - WXLoading component; - - @Before - public void setUp() throws Exception { - component = create(); - ComponentTest.create(component); - } - - @After - public void tearDown() throws Exception { - component.destroy(); - } - - @Test - public void testOnLoading() throws Exception { - component.onLoading(); - } - - - @Test - public void testSetProperty() throws Exception { - component.setProperty(Constants.Name.DISPLAY,WXLoading.HIDE); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXRefreshTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/WXRefreshTest.java deleted file mode 100644 index 99ca151110..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXRefreshTest.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.component; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.common.Constants; -import com.taobao.weex.ui.SimpleComponentHolder; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.lang.reflect.InvocationTargetException; - -/** - * Created by sospartan on 28/09/2016. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"}) -public class WXRefreshTest { - - public static WXRefresh create() throws IllegalAccessException, InstantiationException, InvocationTargetException { - return (WXRefresh) new SimpleComponentHolder(WXRefresh.class).createInstance(WXSDKInstanceTest.createInstance(), new TestDomObject(), WXDivTest.create()); - } - - WXRefresh component; - - @Before - public void setUp() throws Exception { - component = create(); - ComponentTest.create(component); - } - - @After - public void tearDown() throws Exception { - component.destroy(); - } - - @Test - public void testOnRefresh() throws Exception { - component.onRefresh(); - } - - @Test - public void testOnPullingDown() throws Exception { - component.onPullingDown(10,100,100); - } - - @Test - public void testSetProperty() throws Exception { - component.setProperty(Constants.Name.DISPLAY,WXRefresh.HIDE); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXScrollerTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/WXScrollerTest.java deleted file mode 100644 index 185ab2e837..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXScrollerTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.component; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.ui.view.WXScrollView; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -/** - * Created by sospartan on 8/25/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"}) -public class WXScrollerTest { - - public static WXScroller create(){ - WXDiv div = WXDivTest.create(); - ComponentTest.create(div); - WXScroller component = new WXScroller(WXSDKInstanceTest.createInstance(),new WXScrollerDomObject(),div); - div.addChild(component); - return component; - } - - - WXScroller component; - - @Before - public void setUp() throws Exception { - component = create(); - ComponentTest.create(component); - } - - @Test - public void testAddChild() throws Exception{ - WXDiv div = WXDivTest.create(component); - component.addChild(div); - ComponentTest.create(div); - - } - - @Test - public void testScroll() throws Exception { - WXScroller comp = create(); - WXDiv div = WXDivTest.create(comp); - ComponentTest.create(div); - comp.addChild(div); - ComponentTest.create(comp); - WXScrollView view = (WXScrollView) comp.getInnerView(); - view.scrollTo(100,100); - } - - @After - public void tearDown() throws Exception { - component.destroy(); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXSliderNeighborTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/WXSliderNeighborTest.java deleted file mode 100644 index 0f18fa5209..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXSliderNeighborTest.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.component; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.ui.SimpleComponentHolder; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.lang.reflect.InvocationTargetException; - -import static org.junit.Assert.*; - -/** - * Created by sospartan on 27/09/2016. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"}) -public class WXSliderNeighborTest { - - public static WXSliderNeighbor create() throws IllegalAccessException, InstantiationException, InvocationTargetException { - return (WXSliderNeighbor) new SimpleComponentHolder(WXSliderNeighbor.class).createInstance(WXSDKInstanceTest.createInstance(), new TestDomObject(), WXDivTest.create()); - } - - WXSliderNeighbor component; - - @Before - public void setUp() throws Exception { - component = create(); - ComponentTest.create(component); - } - - @Test - public void testPages() throws Exception { - component = create(); - component.addChild(ComponentTest.createComponent(new TestDomObject(),component,TestComponent.class)); - component.addChild(ComponentTest.createComponent(new TestDomObject(),component,TestComponent.class)); - component.addChild(ComponentTest.createComponent(new TestDomObject(),component,TestComponent.class)); - component.addChild(ComponentTest.createComponent(new TestDomObject(),component,TestComponent.class)); - component.addChild(ComponentTest.createComponent(new TestDomObject(),component,TestComponent.class)); - - WXIndicator indicator = new WXIndicator(component.getInstance(),new TestDomObject(),component,false); - ComponentTest.create(indicator); - component.addChild(indicator); - ComponentTest.create(component); - - assertEquals(5,component.mViewPager.getCirclePageAdapter().getRealCount()); - assertEquals(6,component.getChildCount()); - - component.mViewPager.setCurrentItem(0); - } - - @Test - public void testSetProperties() throws Exception { - component.setProperty(WXSliderNeighbor.NEIGHBOR_ALPHA,0.4f); - component.setProperty(WXSliderNeighbor.NEIGHBOR_SCALE,0.9f); - } - - @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); -// ComponentTest.create(pageChild); -// ComponentTest.create(page); - WXSliderNeighbor.ZoomTransformer transformer = component.createTransformer(); - transformer.transformPage(page.getHostView(),0.2f); - } - - @After - public void tearDown() throws Exception { - component.destroy(); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXSliderTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/WXSliderTest.java deleted file mode 100644 index 697d3b427c..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXSliderTest.java +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.component; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.ui.SimpleComponentHolder; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.lang.reflect.InvocationTargetException; - -import static com.taobao.weex.common.Constants.Name; -import static org.junit.Assert.assertEquals; - -/** - * Created by sospartan on 8/9/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"}) -public class WXSliderTest { - - WXSlider component; - - static final String[] PROPS = { - Name.AUTO_PLAY, - Name.VALUE, - "unknown", - Name.INTERVAL, - Name.INDEX, - Name.SHOW_INDICATORS - }; - - static final Object[][] VALUES = { - {"","true","false",true,false,null}, - {"","1","0",1,-1,null}, - {null,"","test"}, - {"","100","0",100,-1,null}, - {"","1","0",1,2,3,-1,null}, - {"","true","false",true,false,null} - }; - - public static WXSlider create() throws IllegalAccessException, InstantiationException, InvocationTargetException { - return (WXSlider) new SimpleComponentHolder(WXSlider.class).createInstance(WXSDKInstanceTest.createInstance(), new TestDomObject(), WXDivTest.create()); - } - - public static WXIndicator createIndicator() throws IllegalAccessException, InstantiationException, InvocationTargetException { - return (WXIndicator) new SimpleComponentHolder(WXIndicator.class).createInstance(WXSDKInstanceTest.createInstance(), new TestDomObject(), WXDivTest.create()); - } - - public static WXIndicator createIndicator(WXVContainer container) throws IllegalAccessException, InstantiationException, InvocationTargetException { - return (WXIndicator) new SimpleComponentHolder(WXIndicator.class).createInstance(WXSDKInstanceTest.createInstance(), new TestDomObject(), container); - } - - @Before - public void setup() throws Exception { - component = create(); - ComponentTest.create(component); - } - - @Test - public void testSetProperties() throws Exception { - ComponentTest.setProperty(component,PROPS,VALUES); - } - - @Test - public void testPages() throws Exception { - component = create(); - component.addChild(ComponentTest.createComponent(new TestDomObject(),component,TestComponent.class)); - component.addChild(ComponentTest.createComponent(new TestDomObject(),component,TestComponent.class)); - component.addChild(ComponentTest.createComponent(new TestDomObject(),component,TestComponent.class)); - component.addChild(ComponentTest.createComponent(new TestDomObject(),component,TestComponent.class)); - component.addChild(ComponentTest.createComponent(new TestDomObject(),component,TestComponent.class)); - - WXIndicator indicator = new WXIndicator(component.getInstance(),new TestDomObject(),component,false); - ComponentTest.create(indicator); - component.addChild(indicator); - ComponentTest.create(component); - - assertEquals(5,component.mViewPager.getCirclePageAdapter().getRealCount()); - assertEquals(6,component.getChildCount()); - - component.mViewPager.setCurrentItem(0); - } - - static final String[] IPROPS = { - Name.ITEM_SIZE, - Name.ITEM_SELECTED_COLOR, - Name.ITEM_COLOR, - "unknown" - }; - - static final Object[][] IVALUES = { - {"0",0,1,"test"}, - {"#ffffff",123,-1}, - {"#ffffff",123,-1}, - {"#ffffff",123,-1}, - }; - - @Test - public void testIndicator() throws Exception { - WXIndicator indicator = createIndicator(component); - ComponentTest.create(indicator); - component.addChild(indicator); - ComponentTest.setProperty(indicator,IPROPS,IVALUES); - } - - @Test - public void testOnScrollListener() throws Exception { - component.mViewPager.addOnPageChangeListener(new WXSlider.SliderOnScrollListener(component)); - component.setOffsetXAccuracy(0.05f); - component.mViewPager.setCurrentItem(0); - for (int index=1;index=0;index--) { - component.mViewPager.setCurrentItem(index,true); - } - component.mViewPager.setCurrentItem(3,true); - component.mViewPager.setCurrentItem(0,true); - } - - @After - public void tearDown() throws Exception { - ComponentTest.destory(component); - } - -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXSwitchTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/WXSwitchTest.java deleted file mode 100644 index 63f8d6a93a..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXSwitchTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.component; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.common.Constants; -import com.taobao.weex.ui.SimpleComponentHolder; -import com.taobao.weex.ui.view.WXSwitchView; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.lang.reflect.InvocationTargetException; - -/** - * Created by sospartan on 28/09/2016. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"}) -public class WXSwitchTest { - - public static WXSwitch create() throws IllegalAccessException, InstantiationException, InvocationTargetException { - return (WXSwitch) new SimpleComponentHolder(WXSwitch.class).createInstance(WXSDKInstanceTest.createInstance(), new TestDomObject(), WXDivTest.create()); - } - - WXSwitch component; - - @Before - public void setUp() throws Exception { - component = create(); - ComponentTest.create(component, Mockito.mock(WXSwitchView.class)); - } - - @After - public void tearDown() throws Exception { - component.destroy(); - } - - @Test - public void testAddEvent() throws Exception { - component.addEvent(Constants.Event.CHANGE); - } - - @Test - public void testSetProperty() throws Exception { - component.setProperty(Constants.Name.CHECKED,true); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXTextTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/WXTextTest.java deleted file mode 100644 index c311ffb90f..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXTextTest.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.component; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXEnvironment; -import com.taobao.weex.WXSDKInstance; -import com.taobao.weex.common.Constants; -import com.taobao.weex.ui.SimpleComponentHolder; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.Config; - -import java.util.HashMap; -import java.util.Map; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; - -/** - * Created by gulin on 16/2/4. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class) -public class WXTextTest { - private WXText mWXText; - private WXDiv mParent; - private WXTextDomObject mDomObject; - private WXDomObject mParentDomObj; - - @Before - public void setUp() throws Exception { - WXEnvironment.sApplication = RuntimeEnvironment.application; - WXSDKInstance instance = Mockito.mock(WXSDKInstance.class); - Mockito.when(instance.getContext()).thenReturn(RuntimeEnvironment.application); - - mParentDomObj = Mockito.spy(new WXDomObject()); - Mockito.when(mParentDomObj.getPadding()).thenReturn(new Spacing()); - Mockito.when(mParentDomObj.getBorder()).thenReturn(new Spacing()); - Mockito.when(mParentDomObj.clone()).thenReturn(mParentDomObj); - TestDomObject.setRef(mParentDomObj,WXDomObject.ROOT); - - mDomObject = Mockito.spy(new WXTextDomObject()); - TestDomObject.setRef(mDomObject,"1"); - mDomObject.addEvent(Constants.Event.CLICK); - Mockito.when(mDomObject.clone()).thenReturn(mDomObject); - Mockito.when(mDomObject.getPadding()).thenReturn(new Spacing()); - Mockito.when(mDomObject.getBorder()).thenReturn(new Spacing()); - Mockito.when(mDomObject.getMargin()).thenReturn(new Spacing()); - Mockito.when(mDomObject.getLayoutWidth()).thenReturn(100f); - Mockito.when(mDomObject.getLayoutHeight()).thenReturn(100f); - - mParent = new WXDiv(instance, mParentDomObj, null); - mParent.createView(); - mWXText = new WXText(instance, mDomObject, mParent); - mWXText.bindHolder(new SimpleComponentHolder(WXText.class)); - assertNotNull(instance.getContext()); - } - - @Test - public void testSetProperties() throws Exception { - mWXText.setProperty(Constants.Name.LINES,null); - mWXText.setProperty(Constants.Name.FONT_SIZE,null); - mWXText.setProperty(Constants.Name.FONT_WEIGHT,null); - mWXText.setProperty(Constants.Name.FONT_STYLE,null); - mWXText.setProperty(Constants.Name.COLOR,null); - mWXText.setProperty(Constants.Name.TEXT_DECORATION,null); - mWXText.setProperty(Constants.Name.FONT_FAMILY,null); - mWXText.setProperty(Constants.Name.TEXT_ALIGN,null); - mWXText.setProperty(Constants.Name.TEXT_OVERFLOW,null); - mWXText.setProperty(Constants.Name.LINE_HEIGHT,null); - } - - @Test - public void testCreateView(){ - mWXText.createView(); - assertNotNull(mWXText.getHostView()); - } - - @Test - public void testSetLayout(){ - testCreateView(); - mWXText.setLayout(mDomObject); - assertNotNull(mWXText.getHostView().getLayoutParams()); - assertEquals(100, mWXText.getHostView().getLayoutParams().height); - assertEquals(100, mWXText.getHostView().getLayoutParams().width); - } - - @Test - public void testSetPadding(){ - testCreateView(); - mWXText.setPadding(mDomObject.getPadding(), mDomObject.getBorder()); - assertEquals(0, mWXText.getHostView().getPaddingLeft()); - assertEquals(0, mWXText.getHostView().getPaddingTop()); - assertEquals(0, mWXText.getHostView().getPaddingRight()); - assertEquals(0, mWXText.getHostView().getPaddingBottom()); - } - - @Test - public void testBind(){ - testCreateView(); -// mWXText.bind(null); - mWXText.applyLayoutAndEvent(mWXText); - mWXText.bindData(mWXText); - - assertNotNull(mWXText.getHostView().getLayoutParams()); - assertEquals(100, mWXText.getHostView().getLayoutParams().height); - assertEquals(100, mWXText.getHostView().getLayoutParams().width); - - assertEquals(0, mWXText.getHostView().getPaddingLeft()); - assertEquals(0, mWXText.getHostView().getPaddingTop()); - assertEquals(0, mWXText.getHostView().getPaddingRight()); - assertEquals(0, mWXText.getHostView().getPaddingBottom()); - } - - @Test - public void testAddEvent(){ - testBind(); - mWXText.addEvent(Constants.Event.CLICK); - assertTrue(mWXText.getHostView().isEnabled()); - mWXText.getHostView().performClick(); - } - - @Test - public void testUpdateProperties(){ - testBind(); - Map prop = new HashMap<>(); - prop.put(Constants.Name.DISABLED, "false"); - prop.put(Constants.Name.OPACITY, 0.8f); - mWXText.updateProperties(prop); - assertTrue(mWXText.getHostView().isEnabled()); - assertEquals(0.8f, mWXText.getHostView().getAlpha(), 0.001f); - - prop.put(Constants.Name.DISABLED, "true"); - mWXText.updateProperties(prop); - assertFalse(mWXText.getHostView().isEnabled()); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXVideoTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/WXVideoTest.java deleted file mode 100644 index d01caa5cb1..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXVideoTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.component; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.common.Constants; -import com.taobao.weex.ui.SimpleComponentHolder; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.lang.reflect.InvocationTargetException; - -/** - * Created by sospartan on 8/10/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"}) -public class WXVideoTest { - - WXVideo component; - - static final String[] PROPS = { - Constants.Name.PLAY_STATUS, - Constants.Name.AUTO_PLAY, - "unknown", - Constants.Name.SRC, - }; - - static final Object[][] VALUES = { - {"", Constants.Value.PLAY, Constants.Value.PAUSE,Constants.Value.STOP,null}, - {"","true","false",true,false,null}, - {null,"","test"}, - {"","http://taobao.com","0",100,null}, - }; - - public static WXVideo create() throws IllegalAccessException, InstantiationException, InvocationTargetException { - return (WXVideo) new SimpleComponentHolder(WXVideo.class) - .createInstance(WXSDKInstanceTest.createInstance(), new TestDomObject(), WXDivTest.create()); - } - - @Before - public void setUp() throws Exception { - component = create(); - ComponentTest.create(component); - } - - @After - public void tearDown() throws Exception { - ComponentTest.destory(component); - } - - @Test - public void testSetProperty() throws Exception { - component.mPrepared = true; - ComponentTest.setProperty(component,PROPS,VALUES); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXWebTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/WXWebTest.java deleted file mode 100644 index 53d1773818..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/component/WXWebTest.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.component; - -import android.view.View; -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.common.Constants; -import com.taobao.weex.ui.SimpleComponentHolder; -import com.taobao.weex.ui.view.IWebView; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; -import java.util.Map; - -/** - * Created by sospartan on 28/09/2016. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"}) -public class WXWebTest { - - public static WXWeb create() throws IllegalAccessException, InstantiationException, InvocationTargetException { - return (WXWeb) new SimpleComponentHolder(WXWeb.class).createInstance(WXSDKInstanceTest.createInstance(), new TestDomObject(), WXDivTest.create()); - } - - WXWeb component; - ProxyWebView mWebView; - - static class ProxyWebView implements IWebView { - IWebView mIWebView; - OnPageListener mOnPageListener; - OnErrorListener mOnErrorListener; - OnMessageListener mOnMessageListener; - - ProxyWebView(IWebView proxy){ - mIWebView = proxy; - } - - @Override - public View getView() { - return mIWebView.getView(); - } - - @Override - public void destroy() { - mIWebView.destroy(); - } - - @Override - public void loadUrl(String url) { - mIWebView.loadUrl(url); - } - - @Override - public void loadDataWithBaseURL(String source) { - mIWebView.loadDataWithBaseURL(source); - } - - @Override - public void reload() { - mIWebView.reload(); - } - - @Override - public void goBack() { - mIWebView.goBack(); - } - - @Override - public void goForward() { - mIWebView.goForward(); - } - - @Override - public void postMessage(Object msg) {} - - @Override - public void setShowLoading(boolean shown) { - mIWebView.setShowLoading(shown); - } - - @Override - public void setOnErrorListener(OnErrorListener listener) { - mIWebView.setOnErrorListener(listener); - mOnErrorListener = listener; - } - - @Override - public void setOnPageListener(OnPageListener listener) { - mIWebView.setOnPageListener(listener); - mOnPageListener = listener; - } - - @Override - public void setOnMessageListener(OnMessageListener listener) { - mIWebView.setOnMessageListener(listener); - mOnMessageListener = listener; - } - } - - @Before - public void setUp() throws Exception { - component = create(); - mWebView = new ProxyWebView(component.mWebView); - component.mWebView = mWebView; - ComponentTest.create(component); - - } - - @After - public void tearDown() throws Exception { - component.destroy(); - } - - @Test - public void testSetProperty() throws Exception { - component.setProperty(Constants.Name.SHOW_LOADING,true); - component.setProperty(Constants.Name.SRC,"http://taobao.com"); - component.setProperty(Constants.Name.SOURCE, "

hello weex

"); - } - - @Test - public void testSetAction() throws Exception { - Map msg = new HashMap<>(); - msg.put("test1", 1); - msg.put("test2", "2"); - component.setAction(WXWeb.GO_BACK, null); - component.setAction(WXWeb.GO_FORWARD, null); - component.setAction(WXWeb.RELOAD, null); - component.setAction(WXWeb.POST_MESSAGE, msg); - } - - @Test - public void testListener() throws Exception { - Map msg = new HashMap<>(); - msg.put("test1", 1); - msg.put("test2", "2"); - component.addEvent(Constants.Event.RECEIVEDTITLE); - component.addEvent(Constants.Event.PAGESTART); - component.addEvent(Constants.Event.PAGEFINISH); - component.addEvent(Constants.Event.ERROR); - component.addEvent(Constants.Event.ONMESSAGE); - mWebView.mOnPageListener.onPageFinish("http://taobao.com",true,true); - mWebView.mOnPageListener.onReceivedTitle("test"); - mWebView.mOnPageListener.onPageStart("http://taobao.com"); - mWebView.mOnErrorListener.onError("test","error occurred"); - mWebView.mOnMessageListener.onMessage(msg); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/helper/WXTimeInputHelperTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/helper/WXTimeInputHelperTest.java deleted file mode 100644 index f9e9ee2ab1..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/component/helper/WXTimeInputHelperTest.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.component.helper; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.appfram.pickers.DatePickerImpl; - -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.rule.PowerMockRule; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.lang.reflect.Method; - -/** - * Created by moxun on 16/10/24. - */ - -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "android.*", "org.json.*"}) -@PrepareForTest() -public class WXTimeInputHelperTest { - @Rule - public PowerMockRule rule = new PowerMockRule(); - - @Test - public void testParseDate() throws Exception{ - Method parseDate = DatePickerImpl.class.getDeclaredMethod("parseDate", String.class); - parseDate.setAccessible(true); - parseDate.invoke(null, ""); - parseDate.invoke(null, "test"); - parseDate.invoke(null, "2016-12-11"); - parseDate.invoke(null, "2016-1-1"); - parseDate.invoke(null, "9999-99-99"); - } - - @Test - public void testParseTime() throws Exception{ - Method parseTime = DatePickerImpl.class.getDeclaredMethod("parseTime", String.class); - parseTime.setAccessible(true); - parseTime.invoke(null, ""); - parseTime.invoke(null, "test"); - parseTime.invoke(null, "11:11"); - parseTime.invoke(null, "1:1"); - parseTime.invoke(null, "25:61"); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/list/DefaultDragHelperTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/list/DefaultDragHelperTest.java deleted file mode 100644 index 474bdcf0a5..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/component/list/DefaultDragHelperTest.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.component.list; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.ui.SimpleComponentHolder; -import com.taobao.weex.ui.component.ComponentTest; -import com.taobao.weex.ui.component.WXComponent; -import com.taobao.weex.ui.component.WXDiv; -import com.taobao.weex.ui.component.WXDivTest; -import com.taobao.weex.ui.component.WXVContainer; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.lang.reflect.InvocationTargetException; -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.mockito.Matchers.anyMap; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"}) -public class DefaultDragHelperTest { - - WXListComponent listComponent; - - WXCell fakeCell; - - private DragHelper mFakeDragHelper; - - private EventTrigger mockedEventTrigger; - - private WXComponent c1; - private WXComponent c2; - private WXComponent c3; - - private List mFakeDataSource; - - public static WXListComponent create(WXVContainer parent) throws IllegalAccessException, InstantiationException, InvocationTargetException { - return create(parent,new WXListDomObject()); - } - - public static WXListComponent create(WXVContainer parent, WXDomObject dom) throws IllegalAccessException, InstantiationException, InvocationTargetException { - return (WXListComponent) new SimpleComponentHolder(WXListComponent.class).createInstance(WXSDKInstanceTest.createInstance(), dom, parent); - } - - @Before - public void setUp() throws Exception { - WXDiv div = WXDivTest.create(); - ComponentTest.create(div); - listComponent = create(div); - ComponentTest.create(listComponent); - - fakeCell = new WXCell(WXSDKInstanceTest.createInstance(),new TestDomObject(),null,false); - - c1 = new WXCell(WXSDKInstanceTest.createInstance(),new TestDomObject(),null,false); - c2 = new WXCell(WXSDKInstanceTest.createInstance(),new TestDomObject(),null,false); - c3 = new WXCell(WXSDKInstanceTest.createInstance(),new TestDomObject(),null,false); - - mFakeDataSource = new ArrayList<>(); - mFakeDataSource.add(c1); - mFakeDataSource.add(c2); - mFakeDataSource.add(c3); - - mockedEventTrigger = mock(EventTrigger.class); - - mFakeDragHelper = new DefaultDragHelper(mFakeDataSource,listComponent.getHostView().getInnerView(), mockedEventTrigger); - } - - @After - public void tearDown() throws Exception { - listComponent.destroy(); - } - - @Test - public void onDragStart() throws Exception { - WXComponent c = new WXCell(WXSDKInstanceTest.createInstance(),new TestDomObject(),null,false); - mFakeDragHelper.onDragStart(c,3); - verify(mockedEventTrigger).triggerEvent(eq("dragstart"),anyMap()); - } - - @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()); - } - - @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); - } - - -} \ No newline at end of file diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/component/list/WXListComponentTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/component/list/WXListComponentTest.java deleted file mode 100644 index feb2b05d3c..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/component/list/WXListComponentTest.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.component.list; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.ui.SimpleComponentHolder; -import com.taobao.weex.ui.component.ComponentTest; -import com.taobao.weex.ui.component.WXComponent; -import com.taobao.weex.ui.component.WXDiv; -import com.taobao.weex.ui.component.WXDivTest; -import com.taobao.weex.ui.component.WXHeaderTest; -import com.taobao.weex.ui.component.WXVContainer; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.lang.reflect.InvocationTargetException; -import java.util.HashMap; -import java.util.Map; - -/** - * Created by sospartan on 8/29/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"}) -public class WXListComponentTest { - - WXListComponent component; - - public static WXListComponent create(WXVContainer parent) throws IllegalAccessException, InstantiationException, InvocationTargetException { - return create(parent,new WXListDomObject()); - } - - public static WXListComponent create(WXVContainer parent, WXDomObject dom) throws IllegalAccessException, InstantiationException, InvocationTargetException { - return (WXListComponent) new SimpleComponentHolder(WXListComponent.class).createInstance(WXSDKInstanceTest.createInstance(), dom, parent); - } - - @Before - public void setUp() throws Exception { - WXDiv div = WXDivTest.create(); - ComponentTest.create(div); - component = create(div); - ComponentTest.create(component); - } - - @Test - public void testAddChild() throws Exception { - WXComponent child = WXDivTest.create(component); - ComponentTest.create(child); - component.addChild(child); - - child = WXHeaderTest.create(component); - ComponentTest.create(child); - component.addChild(child); - - } - - @Test - public void testScrollTo() throws Exception { - WXComponent child = WXDivTest.create(component); - ComponentTest.create(child); - component.addChild(child); - - child = WXHeaderTest.create(component); - ComponentTest.create(child); - component.addChild(child); - - Map options = new HashMap<>(2); - options.put("offset", 10); - options.put("animated", false); - component.scrollTo(child,options); - } - - @Test - public void testAppear() throws Exception { - WXComponent child = WXDivTest.create(component); - ComponentTest.create(child); - component.addChild(child); - - component.bindAppearEvent(child); - - component.notifyAppearStateChange(0,0,0,10); - } - - @Test - public void testParseTransforms() throws Exception { - WXDiv div = WXDivTest.create(); - ComponentTest.create(div); - - WXDomObject dom = new WXListDomObject(); - dom.getAttrs().put(WXListComponent.TRANSFORM,"scale(0.9,0.8);translate(10,20);opacity(0.5);rotate(100)"); - component = create(div,dom); - ComponentTest.create(component); - } - - @After - public void tearDown() throws Exception { - component.destroy(); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/module/WXMetaModuleTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/module/WXMetaModuleTest.java deleted file mode 100644 index d58a0dcf70..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/module/WXMetaModuleTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.module; - -import com.alibaba.fastjson.JSONObject; -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.bridge.WXBridgeManager; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import static junit.framework.Assert.assertTrue; - -/** - * Created by zhengshihan on 16/12/21. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore({ "org.mockito.*", "org.robolectric.*", "android.*" }) -@PrepareForTest(WXBridgeManager.class) -public class WXMetaModuleTest { - - WXMetaModule mMeta; - @Before - public void setUp() throws Exception { - mMeta = new WXMetaModule(); - mMeta.mWXSDKInstance = WXSDKInstanceTest.createInstance(); - - } - - @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); - } - -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/module/WXModalUIModuleTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/module/WXModalUIModuleTest.java deleted file mode 100644 index 17d3fba056..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/module/WXModalUIModuleTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.module; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.bridge.JSCallback; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.rule.PowerMockRule; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -/** - * Created by sospartan on 7/28/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore({ "org.mockito.*", "org.robolectric.*", "android.*","org.json.*" }) -@PrepareForTest() -public class WXModalUIModuleTest { - - @Rule - public PowerMockRule rule = new PowerMockRule(); - - WXModalUIModule module; - - @Before - public void setUp() throws Exception { - module = new WXModalUIModule(); - module.mWXSDKInstance = WXSDKInstanceTest.createInstance(); - - } - - @Test - public void testToast() throws Exception { - module.toast("{}"); - } - - @Test - public void testAlert() throws Exception { - JSCallback callback = Mockito.mock(JSCallback.class); - module.alert("{}",callback); - - } - - @Test - public void testConfirm() throws Exception { - JSCallback callback = Mockito.mock(JSCallback.class); - module.confirm("{}",callback); - } - - @Test - public void testPrompt() throws Exception { - JSCallback callback = Mockito.mock(JSCallback.class); - module.prompt("{}",callback); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/module/WXTimerModuleTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/module/WXTimerModuleTest.java deleted file mode 100644 index 7fe508c410..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/module/WXTimerModuleTest.java +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.module; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.when; - -import android.os.Handler; -import android.os.Message; -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.InitConfig; -import com.taobao.weex.WXSDKEngine; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.bridge.WXBridgeManager; -import com.taobao.weex.bridge.WXBridgeManagerTest; -import com.taobao.weex.common.WXThread; -import java.util.concurrent.TimeUnit; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.rule.PowerMockRule; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; -import org.robolectric.Shadows; -import org.robolectric.annotation.Config; -import org.robolectric.shadows.ShadowLooper; - -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class) -@PowerMockIgnore({"org.mockito.*", "org.robolectric.*", "android.*"}) -@PrepareForTest(WXBridgeManager.class) -public class WXTimerModuleTest { - - public final static int VALID_FUNC_ID = 20; - public final static int NO_CACHING_FUNC_ID = 565654; - public final static int INVALID_FUNC_ID = 0; - public final static int DELAY = 50; - public final static int IMMEDIATELY = 0; - public final static int INVALID_DELAY = -50; - - @Rule - public PowerMockRule rule = new PowerMockRule(); - WXTimerModule module; - ShadowLooper mLooper; - - @Before - public void setup() throws Exception { - WXSDKEngine.initialize(RuntimeEnvironment.application, new InitConfig.Builder().build()); - WXBridgeManager bridge = Mockito.mock(WXBridgeManager.class); - when(bridge.getJSLooper()).thenReturn(new WXThread("js").getLooper()); - WXBridgeManagerTest.setBridgeManager(bridge); - - module = Mockito.spy(new WXTimerModule()); - module.mWXSDKInstance = WXSDKInstanceTest.createInstance(); - Handler handler = new Handler(WXBridgeManager.getInstance().getJSLooper(), module); - mLooper = Shadows.shadowOf(handler.getLooper()); - module.setHandler(handler); - } - - @Test - public void testSetTimeoutDelay() throws Exception { - module.setTimeout(VALID_FUNC_ID, DELAY); - mLooper.idle(DELAY); - Mockito.verify(module, times(1)).handleMessage(any(Message.class)); - } - - @Test - public void testSetTimeoutImmediately() throws Exception { - module.setTimeout(VALID_FUNC_ID, IMMEDIATELY); - mLooper.idle(IMMEDIATELY); - Mockito.verify(module, times(1)).handleMessage(any(Message.class)); - } - - @SuppressWarnings("Range") - @Test - public void testSetTimeoutError1() throws Exception { - module.setTimeout(INVALID_FUNC_ID, DELAY); - mLooper.idle(DELAY); - Mockito.verify(module, never()).handleMessage(any(Message.class)); - } - - @SuppressWarnings("Range") - @Test - public void testSetTimeoutError2() throws Exception { - module.setTimeout(VALID_FUNC_ID, INVALID_DELAY); - mLooper.runToEndOfTasks(); - Mockito.verify(module, never()).handleMessage(any(Message.class)); - } - - @SuppressWarnings("Range") - @Test - public void testSetIntervalError1() throws Exception { - module.setInterval(INVALID_FUNC_ID, DELAY); - mLooper.idle(DELAY); - Mockito.verify(module, never()).handleMessage(any(Message.class)); - } - - @SuppressWarnings("Range") - @Test - public void testSetIntervalError2() throws Exception { - module.setInterval(VALID_FUNC_ID, INVALID_DELAY); - mLooper.runToEndOfTasks(); - Mockito.verify(module, never()).handleMessage(any(Message.class)); - } - - @Test - public void testSetIntervalImmediately() throws Exception { - long start, end, duration; - module.setInterval(VALID_FUNC_ID, DELAY); - - start = mLooper.getScheduler().getCurrentTime(); - mLooper.runOneTask(); - end = mLooper.getScheduler().getCurrentTime(); - duration = end - start; - - assertThat(duration, is((long) DELAY)); - - mLooper.runOneTask(); - mLooper.runOneTask(); - mLooper.runOneTask(); - mLooper.runOneTask(); - Mockito.verify(module, times(5)).handleMessage(any(Message.class)); - } - - @Test - public void testSetIntervalDelay() { - long start, end, duration; - module.setInterval(VALID_FUNC_ID, DELAY); - - start = mLooper.getScheduler().getCurrentTime(); - mLooper.runOneTask(); - end = mLooper.getScheduler().getCurrentTime(); - duration = end - start; - - assertThat(duration, is((long) DELAY)); - - mLooper.runOneTask(); - mLooper.runOneTask(); - Mockito.verify(module, times(3)).handleMessage(any(Message.class)); - } - - @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)); - } - - @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)); - } - - @Test - public void setClearTimeout2(){ - module.setTimeout(NO_CACHING_FUNC_ID, DELAY); - module.clearTimeout(NO_CACHING_FUNC_ID); - mLooper.idle(DELAY, TimeUnit.MILLISECONDS); - Mockito.verify(module, never()).handleMessage(any(Message.class)); - } - - @Test - public void setClearInterval2(){ - module.setInterval(NO_CACHING_FUNC_ID, DELAY); - module.clearInterval(NO_CACHING_FUNC_ID); - mLooper.idle(DELAY, TimeUnit.MILLISECONDS); - Mockito.verify(module, never()).handleMessage(any(Message.class)); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/module/WXWebViewModuleTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/module/WXWebViewModuleTest.java deleted file mode 100644 index acb8e869d3..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/module/WXWebViewModuleTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.module; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXSDKInstance; -import com.taobao.weex.WXSDKInstanceTest; -import com.taobao.weex.bridge.WXBridgeManager; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import static org.junit.Assert.*; - -/** - * Created by sospartan on 7/28/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore({ "org.mockito.*", "org.robolectric.*", "android.*" }) -@PrepareForTest(WXBridgeManager.class) -public class WXWebViewModuleTest { - WXWebViewModule module; - - @Before - public void setUp() throws Exception { - module = new WXWebViewModule(); - module.mWXSDKInstance = WXSDKInstanceTest.createInstance(); - } - - @Test - public void testGoBack() throws Exception { - module.goBack(""); - } - - @Test - public void testGoForward() throws Exception { - module.goForward(""); - } - - @Test - public void testReload() throws Exception { - module.reload(""); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/view/WXCirclePageAdapterTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/view/WXCirclePageAdapterTest.java deleted file mode 100644 index 90b96f7e77..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/view/WXCirclePageAdapterTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.view; - -import android.app.Activity; -import android.support.v4.view.ViewPager; -import android.view.View; -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.TestActivity; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.robolectric.Robolectric; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import static org.junit.Assert.*; - -/** - * Created by sospartan on 9/7/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"}) -public class WXCirclePageAdapterTest { - - WXCirclePageAdapter adapter; - View child; - - @Before - public void setUp() throws Exception { - adapter = new WXCirclePageAdapter(); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testAddPageView() throws Exception { - Activity activity = Robolectric.setupActivity(TestActivity.class); - child = new View(activity); - adapter.addPageView(child); - child = new View(activity); - adapter.addPageView(child); - child = new View(activity); - adapter.addPageView(child); - - assertEquals(adapter.getRealCount(),3); - } - - @Test - public void testRemovePageView() throws Exception { - testAddPageView(); - adapter.removePageView(child); - assertEquals(adapter.getRealCount(),2); - } - - - @Test - public void testInstantiateItem() throws Exception { - testAddPageView(); - ViewPager viewPager = new ViewPager(child.getContext()); - viewPager.setAdapter(adapter); - Object obj = adapter.instantiateItem(viewPager,adapter.getRealCount()); - assertEquals(child,obj); - } - - @Test - public void testReplacePageView() throws Exception { - testAddPageView(); - View relace = new View(child.getContext()); - - adapter.replacePageView(child,relace); - - assertEquals(adapter.getRealCount(),3); - - } - - @Test - public void testGetRealPosition() throws Exception { - testAddPageView(); - assertEquals(adapter.getRealPosition(0), adapter.getRealCount() - 1); - assertEquals(adapter.getRealPosition(1), 0); - assertEquals(adapter.getRealPosition(adapter.getRealCount() + 1), 0); - assertEquals(adapter.getRealPosition(100), -1); - assertEquals(adapter.getRealPosition(-1), -1); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/view/WXScrollViewTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/view/WXScrollViewTest.java deleted file mode 100644 index 3873aa1a9b..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/view/WXScrollViewTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.view; - -import android.app.Activity; -import android.view.MotionEvent; -import android.view.View; -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.TestActivity; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.robolectric.Robolectric; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.Config; - -import static org.junit.Assert.*; - -/** - * Created by sospartan on 9/7/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"}) -public class WXScrollViewTest { - - WXScrollView view; - - static final int[] EVENTS = {MotionEvent.ACTION_DOWN,MotionEvent.ACTION_MOVE,MotionEvent.ACTION_UP}; - - @Before - public void setUp() throws Exception { - Activity activity = Robolectric.setupActivity(TestActivity.class); - view = new WXScrollView(activity); - View child = new View(activity); - view.addView(child); - } - - @After - public void tearDown() throws Exception { - view.destroy(); - } - - @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(); - } - } - - @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(); - } - } - - @Test - public void testOnScrollChanged() throws Exception { - view.onScrollChanged(0,10,0,20); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/view/WXWebViewTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/view/WXWebViewTest.java deleted file mode 100644 index 7b8b5cdad8..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/view/WXWebViewTest.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.view; - -import static org.junit.Assert.assertNotNull; - -import android.app.Activity; -import android.view.ViewGroup; -import android.webkit.WebChromeClient; -import android.webkit.WebView; -import android.webkit.WebViewClient; -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.TestActivity; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.robolectric.Robolectric; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.Shadows; -import org.robolectric.annotation.Config; -import org.robolectric.shadows.ShadowWebView; - -import java.util.HashMap; -import java.util.Map; - -/** - * Created by sospartan on 9/7/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"}) -public class WXWebViewTest { - - IWebView view; - WebView webView; - ShadowWebView shadow; - - @Before - public void setUp() throws Exception { - Activity activity = Robolectric.setupActivity(TestActivity.class); - view = new WXWebView(activity, null); - webView = (WebView)((ViewGroup)view.getView()).getChildAt(0);//first child - shadow = Shadows.shadowOf(webView); - } - - @After - public void tearDown() throws Exception { - view.destroy(); - } - - @Test - public void testDestory() throws Exception { - - } - - @Test - public void testGetView() throws Exception { - assertNotNull(view); - } - - @Test - public void testLoadUrl() throws Exception { - String url = "http://www.taobao.com"; - view.loadUrl(url); - WebViewClient client = shadow.getWebViewClient(); - client.onPageStarted(webView,url,null); - client.onPageFinished(webView,url); - - WebChromeClient chromeClient = shadow.getWebChromeClient(); - chromeClient.onProgressChanged(webView,10); - chromeClient.onProgressChanged(webView,100); - chromeClient.onReceivedTitle(webView,"test"); - - } - - @Test - public void testLoadDataWithBaseURL() throws Exception { - String source = "

hello weex

"; - view.loadDataWithBaseURL(source); - } - - - @Test - public void testReload() throws Exception { - view.reload(); - testLoadUrl(); - view.reload(); - } - - @Test - public void testGoBack() throws Exception { - testLoadUrl(); - view.loadUrl("http://www.w3c.org"); - view.goBack(); - } - - @Test - public void testGoForward() throws Exception { - testGoBack(); - view.goForward(); - } - - @Test - public void testPostMessage() throws Exception { - Map msg = new HashMap<>(); - msg.put("test1", 1); - msg.put("test2", "2"); - view.postMessage(msg); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/view/border/BorderCornerTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/view/border/BorderCornerTest.java deleted file mode 100644 index 827e632174..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/view/border/BorderCornerTest.java +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.taobao.weex.ui.view.border; - -import android.graphics.Point; -import android.graphics.PointF; -import android.graphics.RectF; -import android.support.annotation.Nullable; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Set; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.*; - -@RunWith(RobolectricTestRunner.class) -@Config(manifest = Config.NONE) -public class BorderCornerTest { - - private final static String TOP_LEFT = "TopLeft"; - private final static String TOP_RIGHT = "TopRight"; - private final static String BOTTOM_RIGHT = "BottomRight"; - private final static String BOTTOM_LEFT = "BottomLeft"; - - private List borderCorners = new ArrayList<>(); - private RectF borderBox = new RectF(0, 0, 400, 400); - private List radiusList = Arrays.asList(-10f, 0f, 10f, 25f, 50f, 75f, 150f); - private List preWidthList = Arrays.asList(-10f, 0f, 10f, 50f, 100f); - private List postWidthList = Arrays.asList(-10f, 0f, 10f, 50f, 100f); - private List cornerList = Arrays.asList(TOP_LEFT, TOP_RIGHT, BOTTOM_RIGHT, BOTTOM_LEFT); - - private - @Nullable - BorderCorner createBorderCorner(String corner, float - radius, float preWidth, float postWidth, RectF borderBox) { - switch (corner) { - case TOP_LEFT: - return new TopLeftCorner(radius, preWidth, postWidth, borderBox); - case TOP_RIGHT: - return new TopRightCorner(radius, preWidth, postWidth, borderBox); - case BOTTOM_RIGHT: - return new BottomRightCorner(radius, preWidth, postWidth, borderBox); - case BOTTOM_LEFT: - return new BottomLeftCorner(radius, preWidth, postWidth, borderBox); - default: - return null; - } - } - - @Before - public void setUp() throws Exception { - - } - - @After - public void tearDown() throws Exception { - borderCorners.clear(); - } - - @Test - public void testHasOuterCorner() throws Exception { - for (float preWidth : preWidthList) { - for (float postWidth : postWidthList) { - for (String corner : cornerList) { - assertThat(createBorderCorner(corner, 0f, preWidth, postWidth, borderBox).hasOuterCorner(), is(false)); - assertThat(createBorderCorner(corner, 50f, preWidth, postWidth, borderBox) - .hasOuterCorner(), is(true)); - assertThat(createBorderCorner(corner, -10f, preWidth, postWidth, borderBox) - .hasOuterCorner(), is(false)); - } - } - } - } - - @Test - public void testHasInnerCorner() throws Exception { - for (String corner : cornerList) { - for (float preWidth : preWidthList) { - for (float postWidth : postWidthList) { - assertThat(createBorderCorner(corner, -10, preWidth, postWidth, borderBox).hasInnerCorner() - , is(false)); - assertThat(createBorderCorner(corner, 0, preWidth, postWidth, borderBox) - .hasInnerCorner() - , is(false)); - } - } - assertThat(createBorderCorner(corner, 25, -10, -10, borderBox).hasInnerCorner() - , is(false)); - assertThat(createBorderCorner(corner, 25, -10, 0, borderBox).hasInnerCorner() - , is(false)); - assertThat(createBorderCorner(corner, 25, -10, 10, borderBox).hasInnerCorner() - , is(false)); - assertThat(createBorderCorner(corner, 25, -10, 50, borderBox).hasInnerCorner() - , is(false)); - assertThat(createBorderCorner(corner, 25, 0, -10, borderBox).hasInnerCorner() - , is(false)); - assertThat(createBorderCorner(corner, 25, 0, 0, borderBox).hasInnerCorner() - , is(true)); - assertThat(createBorderCorner(corner, 25, 0, 10, borderBox).hasInnerCorner() - , is(true)); - assertThat(createBorderCorner(corner, 25, 0, 50, borderBox).hasInnerCorner() - , is(false)); - assertThat(createBorderCorner(corner, 25, 10, -10, borderBox).hasInnerCorner() - , is(false)); - assertThat(createBorderCorner(corner, 25, 10, 0, borderBox).hasInnerCorner() - , is(true)); - assertThat(createBorderCorner(corner, 25, 10, 10, borderBox).hasInnerCorner() - , is(true)); - assertThat(createBorderCorner(corner, 25, 10, 50, borderBox).hasInnerCorner() - , is(false)); - assertThat(createBorderCorner(corner, 25, 50, -10, borderBox).hasInnerCorner() - , is(false)); - assertThat(createBorderCorner(corner, 25, 50, 0, borderBox).hasInnerCorner() - , is(false)); - assertThat(createBorderCorner(corner, 25, 50, 10, borderBox).hasInnerCorner() - , is(false)); - assertThat(createBorderCorner(corner, 25, 50, 50, borderBox).hasInnerCorner() - , is(false)); - } - } - - @Test - public void testGetCornerStart() throws Exception { - PointF topLeft = createBorderCorner(TOP_LEFT, 25, 10, 50, borderBox) - .getCornerStart(); - assertThat(topLeft.x, is(5f)); - assertThat(topLeft.y, is(25f)); - PointF topRight = createBorderCorner(TOP_RIGHT, 25, 10, 50, borderBox) - .getCornerStart(); - assertThat(topRight.x, is(375f)); - assertThat(topRight.y, is(5f)); - PointF bottomRight = createBorderCorner(BOTTOM_RIGHT, 25, 10, 50, borderBox) - .getCornerStart(); - assertThat(bottomRight.x, is(395f)); - assertThat(bottomRight.y, is(375f)); - PointF bottomLeft = createBorderCorner(BOTTOM_LEFT, 25, 10, 50, borderBox) - .getCornerStart(); - assertThat(bottomLeft.x, is(25f)); - assertThat(bottomLeft.y, is(395f)); - } - - @Test - public void testGetCornerEnd() throws Exception { - PointF topLeft = createBorderCorner(TOP_LEFT, 0, 10, 50, borderBox) - .getCornerEnd(); - assertThat(topLeft.x, is(5f)); - assertThat(topLeft.y, is(25f)); - PointF topRight = createBorderCorner(TOP_RIGHT, 0, 10, 50, borderBox) - .getCornerEnd(); - assertThat(topRight.x, is(375f)); - assertThat(topRight.y, is(5f)); - PointF bottomRight = createBorderCorner(BOTTOM_RIGHT, 0, 10, 50, borderBox) - .getCornerEnd(); - assertThat(bottomRight.x, is(395f)); - assertThat(bottomRight.y, is(375f)); - PointF bottomLeft = createBorderCorner(BOTTOM_LEFT, 0, 10, 50, borderBox) - .getCornerEnd(); - assertThat(bottomLeft.x, is(25f)); - assertThat(bottomLeft.y, is(395f)); - } - - @Test - public void testGetRoundCornerStart() throws Exception { - PointF topLeft = createBorderCorner(TOP_LEFT, 25, 10, 50, borderBox) - .getRoundCornerStart(); - assertThat(topLeft.x, is(5f)); - assertThat(topLeft.y, is(25f)); - PointF topRight = createBorderCorner(TOP_RIGHT, 25, 10, 50, borderBox) - .getRoundCornerStart(); - assertThat(topRight.x, is(375f)); - assertThat(topRight.y, is(5f)); - PointF bottomRight = createBorderCorner(BOTTOM_RIGHT, 25, 10, 50, borderBox) - .getRoundCornerStart(); - assertThat(bottomRight.x, is(395f)); - assertThat(bottomRight.y, is(375f)); - PointF bottomLeft = createBorderCorner(BOTTOM_LEFT, 25, 10, 50, borderBox) - .getRoundCornerStart(); - assertThat(bottomLeft.x, is(25f)); - assertThat(bottomLeft.y, is(395f)); - } - - @Test - public void testGetRoundCornerEnd() throws Exception { - PointF topLeft = createBorderCorner(TOP_LEFT, 25, 10, 50, borderBox) - .getRoundCornerEnd(); - assertThat(topLeft.x, is(25f)); - assertThat(topLeft.y, is(25f)); - PointF topRight = createBorderCorner(TOP_RIGHT, 25, 10, 50, borderBox) - .getRoundCornerEnd(); - assertThat(topRight.x, is(375f)); - assertThat(topRight.y, is(25f)); - PointF bottomRight = createBorderCorner(BOTTOM_RIGHT, 25, 10, 50, borderBox) - .getRoundCornerEnd(); - assertThat(bottomRight.x, is(375f)); - assertThat(bottomRight.y, is(375f)); - PointF bottomLeft = createBorderCorner(BOTTOM_LEFT, 25, 10, 50, borderBox) - .getRoundCornerEnd(); - assertThat(bottomLeft.x, is(25f)); - assertThat(bottomLeft.y, is(375f)); - } - - @Test - public void testGetSharpCornerVertex() throws Exception { - PointF topLeft = createBorderCorner(TOP_LEFT, 0, 10, 50, borderBox) - .getSharpCornerVertex(); - assertThat(topLeft.x, is(5f)); - assertThat(topLeft.y, is(25f)); - PointF topRight = createBorderCorner(TOP_RIGHT, 0, 10, 50, borderBox) - .getSharpCornerVertex(); - assertThat(topRight.x, is(375f)); - assertThat(topRight.y, is(5f)); - PointF bottomRight = createBorderCorner(BOTTOM_RIGHT, 0, 10, 50, borderBox) - .getSharpCornerVertex(); - assertThat(bottomRight.x, is(395f)); - assertThat(bottomRight.y, is(375f)); - PointF bottomLeft = createBorderCorner(BOTTOM_LEFT, 0, 10, 50, borderBox) - .getSharpCornerVertex(); - assertThat(bottomLeft.x, is(25f)); - assertThat(bottomLeft.y, is(395f)); - } - - @Test - public void testGetSharpCornerStart() throws Exception { - PointF topLeft = createBorderCorner(TOP_LEFT, 0, 10, 50, borderBox) - .getSharpCornerStart(); - assertThat(topLeft.x, is(0f)); - assertThat(topLeft.y, is(25f)); - PointF topRight = createBorderCorner(TOP_RIGHT, 0, 10, 50, borderBox) - .getSharpCornerStart(); - assertThat(topRight.x, is(375f)); - assertThat(topRight.y, is(0f)); - PointF bottomRight = createBorderCorner(BOTTOM_RIGHT, 0, 10, 50, borderBox) - .getSharpCornerStart(); - assertThat(bottomRight.x, is(400f)); - assertThat(bottomRight.y, is(375f)); - PointF bottomLeft = createBorderCorner(BOTTOM_LEFT, 0, 10, 50, borderBox) - .getSharpCornerStart(); - assertThat(bottomLeft.x, is(25f)); - assertThat(bottomLeft.y, is(400f)); - } - - @Test - public void testGetSharpCornerEnd() throws Exception { - PointF topLeft = createBorderCorner(TOP_LEFT, 0, 10, 50, borderBox) - .getSharpCornerEnd(); - assertThat(topLeft.x, is(5f)); - assertThat(topLeft.y, is(0f)); - PointF topRight = createBorderCorner(TOP_RIGHT, 0, 10, 50, borderBox) - .getSharpCornerEnd(); - assertThat(topRight.x, is(400f)); - assertThat(topRight.y, is(5f)); - PointF bottomRight = createBorderCorner(BOTTOM_RIGHT, 0, 10, 50, borderBox) - .getSharpCornerEnd(); - assertThat(bottomRight.x, is(395f)); - assertThat(bottomRight.y, is(400f)); - PointF bottomLeft = createBorderCorner(BOTTOM_LEFT, 0, 10, 50, borderBox) - .getSharpCornerEnd(); - assertThat(bottomLeft.x, is(0f)); - assertThat(bottomLeft.y, is(395f)); - } - - @Test - public void testGetOvalIfInnerCornerExist() throws Exception { - RectF topLeft = createBorderCorner(TOP_LEFT, 100, 10, 50, borderBox) - .getOvalIfInnerCornerExist(); - assertThat(topLeft, is(new RectF(5, 25, 195, 175))); - RectF topRight = createBorderCorner(TOP_RIGHT, 100, 10, 50, borderBox) - .getOvalIfInnerCornerExist(); - assertThat(topRight, is(new RectF(225, 5, 375, 195))); - RectF bottomRight = createBorderCorner(BOTTOM_RIGHT, 100, 10, 50, borderBox) - .getOvalIfInnerCornerExist(); - assertThat(bottomRight, is(new RectF(205, 225, 395, 375))); - RectF bottomLeft = createBorderCorner(BOTTOM_LEFT, 100, 10, 50, borderBox) - .getOvalIfInnerCornerExist(); - assertThat(bottomLeft, is(new RectF(25, 205, 175, 395))); - } - - @Test - public void testGetOvalIfInnerCornerNotExist() throws Exception { - RectF topLeft = createBorderCorner(TOP_LEFT, 50, 10, 50, borderBox).getOvalIfInnerCornerNotExist(); - assertThat(topLeft, is(new RectF(25, 25, 75, 75))); - RectF topRight = createBorderCorner(TOP_RIGHT, 50, 10, 50, borderBox).getOvalIfInnerCornerNotExist(); - assertThat(topRight, is(new RectF(325, 25, 375, 75))); - RectF bottomRight = createBorderCorner(BOTTOM_RIGHT, 50, 10, 50, borderBox).getOvalIfInnerCornerNotExist(); - assertThat(bottomRight, is(new RectF(325, 325, 375, 375))); - RectF bottomLeft = createBorderCorner(BOTTOM_LEFT, 50, 10, 50, borderBox) - .getOvalIfInnerCornerNotExist(); - assertThat(bottomLeft, is(new RectF(25, 325, 75, 375))); - } - -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/view/border/BorderDrawableTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/view/border/BorderDrawableTest.java deleted file mode 100644 index 49caafab68..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/view/border/BorderDrawableTest.java +++ /dev/null @@ -1,377 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package com.taobao.weex.ui.view.border; - -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.PixelFormat; -import android.graphics.Rect; - -import com.taobao.weex.utils.WXResourceUtils; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertThat; - -@RunWith(RobolectricTestRunner.class) -@Config(manifest = Config.NONE) -public class BorderDrawableTest { - - @Before - public void setUp() throws Exception { - - } - - @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)); - } - - @Test - public void testBorderWidth() throws Exception { - BorderDrawable none = new BorderDrawable(); - assertThat(none.getBorderWidth(Spacing.ALL), is(BorderDrawable.DEFAULT_BORDER_WIDTH)); - assertThat(none.getBorderWidth(Spacing.LEFT), is(BorderDrawable.DEFAULT_BORDER_WIDTH)); - assertThat(none.getBorderWidth(Spacing.RIGHT), is(BorderDrawable.DEFAULT_BORDER_WIDTH)); - assertThat(none.getBorderWidth(Spacing.TOP), is(BorderDrawable.DEFAULT_BORDER_WIDTH)); - assertThat(none.getBorderWidth(Spacing.BOTTOM), is(BorderDrawable.DEFAULT_BORDER_WIDTH)); - - BorderDrawable full = new BorderDrawable(); - full.setBorderWidth(Spacing.ALL, 12); - assertThat(full.getBorderWidth(Spacing.ALL), is(12f)); - assertThat(full.getBorderWidth(Spacing.LEFT), is(12f)); - assertThat(full.getBorderWidth(Spacing.RIGHT), is(12f)); - assertThat(full.getBorderWidth(Spacing.TOP), is(12f)); - assertThat(full.getBorderWidth(Spacing.BOTTOM), is(12f)); - - BorderDrawable noneAndPart = new BorderDrawable(); - noneAndPart.setBorderWidth(Spacing.LEFT, 5); - noneAndPart.setBorderWidth(Spacing.TOP, 12); - assertThat(noneAndPart.getBorderWidth(Spacing.LEFT), is(5f)); - assertThat(noneAndPart.getBorderWidth(Spacing.RIGHT), is(BorderDrawable.DEFAULT_BORDER_WIDTH)); - assertThat(noneAndPart.getBorderWidth(Spacing.TOP), is(12f)); - assertThat(noneAndPart.getBorderWidth(Spacing.BOTTOM), is(BorderDrawable.DEFAULT_BORDER_WIDTH)); - - BorderDrawable fullAndPart = new BorderDrawable(); - fullAndPart.setBorderWidth(Spacing.ALL, 5); - fullAndPart.setBorderWidth(Spacing.LEFT, 12); - fullAndPart.setBorderWidth(Spacing.TOP, 19); - assertThat(fullAndPart.getBorderWidth(Spacing.LEFT), is(12f)); - assertThat(fullAndPart.getBorderWidth(Spacing.RIGHT), is(5f)); - assertThat(fullAndPart.getBorderWidth(Spacing.TOP), is(19f)); - assertThat(fullAndPart.getBorderWidth(Spacing.BOTTOM), is(5f)); - - BorderDrawable partAndFull = new BorderDrawable(); - partAndFull.setBorderWidth(Spacing.LEFT, 12); - partAndFull.setBorderWidth(Spacing.ALL, 5); - assertThat(partAndFull.getBorderWidth(Spacing.ALL), is(5f)); - assertThat(partAndFull.getBorderWidth(Spacing.LEFT), is(5f)); - assertThat(partAndFull.getBorderWidth(Spacing.RIGHT), is(5f)); - assertThat(partAndFull.getBorderWidth(Spacing.TOP), is(5f)); - assertThat(partAndFull.getBorderWidth(Spacing.BOTTOM), is(5f)); - } - - @Test - public void testBorderRadius() throws Exception { - BorderDrawable none = new BorderDrawable(); - none.draw(new Canvas()); - assertThat(none.getBorderRadius(BorderDrawable.BORDER_RADIUS_ALL), is(BorderDrawable.DEFAULT_BORDER_WIDTH)); - assertThat(none.getBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS), is(BorderDrawable.DEFAULT_BORDER_WIDTH)); - assertThat(none.getBorderRadius(BorderDrawable.BORDER_TOP_RIGHT_RADIUS), is(BorderDrawable.DEFAULT_BORDER_WIDTH)); - assertThat(none.getBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS), is(BorderDrawable.DEFAULT_BORDER_WIDTH)); - assertThat(none.getBorderRadius(BorderDrawable.BORDER_BOTTOM_LEFT_RADIUS), is(BorderDrawable.DEFAULT_BORDER_WIDTH)); - - BorderDrawable full = new BorderDrawable(); - full.setBorderRadius(BorderDrawable.BORDER_RADIUS_ALL, 12); - full.setBounds(new Rect(0, 0, 400, 400)); - full.draw(new Canvas()); - assertThat(full.getBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS), is(12f)); - assertThat(full.getBorderRadius(BorderDrawable.BORDER_TOP_RIGHT_RADIUS), is(12f)); - assertThat(full.getBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS), is(12f)); - assertThat(full.getBorderRadius(BorderDrawable.BORDER_BOTTOM_LEFT_RADIUS), is(12f)); - - BorderDrawable noneAndPart = new BorderDrawable(); - noneAndPart.setBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS, 5); - noneAndPart.setBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS, 12); - noneAndPart.setBounds(new Rect(0, 0, 400, 400)); - noneAndPart.draw(new Canvas()); - assertThat(noneAndPart.getBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS), is(5f)); - assertThat(noneAndPart.getBorderRadius(BorderDrawable.BORDER_TOP_RIGHT_RADIUS), is(BorderDrawable.DEFAULT_BORDER_WIDTH)); - assertThat(noneAndPart.getBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS), is(12f)); - assertThat(noneAndPart.getBorderRadius(BorderDrawable.BORDER_BOTTOM_LEFT_RADIUS), is(BorderDrawable.DEFAULT_BORDER_WIDTH)); - - BorderDrawable fullAndPart = new BorderDrawable(); - fullAndPart.setBorderRadius(BorderDrawable.BORDER_RADIUS_ALL, 5); - fullAndPart.setBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS, 12); - fullAndPart.setBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS, 19); - fullAndPart.setBounds(new Rect(0, 0, 400, 400)); - fullAndPart.draw(new Canvas()); - assertThat(fullAndPart.getBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS), is(12f)); - assertThat(fullAndPart.getBorderRadius(BorderDrawable.BORDER_TOP_RIGHT_RADIUS), is(5f)); - assertThat(fullAndPart.getBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS), is(19f)); - assertThat(fullAndPart.getBorderRadius(BorderDrawable.BORDER_BOTTOM_LEFT_RADIUS), is(5f)); - - BorderDrawable partAndFull = new BorderDrawable(); - partAndFull.setBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS, 12); - partAndFull.setBorderRadius(BorderDrawable.BORDER_RADIUS_ALL, 5); - partAndFull.setBounds(new Rect(0, 0, 400, 400)); - partAndFull.draw(new Canvas()); - assertThat(partAndFull.getBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS), is(5f)); - assertThat(partAndFull.getBorderRadius(BorderDrawable.BORDER_TOP_RIGHT_RADIUS), is(5f)); - assertThat(partAndFull.getBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS), is(5f)); - assertThat(partAndFull.getBorderRadius(BorderDrawable.BORDER_BOTTOM_LEFT_RADIUS), is(5f)); - - BorderDrawable noOverLapping = new BorderDrawable(); - noOverLapping.setBounds(new Rect(0, 0, 400, 400)); - noOverLapping.setBorderRadius(BorderDrawable.BORDER_RADIUS_ALL, 0); - noOverLapping.draw(new Canvas()); - assertThat(noOverLapping.getBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS), is(0f)); - assertThat(noOverLapping.getBorderRadius(BorderDrawable.BORDER_TOP_RIGHT_RADIUS), is(0f)); - assertThat(noOverLapping.getBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS), is(0f)); - assertThat(noOverLapping.getBorderRadius(BorderDrawable.BORDER_BOTTOM_LEFT_RADIUS), is(0f)); - - BorderDrawable overlappingOneLine = new BorderDrawable(); - overlappingOneLine.setBounds(new Rect(0, 0, 400, 400)); - overlappingOneLine.setBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS, 300); - overlappingOneLine.setBorderRadius(BorderDrawable.BORDER_TOP_RIGHT_RADIUS, 200); - overlappingOneLine.draw(new Canvas()); - assertThat(overlappingOneLine.getBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS), is(240f)); - assertThat(overlappingOneLine.getBorderRadius(BorderDrawable.BORDER_TOP_RIGHT_RADIUS), is(160f)); - assertThat(overlappingOneLine.getBorderRadius(BorderDrawable.BORDER_BOTTOM_LEFT_RADIUS), is - (0f)); - assertThat(overlappingOneLine.getBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS), is - (0f)); - - BorderDrawable overlappingAdjoinLine = new BorderDrawable(); - overlappingAdjoinLine.setBounds(new Rect(0, 0, 400, 400)); - overlappingAdjoinLine.setBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS, 300); - overlappingAdjoinLine.setBorderRadius(BorderDrawable.BORDER_TOP_RIGHT_RADIUS, 200); - overlappingAdjoinLine.setBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS, 300); - overlappingAdjoinLine.setBorderRadius(BorderDrawable.BORDER_BOTTOM_LEFT_RADIUS, 50); - overlappingAdjoinLine.draw(new Canvas()); - assertThat(overlappingAdjoinLine.getBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS), is - (240f)); - assertThat(overlappingAdjoinLine.getBorderRadius(BorderDrawable.BORDER_TOP_RIGHT_RADIUS), is - (160f)); - assertThat(overlappingAdjoinLine.getBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS), is - (240f)); - assertThat(overlappingAdjoinLine.getBorderRadius(BorderDrawable.BORDER_BOTTOM_LEFT_RADIUS), - is(40f)); - - BorderDrawable overlappingNonadjoinLine = new BorderDrawable(); - overlappingNonadjoinLine.setBounds(new Rect(0, 0, 400, 800)); - overlappingNonadjoinLine.setBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS, 300); - overlappingNonadjoinLine.setBorderRadius(BorderDrawable.BORDER_TOP_RIGHT_RADIUS, 200); - overlappingNonadjoinLine.setBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS, 300); - overlappingNonadjoinLine.setBorderRadius(BorderDrawable.BORDER_BOTTOM_LEFT_RADIUS, 200); - overlappingNonadjoinLine.draw(new Canvas()); - assertThat(overlappingNonadjoinLine.getBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS), is - (240f)); - assertThat(overlappingNonadjoinLine.getBorderRadius(BorderDrawable.BORDER_TOP_RIGHT_RADIUS), is - (160f)); - assertThat(overlappingNonadjoinLine.getBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS), is - (240f)); - assertThat(overlappingNonadjoinLine.getBorderRadius(BorderDrawable.BORDER_BOTTOM_LEFT_RADIUS), - is(160f)); - - BorderDrawable overlappingThreeLines = new BorderDrawable(); - overlappingThreeLines.setBounds(new Rect(0, 0, 400, 500)); - overlappingThreeLines.setBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS, 300); - overlappingThreeLines.setBorderRadius(BorderDrawable.BORDER_TOP_RIGHT_RADIUS, 200); - overlappingThreeLines.setBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS, 600); - overlappingThreeLines.setBorderRadius(BorderDrawable.BORDER_BOTTOM_LEFT_RADIUS, 100); - overlappingThreeLines.draw(new Canvas()); - assertEquals(300f * 4 / 7, - overlappingThreeLines.getBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS), - .00001f); - assertEquals(200f * 4 / 7, overlappingThreeLines.getBorderRadius(BorderDrawable.BORDER_TOP_RIGHT_RADIUS), - .00001f); - assertEquals(600f * 4 / 7, overlappingThreeLines.getBorderRadius(BorderDrawable - .BORDER_BOTTOM_RIGHT_RADIUS), - .00001f); - assertEquals(100f * 4 / 7, overlappingThreeLines.getBorderRadius(BorderDrawable - .BORDER_BOTTOM_LEFT_RADIUS), - .00001f); - - BorderDrawable overlappingFourLines = new BorderDrawable(); - overlappingFourLines.setBounds(new Rect(0, 0, 400, 500)); - overlappingFourLines.setBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS, 500); - overlappingFourLines.setBorderRadius(BorderDrawable.BORDER_TOP_RIGHT_RADIUS, 600); - overlappingFourLines.setBorderRadius(BorderDrawable.BORDER_BOTTOM_RIGHT_RADIUS, 700); - overlappingFourLines.setBorderRadius(BorderDrawable.BORDER_BOTTOM_LEFT_RADIUS, 800); - overlappingFourLines.draw(new Canvas()); - assertEquals(500f * 4 / 15, - overlappingFourLines.getBorderRadius(BorderDrawable.BORDER_TOP_LEFT_RADIUS), - .0001f); - assertEquals(600f * 4 / 15, overlappingFourLines.getBorderRadius(BorderDrawable - .BORDER_TOP_RIGHT_RADIUS), - .0001f); - assertEquals(700f * 4 / 15, overlappingFourLines.getBorderRadius(BorderDrawable - .BORDER_BOTTOM_RIGHT_RADIUS), - .0001f); - assertEquals(800f * 4 / 15, overlappingFourLines.getBorderRadius(BorderDrawable - .BORDER_BOTTOM_LEFT_RADIUS), - .0001f); - } - - @Test - public void testBorderColor() throws Exception { - BorderDrawable none = new BorderDrawable(); - assertThat(none.getBorderColor(Spacing.ALL), is(BorderDrawable.DEFAULT_BORDER_COLOR)); - assertThat(none.getBorderColor(Spacing.LEFT), is(BorderDrawable.DEFAULT_BORDER_COLOR)); - assertThat(none.getBorderColor(Spacing.RIGHT), is(BorderDrawable.DEFAULT_BORDER_COLOR)); - assertThat(none.getBorderColor(Spacing.TOP), is(BorderDrawable.DEFAULT_BORDER_COLOR)); - assertThat(none.getBorderColor(Spacing.BOTTOM), is(BorderDrawable.DEFAULT_BORDER_COLOR)); - - BorderDrawable full = new BorderDrawable(); - full.setBorderColor(Spacing.ALL, Color.RED); - assertThat(full.getBorderColor(Spacing.ALL), is(Color.RED)); - assertThat(full.getBorderColor(Spacing.LEFT), is(Color.RED)); - assertThat(full.getBorderColor(Spacing.RIGHT), is(Color.RED)); - assertThat(full.getBorderColor(Spacing.TOP), is(Color.RED)); - assertThat(full.getBorderColor(Spacing.BOTTOM), is(Color.RED)); - - BorderDrawable noneAndPart = new BorderDrawable(); - noneAndPart.setBorderColor(Spacing.LEFT, Color.BLUE); - noneAndPart.setBorderColor(Spacing.TOP, Color.GREEN); - assertThat(noneAndPart.getBorderColor(Spacing.LEFT), is(Color.BLUE)); - assertThat(noneAndPart.getBorderColor(Spacing.RIGHT), is(BorderDrawable.DEFAULT_BORDER_COLOR)); - assertThat(noneAndPart.getBorderColor(Spacing.TOP), is(Color.GREEN)); - assertThat(noneAndPart.getBorderColor(Spacing.BOTTOM), is(BorderDrawable.DEFAULT_BORDER_COLOR)); - - BorderDrawable fullAndPart = new BorderDrawable(); - fullAndPart.setBorderColor(Spacing.ALL, Color.BLUE); - fullAndPart.setBorderColor(Spacing.LEFT, Color.GREEN); - fullAndPart.setBorderColor(Spacing.TOP, Color.RED); - assertThat(fullAndPart.getBorderColor(Spacing.LEFT), is(Color.GREEN)); - assertThat(fullAndPart.getBorderColor(Spacing.RIGHT), is(Color.BLUE)); - assertThat(fullAndPart.getBorderColor(Spacing.TOP), is(Color.RED)); - assertThat(fullAndPart.getBorderColor(Spacing.BOTTOM), is(Color.BLUE)); - - BorderDrawable partAndFull = new BorderDrawable(); - partAndFull.setBorderColor(Spacing.LEFT, Color.RED); - partAndFull.setBorderColor(Spacing.ALL, Color.BLUE); - assertThat(partAndFull.getBorderColor(Spacing.ALL), is(Color.BLUE)); - assertThat(partAndFull.getBorderColor(Spacing.LEFT), is(Color.BLUE)); - assertThat(partAndFull.getBorderColor(Spacing.RIGHT), is(Color.BLUE)); - assertThat(partAndFull.getBorderColor(Spacing.TOP), is(Color.BLUE)); - assertThat(partAndFull.getBorderColor(Spacing.BOTTOM), is(Color.BLUE)); - - } - - @Test - public void testBorderStyle() throws Exception { - BorderDrawable none = new BorderDrawable(); - assertThat(none.getBorderStyle(Spacing.ALL), is(BorderStyle.SOLID.ordinal())); - assertThat(none.getBorderStyle(Spacing.LEFT), is(BorderStyle.SOLID.ordinal())); - assertThat(none.getBorderStyle(Spacing.RIGHT), is(BorderStyle.SOLID.ordinal())); - assertThat(none.getBorderStyle(Spacing.TOP), is(BorderStyle.SOLID.ordinal())); - assertThat(none.getBorderStyle(Spacing.BOTTOM), is(BorderStyle.SOLID.ordinal())); - - BorderDrawable full = new BorderDrawable(); - full.setBorderStyle(Spacing.ALL, BorderStyle.DOTTED.name()); - assertThat(full.getBorderStyle(Spacing.ALL), is(BorderStyle.DOTTED.ordinal())); - assertThat(full.getBorderStyle(Spacing.LEFT), is(BorderStyle.DOTTED.ordinal())); - assertThat(full.getBorderStyle(Spacing.RIGHT), is(BorderStyle.DOTTED.ordinal())); - assertThat(full.getBorderStyle(Spacing.TOP), is(BorderStyle.DOTTED.ordinal())); - assertThat(full.getBorderStyle(Spacing.BOTTOM), is(BorderStyle.DOTTED.ordinal())); - - BorderDrawable noneAndPart = new BorderDrawable(); - noneAndPart.setBorderStyle(Spacing.LEFT, BorderStyle.DOTTED.name()); - noneAndPart.setBorderStyle(Spacing.TOP, BorderStyle.DASHED.name()); - assertThat(noneAndPart.getBorderStyle(Spacing.LEFT), is(BorderStyle.DOTTED.ordinal())); - assertThat(noneAndPart.getBorderStyle(Spacing.RIGHT), is(BorderStyle.SOLID.ordinal())); - assertThat(noneAndPart.getBorderStyle(Spacing.TOP), is(BorderStyle.DASHED.ordinal())); - assertThat(noneAndPart.getBorderStyle(Spacing.BOTTOM), is(BorderStyle.SOLID.ordinal())); - - BorderDrawable fullAndPart = new BorderDrawable(); - fullAndPart.setBorderStyle(Spacing.ALL, BorderStyle.DASHED.name()); - fullAndPart.setBorderStyle(Spacing.LEFT, BorderStyle.DOTTED.name()); - fullAndPart.setBorderStyle(Spacing.TOP, BorderStyle.SOLID.name()); - assertThat(fullAndPart.getBorderStyle(Spacing.LEFT), is(BorderStyle.DOTTED.ordinal())); - assertThat(fullAndPart.getBorderStyle(Spacing.RIGHT), is(BorderStyle.DASHED.ordinal())); - assertThat(fullAndPart.getBorderStyle(Spacing.TOP), is(BorderStyle.SOLID.ordinal())); - assertThat(fullAndPart.getBorderStyle(Spacing.BOTTOM), is(BorderStyle.DASHED.ordinal())); - - BorderDrawable partAndFull = new BorderDrawable(); - partAndFull.setBorderStyle(Spacing.LEFT, BorderStyle.DASHED.name()); - partAndFull.setBorderStyle(Spacing.ALL, BorderStyle.DOTTED.name()); - assertThat(partAndFull.getBorderStyle(Spacing.ALL), is(BorderStyle.DOTTED.ordinal())); - assertThat(partAndFull.getBorderStyle(Spacing.LEFT), is(BorderStyle.DOTTED.ordinal())); - assertThat(partAndFull.getBorderStyle(Spacing.RIGHT), is(BorderStyle.DOTTED.ordinal())); - assertThat(partAndFull.getBorderStyle(Spacing.TOP), is(BorderStyle.DOTTED.ordinal())); - assertThat(partAndFull.getBorderStyle(Spacing.BOTTOM), is(BorderStyle.DOTTED.ordinal())); - } - - @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)); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/ui/view/gesture/WXGestureTest.java b/android/sdk/src/test/java/com/taobao/weex/ui/view/gesture/WXGestureTest.java deleted file mode 100644 index 125f9d12ef..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/ui/view/gesture/WXGestureTest.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.ui.view.gesture; - -import android.view.MotionEvent; -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.TestActivity; -import com.taobao.weex.ui.component.ComponentTest; -import com.taobao.weex.ui.component.WXComponent; -import com.taobao.weex.ui.component.WXDivTest; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.robolectric.Robolectric; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -/** - * Created by sospartan on 27/09/2016. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"}) -public class WXGestureTest { - - WXGesture mGesture; - WXComponent component; - @Before - public void setUp() throws Exception { - component = WXDivTest.create(); - ComponentTest.create(component); - - component.addEvent(WXGestureType.LowLevelGesture.ACTION_CANCEL.toString()); - component.addEvent(WXGestureType.LowLevelGesture.ACTION_DOWN.toString()); - component.addEvent(WXGestureType.LowLevelGesture.ACTION_MOVE.toString()); - component.addEvent(WXGestureType.LowLevelGesture.ACTION_UP.toString()); - - TestActivity activity = Robolectric.setupActivity(TestActivity.class); - mGesture = new WXGesture(component, activity); - - } - - @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); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/utils/FunctionParserTest.java b/android/sdk/src/test/java/com/taobao/weex/utils/FunctionParserTest.java deleted file mode 100644 index aa1c719c9a..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/utils/FunctionParserTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.utils; - -import org.junit.Test; - -import java.util.List; - -/** - * Created by sospartan on 27/09/2016. - */ -public class FunctionParserTest { - - @Test - public void testParse() throws Exception { - List s = new SingleFunctionParser<>("blur(5px)", new SingleFunctionParser.FlatMapper() { - @Override - public Integer map(String raw) { - return WXUtils.getInteger(raw,0); - } - }).parse("blur"); - System.out.println(s); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/utils/TypefaceUtilTest.java b/android/sdk/src/test/java/com/taobao/weex/utils/TypefaceUtilTest.java deleted file mode 100644 index 7416b8df05..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/utils/TypefaceUtilTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.utils; - -import android.graphics.Paint; -import android.graphics.Typeface; -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXSDKInstanceTest; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import static org.junit.Assert.*; - -/** - * Created by sospartan on 8/2/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore({ "org.mockito.*", "org.robolectric.*", "android.*" }) -public class TypefaceUtilTest { - - @Test - public void testPutFontDO() throws Exception { - FontDO font = new FontDO("test","url('local:///test')", WXSDKInstanceTest.createInstance()); - TypefaceUtil.putFontDO(font); - assertEquals(TypefaceUtil.getFontDO("test").getUrl(),"local:///test"); - - } - - -} diff --git a/android/sdk/src/test/java/com/taobao/weex/utils/WXFileUtilsTest.java b/android/sdk/src/test/java/com/taobao/weex/utils/WXFileUtilsTest.java deleted file mode 100644 index 64a072039e..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/utils/WXFileUtilsTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.utils; - -import com.taobao.weappplus_sdk.BuildConfig; -import java.io.File; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.rule.PowerMockRule; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.RuntimeEnvironment; -import org.robolectric.annotation.Config; - -/** - * Created by sospartan on 8/2/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore({ "org.mockito.*", "org.robolectric.*", "android.*" }) -@PrepareForTest() -public class WXFileUtilsTest { - - @Rule - public PowerMockRule rule = new PowerMockRule(); - - @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); - } - - @Test - public void testSaveFile() throws Exception { - WXFileUtils.saveFile("build/test","test".getBytes(),RuntimeEnvironment.application); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/utils/WXJsonUtilsTest.java b/android/sdk/src/test/java/com/taobao/weex/utils/WXJsonUtilsTest.java deleted file mode 100644 index 92f64eba48..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/utils/WXJsonUtilsTest.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.utils; - -import com.alibaba.fastjson.JSON; -import org.junit.Test; - -import java.math.BigDecimal; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -import static org.junit.Assert.*; - -/** - * Created by sospartan on 8/2/16. - */ -public class WXJsonUtilsTest { - - - static class TestObj{ - int a; - - public int getA() { - return a; - } - - public void setA(int a) { - this.a = a; - } - } - - @Test - public void testGetList() throws Exception { - List list = WXJsonUtils.getList("[{'a':1},{'a':2}]",TestObj.class); - - assertEquals(list.size(),2); - assertEquals(list.get(0).getA(),1); - assertEquals(list.get(1).getA(),2); - - list = WXJsonUtils.getList("{}",TestObj.class); - - assertEquals(list.size(),0); - } - - @Test - public void testFromObjectToJSONString() throws Exception { - TestObj obj = new TestObj(); - obj.a = 1; - assertEquals(WXJsonUtils.fromObjectToJSONString(obj),"{\"a\":1}"); - assertEquals(WXJsonUtils.fromObjectToJSONString(null),"null"); - assertEquals(WXJsonUtils.fromObjectToJSONString(new Object()),"{}"); - - Map data = new HashMap<>(); - data.put("a",536649655068L); - BigDecimal d = new BigDecimal(536649655068L); - data.put("d",d); - data.put("b",new Long(536649655068L)); - - - Object resp = JSON.parse("[{\"offerId\":536449659068,\"subject\":\"jv2测试offer\",\"offerUnit\":\"千克\",\"price\":{\"price\":234.0},\"imageList\":[\"http://product.1688nongchanping.com/offer/7730-1503041G910-51.jpg\",\"http://product.1688nongchanping.com/offer/7730-1503041G910-51.jpg\",\"http://product.1688nongchanping.com/offer/140-150302120045.jpg\"],\"featureList\":[],\"companyInfo\":null,\"saleInfo\":{\"saledCount\":null,\"avaliableAmount\":100.0},\"detailURL\":\"

http://view.m.1688.com/cms/native/offerdetail.html?url=http://img02.taobaocdn.com/tfscom/TB18Z_5KVXXXXbAXXXXXXXXXXXX

\"},{\"offerId\":536489059003,\"subject\":\"jv 测试offer——detailURL\",\"offerUnit\":\"千克\",\"price\":{\"price\":12.0},\"imageList\":[\"http://product.1688nongchanping.com/offer/1139304780d4f14e57o.jpg\",\"http://product.1688nongchanping.com/offer/1139304780d4f14e57o.jpg\"],\"featureList\":[],\"companyInfo\":null,\"saleInfo\":{\"saledCount\":null,\"avaliableAmount\":100.0},\"detailURL\":\"

\"},{\"offerId\":536489059017,\"subject\":\"jv测试offer9\",\"offerUnit\":\"千克\",\"price\":{\"price\":12.0},\"imageList\":[\"http://product.1688nongchanping.com/offer/b356b09004d94f429f39c59c68768a38.jpg\",\"http://product.1688nongchanping.com/offer/b356b09004d94f429f39c59c68768a38.jpg\",\"http://product.1688nongchanping.com/offer/140-150302120045.jpg\"],\"featureList\":[],\"companyInfo\":null,\"saleInfo\":{\"saledCount\":null,\"avaliableAmount\":122.0},\"detailURL\":\"
\\r\\n

\\r\\n
\"},{\"offerId\":536489059001,\"subject\":\"正儿八经测试3\",\"offerUnit\":\"千克\",\"price\":{\"price\":12.0},\"imageList\":[\"http://product.1688nongchanping.com/offer/3132872979_999566913.jpg\",\"http://product.1688nongchanping.com/offer/3132872979_999566913.jpg\",\"http://product.1688nongchanping.com/offer/3214597083_919536840.jpg\"],\"featureList\":[],\"companyInfo\":null,\"saleInfo\":{\"saledCount\":null,\"avaliableAmount\":2323232.0},\"detailURL\":\"

<p data-type=\\\"label-view\\\" style=\\\"color: rgb(255, 255, 255); font-size: 9px; height: 13px; margin-left: 15px; margin-top: 64px; width: 46px; background-image: url(&quot;http://gtms02.alicdn.com/tps/i2/TB1dYb9KVXXXXX5XVXXjm1NHpXX-204-56.png&quot;); background-size: contain; background-repeat: no-repeat;\\\" data-gravity=\\\"5\\\" roc-id=\\\"roc-13\\\">

\\r\\n

    <span class=\\\"label-content\\\" style=\\\"left: 0px; top: -2.5px;\\\">JV测试测试测试</span>

\\r\\n

</p>

\"},{\"offerId\":536449539162,\"subject\":\"正儿八经测试商品1\",\"offerUnit\":\"千克\",\"price\":{\"price\":23.0},\"imageList\":[\"http://product.1688nongchanping.com/offer/3211026576_999566913.jpg\",\"http://product.1688nongchanping.com/offer/3211026576_999566913.jpg\",\"http://product.1688nongchanping.com/offer/3132872979_999566913.jpg\"],\"featureList\":[],\"companyInfo\":null,\"saleInfo\":{\"saledCount\":null,\"avaliableAmount\":34567.0},\"detailURL\":\"\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n\\r\\n
 <!----><!DOCTYPE html>
 <html>
 <head>
 <title>图文详情</title>
 <meta charset=\\\"gbk\\\">
 <meta name=\\\"data-spm\\\" content=\\\"a260g\\\" /><meta name='date' content='1469761837251'/>
 <meta name=\\\"viewport\\\" content=\\\"width=790px\\\">
 <link rel=\\\"stylesheet\\\" href=\\\"//astyle.alicdn.com/fdevlib/css/lofty/port/lofty.css?_v=4900687.css\\\" /></link>
 <script type=\\\"text/javascript\\\" src=\\\"//astyle.alicdn.com/m/lofty/port/lofty.js?_v=4900687.js\\\"></script>
 <script type=\\\"text/javascript\\\" src=\\\"//astyle.alicdn.com/fdevlib/js/gallery/jquery/jquery-latest.js?_v=4900687.js\\\"></script>
 <style>
 div,p,td,a,strong,b,span{word-break:break-word}
 body img{
 max-width:790px;
 vertical-align:bottom;
 }
 </style>
 </head>
 <body data-spm=\\\"8029192\\\"><script type=text/javascript>var dmtrack_c='{-}'; var dmtrack_pageid='0ac6d5d80a6738c01470206317';
 (function(d){var t=d.createElement('script');t.type='text/javascript';t.async=true;t.src='//astyle-src.alicdn.com/sys/js/beacon/cnb.js';d.getElementsByTagName('head')[0].appendChild(t);}(document));</script>
 <noscript><img src=\\\"//dmtracking.1688.com/b.jpg?cD0yJnU9e3ZpZXcubS4xNjg4LmNvbSUyZmNtcyUyZm5hdGl2ZSUyZm9mZmVyZGV0YWlsJTJlaHRtbD91cmw9aHR0cCUzYSUyZiUyZmRzYyUyZXRhb2Jhb2NkbiUyZWNvbSUyZmk4JTJmNTMwJTJmMzgwJTJmNTM2MzgxODI4NjQ5JTJmVEIxRFpXb0xYWFhYWGJqWEZYWDhxdHBGWGxYJTJlZGVzYyUyNTdDdmFyJTI1NUVkZXNjJTI1M0JsYW5nJTI1NUVnYmslMjUzQnNpZ24lMjU1RTEwZDUwYzk3OTVmZmM0N2I3YmYwODhmZTAyZjExMzMzJTI1M0J0JTI1NUUxNDY5Njk3MDgzfSZtPXtHRVR9JnM9ezIwMH0mcj17LX0mYT17JTIyY19tcz0xfGNfbXQ9M3xjX21pZD1iMmItNjAyNDQ5Mjg4fGNfbGlkPW1yJTI1RTklMjVBMyUyNThFJTI1RTYlMjVCNSUyNTgxJTI1RTYlMjVCNiUyNTk1JTI1RTYlMjVCNyUyNThDJTIyfSZiPS0mYz17LX0K&ver=40&pageid=0ac6d5d80a6738c01470206317&time=1470206317\\\" width=\\\"1\\\" height=\\\"1\\\" style=\\\"display:none\\\"></noscript>
 <script type=text/javascript> var _SPM_a='{-}'; var _SPM_b='{-}';var _SPM_app_name='{-}';var _SPM_template_path='{-}';</script>
 <script>
 with(document)with(body)with(insertBefore(createElement(\\\"script\\\"),firstChild))setAttribute(\\\"exparams\\\",\\\"category=&userid=602449288&aplus&&asid=AYil6CNtkaFXdONiEQAAAABPw8F55NX8kg==&aat=%22c%5fms%3d1%7cc%5fmt%3d3%7cc%5fmid%3db2b%2d602449288%7cc%5flid%3dmr%25E9%25A3%258E%25E6%25B5%2581%25E6%25B6%2595%25E6%25B7%258C%22&abi=42%2e120%2e74%2e159%2e1456797195765%2e338553%2e3&abb=&\\\",id=\\\"tb-beacon-aplus\\\",src=(location>\\\"https\\\"?\\\"//g\\\":\\\"//g\\\")+\\\".alicdn.com/alilog/mlog/aplus_b2b.js\\\")
 </script>
  
  
 </body>
 <script type=\\\"text/javascript\\\">
 define(['util/lazyload/1.0','jquery'],function(LazyLoad,J){
 var main={
 init:function(){
 this.detailUrl =this._getUrlVars('url');
 this.config = {},
 this.container=J('body');
 this._loadDesc();
 },
 _getUrlVars: function(name){
 var vars = [], hash;
 var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
  
 for(var i = 0; i < hashes.length; i++){
 hash = hashes[i].split('=');
 vars.push(hash[0]);
 vars[hash[0]] = hash[1];
 }
  
 return decodeURI(vars[name]);
 },
 _loadDesc: function() {
 if (this.detailUrl) {
 this._initLazyLoadDescriptionTFS();
 } else {
 this._initLazyLoadDescription();
 }
 },
  
 _initLazyLoadDescriptionTFS: function() {
 var that = this,
 descURLTFS = that.detailUrl;
  
 //新老地址处理
 if (typeof(descURLTFS) === \\\"string\\\" && descURLTFS.indexOf(\\\"/tfscom/\\\") >= 0 && descURLTFS.indexOf(\\\"?t=\\\") < 0) {
 descURLTFS = descURLTFS + '?t=' + new Date().getTime();
 }
  
 J.ajax({
 url: descURLTFS,
 dataType: 'script',
 timeout: 3000,
 cache: true,
 success: function() {
 if (descURLTFS.indexOf(\\\"/tfscom/\\\") >= 0) {
 if (window.offer_details && window.offer_details.content) {
 that._descriptionSuccessCallback(window.offer_details.content);
 } else {
 that._initLazyLoadDescription();
 }
 } else {
 if (window.desc) {
 that._descriptionSuccessCallback(window.desc);
 } else {
 that._initLazyLoadDescription();
 }
 }
 },
 error: function() {
 that._initLazyLoadDescription();
 }
 });
 },
  
 _initLazyLoadDescription: function() {
 var that = this;
 var descURL = that.detailUrl;
 //获取offer详情的数据
 J.ajax(descURL, {
 dataType: 'jsonp',
 data: {},
 success: function(o) {
 if (o.success === true) {
 that._descriptionSuccessCallback(o.offerDesc);
 } else {
 that.container.html('详情加载失败');
 }
 },
 error: function() {
 that.container.html('详情加载失败');
 }
 });
 },
  
 _descriptionSuccessCallback: function(o) {
 var self = this,
 heightStyle = '',
 widthStyle = '',
 styles='',
 imgRegx = /(<img[^>]*)(src *= *(\\\"[^\\\"]*\\\"|'[^']*'|[^ >]*)) *[^>]*>/g,
 heightRegx = /(height[^:]*=\\\\s*(\\\"[^\\\"]*\\\"|'[^']*'|[^ >]*))/g,
 widthRegx = /(width[^:]*=\\\\s*(\\\"[^\\\"]*\\\"|'[^']*'|[^ >]*))/g,
 styleRegx =/style[^=]*=\\\\s*\\\"[^\\\"]*\\\"/g,
 html = '',
 imgCount, count = 0,
 imgs, tempEl,
 SPACEBALL = '//cbu01.alicdn.com/cms/upload/other/lazyload.png',
 that = this;
  
 html = o || '';
  
 imgCount = html.match(imgRegx) ? html.match(imgRegx).length : 0;
 html = html.replace(imgRegx, function(m, p1, p2, p3) {
 count++;
 //if (count < 1) return m; // 前 1 个图片不处理
 if (m.match(widthRegx)) {
 widthStyle = m.match(widthRegx);
 } else {
 widthStyle = '';
 }
  
 if(m.match(styleRegx)){
 styles = m.match(styleRegx);
 }else{
 styles = '';
 }
  
 if (m.indexOf('height') !== -1) {
 heightStyle = m.match(heightRegx);
 } else {
 heightStyle = '';
 }
 if (self.config.platform === 'iOS' && (self.config.networkType === '2g' || self.config.networkType === '3g' || J(window).height() < 481)) {
 p3 = handleImgSize(p3, '450x5000', '200x200');
 // } else {
 // p3 = handleImgSize(p3, '450x5000', '400x400');
  
 }
 return [
 '<img ',
 'src=\\\"https:' + SPACEBALL + '\\\" data-lazyload-src=',
 p3.replace(/_\\\\.webp\\\"$/,'\\\"') + ' ',
 styles + ' ',
 widthStyle + ' ',
 heightStyle + ' >'
 ].join('');
 });
 /* ref: http://blog.stevenlevithan.com/archives/faster-than-innerhtml */
 this.container.html(html);
  
 if (this.container.html() === '' || this.container.html() == '<p></p>') {
 this.container.html('卖家暂未添加产品描述');
 }
 this._initLink();
  
 imgs = J('img', this.container);
 for (var i = 0, l = imgs.length; i < l; i++) {
 //显示图片,一开始的时候图片都是隐藏的
 imgs.eq(i).css('visibility', 'visible');
 }
 //图片加载后缩放到detail页宽度
 imgs.bind('load', function() {
 J(this).css('visibility', 'visible');
 if (this.width > that.detailWidth && J(this).closest('table').length === 0) {
 J(this).width('100%');
 J(this).height('auto');
 }
 }).error(function() {
 J(this).hide();
 });
  
 this._initScroller();
  
 function handleImgSize(img, size, taobaoSize) {
 var p = img.match(/(\\\\S+)(\\\\.jpg'|\\\\.jpg\\\"|\\\\.jpg)((\\\\?)?(\\\\S+))J/),
 _img;
  
 if (img.search(/(\\\\d+)x(\\\\d+)\\\\.jpg/) == -1 && img.search(/(\\\\.jpg'|\\\\.jpg\\\"|\\\\.jpg)J/) !== -1) {
 if (img.indexOf('taobaocdn') !== -1 || img.indexOf('img.alicdn.com') !== -1) {
 // _img = p[1]+'.jpg_'+ taobaoSize + p[2];
 _img = img;
 } else {
 _img = p[1] + '.' + size + p[2]+p[3];
 }
 } else {
 _img = img;
 }
 // var _img = img.replace(/(\\\\S+\\\\.jpg['\\\"]?)\\\\??[^\\\"']*([\\\"'])?J/, function(p, p1, p2) {
 // return p1 + (p2 || '');
 // });
 return _img;
 }
 },
 _initLink: function() {
 this.container.on('click', 'a', function(e) {
 e.preventDefault();
 /*var href = J(this).attr('href'),
 result = href.match(/(\\\\d+)\\\\.html/);
 result[1] && Wing.navigator.rewrite('URL', 'http://detail.m.1688.com/page/index.html?offerId=' + result[1]);*/
 });
 },
 _initScroller: function() {
 // setTimeout(function(){
 // var myScroll = new Scroller({
 // container: '#d-content',
 // hScroll:true,
 // vScroll:true,
 // zoom: true,
 // checkDOMChanges: true
 // });
 var lazy = new LazyLoad({
 container: 'body'
 // scroller: myScroll
 });
 //lazy.init();
 // }, 200);
 }
 };
 J(function(){
 main.init()
 });
 });
 </script>
 </html>
 <!-- user defined footer -->
\"}]"); - - data.put("c",resp); -// System.out.println("max long:"+Long.MAX_VALUE); - String result = WXJsonUtils.fromObjectToJSONString(data); - System.out.println(result); - - } - - static class TestObject{ - - private BigDecimal big = new BigDecimal(536649655068L); - - public BigDecimal getBig() { - return big; - } - - public void setBig(BigDecimal big) { - this.big = big; - } - } - -} diff --git a/android/sdk/src/test/java/com/taobao/weex/utils/WXLogUtilsTest.java b/android/sdk/src/test/java/com/taobao/weex/utils/WXLogUtilsTest.java deleted file mode 100644 index ece6e0ef6e..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/utils/WXLogUtilsTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.utils; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXEnvironment; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.rule.PowerMockRule; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -/** - * Created by sospartan on 9/18/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore({ "org.mockito.*", "org.robolectric.*", "android.*" }) -@PrepareForTest({WXEnvironment.class}) -public class WXLogUtilsTest { - static class Log extends WXLogUtils{}; - - @Rule - public PowerMockRule rule = new PowerMockRule(); - - @Before - public void setUp() throws Exception { - WXLogUtils.isShowLineNumber = true; - PowerMockito.mockStatic(WXEnvironment.class); - PowerMockito.when(WXEnvironment.isApkDebugable()).thenReturn(true); - } - - @Test - public void testD() throws Exception { - Log.d("test"); - Log.d(null); - Log.d("tag","test"); - Log.d("tag","test | __ | __ __DEBUG | __ "); - Log.d("tag",new Throwable("test")); - } - - @Test - public void testI() throws Exception { - Log.i("test"); - Log.i(null); - Log.i("tag","test"); - Log.i("tag",new Throwable("test")); - } - - @Test - public void testV() throws Exception { - Log.v("test"); - Log.v(null); - Log.v("tag","test"); - Log.v("tag",new Throwable("test")); - } - - @Test - public void testW() throws Exception { - Log.w("test"); - Log.w(null); - Log.w("tag","test"); - Log.w("tag",new Throwable("test")); - } - - @Test - public void testE() throws Exception { - Log.e("test"); - Log.e(null); - Log.e("tag","test"); - Log.e("tag",new Throwable("test")); - } - -} diff --git a/android/sdk/src/test/java/com/taobao/weex/utils/WXReflectionUtilsTest.java b/android/sdk/src/test/java/com/taobao/weex/utils/WXReflectionUtilsTest.java deleted file mode 100644 index 18df37985c..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/utils/WXReflectionUtilsTest.java +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.utils; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.taobao.weappplus_sdk.BuildConfig; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import java.util.List; -import java.util.Map; - -import static org.junit.Assert.*; - -/** - * Created by sospartan on 8/2/16. - */ -@RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore({ "org.mockito.*", "org.robolectric.*", "android.*" }) -public class WXReflectionUtilsTest { - - static class TestA{ - private boolean value = false; - } - - @Test - public void testParseArgument() throws Exception { - Object value = WXReflectionUtils.parseArgument(String.class,"dkdkdkdk"); - assertTrue(value instanceof String); - - value = WXReflectionUtils.parseArgument(long.class,"123444"); - assertTrue(value instanceof Long); - - value = WXReflectionUtils.parseArgument(int.class,"123444"); - assertTrue(value instanceof Integer); - - value = WXReflectionUtils.parseArgument(Integer.class,"123444"); - assertTrue(value instanceof Integer); - - value = WXReflectionUtils.parseArgument(int.class,123444); - assertTrue(value instanceof Integer); - - value = WXReflectionUtils.parseArgument(double.class, Double.toString(123.444d)); - assertTrue(value instanceof Double); - - - - JSONObject j = new JSONObject(); - j.put("a","b"); - j.put("c",23); - value = WXReflectionUtils.parseArgument(String.class,j); - assertTrue(value instanceof String); - - value = WXReflectionUtils.parseArgument(Map.class,j); - assertTrue(value instanceof Map); - assertEquals(((Map)value).get("a"),"b"); - - value = WXReflectionUtils.parseArgument(JSONObject.class,j); - assertTrue(value instanceof JSONObject); - assertEquals(((JSONObject)value).get("a"),"b"); - assertEquals(((JSONObject)value).get("c"),23); - - value = WXReflectionUtils.parseArgument(JSONObject.class, JSON.toJSONString(j)); - assertTrue(value instanceof JSONObject); - assertEquals(((JSONObject)value).get("a"),"b"); - assertEquals(((JSONObject)value).get("c"),23); - - JSONArray k = new JSONArray(); - k.add("b"); - k.add(23); - value = WXReflectionUtils.parseArgument(String[].class, k); - assertTrue(value instanceof String[]); - assertEquals(((String[])value)[0],"b"); - assertEquals(((String[])value)[1],"23"); - - value = WXReflectionUtils.parseArgument(String[].class, JSON.toJSONString(k)); - assertTrue(value instanceof String[]); - assertEquals(((String[])value)[0],"b"); - assertEquals(((String[])value)[1],"23"); - - value = WXReflectionUtils.parseArgument(List.class, JSON.toJSONString(k)); - assertTrue(value instanceof List); - assertEquals(((List)value).get(0),"b"); - assertEquals(((List)value).get(1),23); - - k = new JSONArray(); - k.add(1); - k.add(23); - value = WXReflectionUtils.parseArgument(int[].class, JSON.toJSONString(k)); - assertTrue(value instanceof int[]); - assertEquals(((int[])value)[0],1); - assertEquals(((int[])value)[1],23); - } - - @Test - public void testSetValue() throws Exception { - TestA a = new TestA(); - - WXReflectionUtils.setValue(a,"value","true"); - assertTrue(a.value); - } - - -} diff --git a/android/sdk/src/test/java/com/taobao/weex/utils/WXResourceUtilsTest.java b/android/sdk/src/test/java/com/taobao/weex/utils/WXResourceUtilsTest.java deleted file mode 100644 index caaf8ab2d8..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/utils/WXResourceUtilsTest.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.utils; - -import android.graphics.Shader; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.robolectric.RobolectricTestRunner; -import org.robolectric.annotation.Config; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; - -/** - * Created by caolijie on 16/8/4. - */ -@RunWith(RobolectricTestRunner.class) -@Config(manifest = Config.NONE) -public class WXResourceUtilsTest { - - @Test - public void testColor1() throws Exception { - int color = WXResourceUtils.getColor("#ffffff"); - assertEquals(color, 0xffffffff); - - color = WXResourceUtils.getColor("#99ffffff"); - assertEquals(color, 0x99ffffff); - - color = WXResourceUtils.getColor("#aa123123"); - assertEquals(color, 0xaa123123); - - color = WXResourceUtils.getColor("#00000000"); - assertEquals(color, 0x00000000); - - //can't match - color = WXResourceUtils.getColor("#ssssss"); - assertEquals(color, Integer.MIN_VALUE); - } - - @Test - public void testColor2() throws Exception { - int color = WXResourceUtils.getColor("#123"); - assertEquals(color, 0xff112233); - - color = WXResourceUtils.getColor("#abc"); - assertEquals(color, 0xffaabbcc); - - //can't match - color = WXResourceUtils.getColor("#12332"); - assertEquals(color, Integer.MIN_VALUE); - - color = WXResourceUtils.getColor("#sss"); - assertEquals(color, Integer.MIN_VALUE); - } - - @Test - public void testColor3() throws Exception { - int color = WXResourceUtils.getColor("rgba(50%,50%,50%, 0.5)"); - assertEquals(color, 0x7f7f7f7f); - - color = WXResourceUtils.getColor("rgba( 50%, 50% , 50% , 0.5 )"); - assertEquals(color, 0x7f7f7f7f); - - color = WXResourceUtils.getColor("rgba(255, 255, 255, 1.0)"); - assertEquals(color, 0xffffffff); - - color = WXResourceUtils.getColor("rgba(1%, 1% ,1%, 1)"); - assertEquals(color, 0xff020202); - - color = WXResourceUtils.getColor("rgba(0%, 0, 1%, 0.1)"); - assertEquals(color, 0x19000002); - - color = WXResourceUtils.getColor("rgba(100%, 100%, 100%, 0.1)"); - assertEquals(color, 0x19ffffff); - - color = WXResourceUtils.getColor("rgba(1, 1, 1, 1.0)"); - assertEquals(color, 0xff010101); - - //can't match - color = WXResourceUtils.getColor("rgba(0.1, 0.1, 0.1, 1.0)"); - assertEquals(color, Integer.MIN_VALUE); - - color = WXResourceUtils.getColor("rgba(10.0%, 101%, -0.1, 50%)"); - assertEquals(color, Integer.MIN_VALUE); - } - - @Test - public void testColor4() throws Exception { - int color = WXResourceUtils.getColor("rgb(255, 255, 255)"); - assertEquals(color, 0xffffffff); - - color = WXResourceUtils.getColor("rgb(000000, 255, 255)"); - assertEquals(color, 0xff00ffff); - - //can't match - color = WXResourceUtils.getColor("rgb(256, 256, 256)"); - assertEquals(color, 0xffffffff); - - color = WXResourceUtils.getColor("rgb(-1, 255, 255)"); - assertEquals(color, 0xff00ffff); - } - - @Test - public void testColor5() throws Exception { - int color = WXResourceUtils.getColor("aliceblue"); - assertEquals(color, 0XFFF0F8FF); - - color = WXResourceUtils.getColor("pink"); - assertEquals(color, 0XFFFFC0CB); - - //can't match - color = WXResourceUtils.getColor("jahskdja"); - assertEquals(color, Integer.MIN_VALUE); - } - - @Test - public void testGetShader() throws Exception { - Shader shader = WXResourceUtils.getShader("linear-gradient(to bottom,#a80077,blue)", 100, 100); - assertNotNull(shader); - shader = WXResourceUtils.getShader("linear-gradient(to bottom,#a80077,rgb(255,255,0))", 100, 100); - assertNotNull(shader); - shader = WXResourceUtils.getShader("linear-gradient(to bottom,#a80077,rgba(255,255,0,0.5))", 100, 100); - assertNotNull(shader); - shader = WXResourceUtils.getShader("gradient", 100, 100); - assertNull(shader); - } -} diff --git a/android/sdk/src/test/java/com/taobao/weex/utils/WXUtilsTest.java b/android/sdk/src/test/java/com/taobao/weex/utils/WXUtilsTest.java deleted file mode 100644 index e981c69e4a..0000000000 --- a/android/sdk/src/test/java/com/taobao/weex/utils/WXUtilsTest.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package com.taobao.weex.utils; - -import android.text.TextUtils; - -import com.taobao.weappplus_sdk.BuildConfig; -import com.taobao.weex.WXEnvironment; -import com.taobao.weex.WXSDKInstance; -import com.taobao.weex.common.WXConfig; - -import junit.framework.TestCase; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; -import org.powermock.api.mockito.PowerMockito; -import org.powermock.core.classloader.annotations.PowerMockIgnore; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; -import org.robolectric.annotation.Config; - -import java.util.HashMap; -import java.util.Map; - -import static org.mockito.Matchers.any; - -/** - * Created by lixinke on 16/2/24. - */ -@RunWith(PowerMockRunner.class) -@Config(constants = BuildConfig.class, sdk = 19) -@PowerMockIgnore( {"org.mockito.*", "org.robolectric.*", "android.*"}) -@PrepareForTest( {WXEnvironment.class, WXViewUtils.class, WXSDKInstance.class, TextUtils.class}) -public class WXUtilsTest extends TestCase { - - public static final float TEST_DENSITY = 3.0f; - public static final int TEST_SCREEN_WIDTH = 1024; - public static final int TEST_VIEW_PORT = 800; - - @Before - public void setUp() throws Exception { - super.setUp(); - - Map map = new HashMap<>(); - map.put(WXConfig.scale, Float.toString(TEST_DENSITY)); - PowerMockito.mockStatic(WXEnvironment.class); - PowerMockito.when(WXEnvironment.class, "getConfig").thenReturn(map); - - PowerMockito.mockStatic(WXViewUtils.class); - PowerMockito.when(WXViewUtils.class, "getScreenWidth").thenReturn(TEST_SCREEN_WIDTH); - - PowerMockito.mockStatic(WXSDKInstance.class); - PowerMockito.when(WXSDKInstance.class, "getViewPortWidth").thenReturn(TEST_VIEW_PORT); - - PowerMockito.mockStatic(TextUtils.class); - PowerMockito.when(TextUtils.isEmpty(any(CharSequence.class))).thenAnswer(new Answer() { - @Override - public Boolean answer(InvocationOnMock invocation) throws Throwable { - CharSequence a = (CharSequence) invocation.getArguments()[0]; - return !(a != null && a.length() > 0); - } - }); - // also look at @PrepareForTest if add mock of new class - } - - @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); - } - - @Test - public void testGetInt() throws Exception { - int test_int = WXUtils.getInt("23px"); - assertEquals(23, test_int); - } - - @Test - public void testGetLong() throws Exception { - long test_long = WXUtils.getLong("8098px"); - assertEquals(8098, test_long); - } - - @Test - public void testGetDouble() throws Exception { - double test_Double = WXUtils.getDouble("8098.8989px"); - assertEquals(8098.8, test_Double, 0.1); - } - - @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); - } - - @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); // double can not cast to integer - } - - @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); - } - -} diff --git a/android/sdk/src/test/java/org/mockito/configuration/MockitoConfiguration.java b/android/sdk/src/test/java/org/mockito/configuration/MockitoConfiguration.java deleted file mode 100644 index d6f285cba0..0000000000 --- a/android/sdk/src/test/java/org/mockito/configuration/MockitoConfiguration.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -package org.mockito.configuration; - -/** - * Created by sospartan on 7/28/16. - */ -public class MockitoConfiguration extends DefaultMockitoConfiguration { - @Override - public boolean enableClassCache() { - return false; - } -}