mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-05 09:29:07 +08:00
Backed out changeset 7c338fe3b747
Reviewed By: AaaChiuuu Differential Revision: D5926999 fbshipit-source-id: 58595f74f1fab764b63b5d7d6c2f20d8edb2efda
This commit is contained in:
committed by
Facebook Github Bot
parent
672db77eae
commit
9b3cc30357
@@ -9,25 +9,27 @@
|
||||
|
||||
package com.facebook.react.uimanager;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.bridge.JavaOnlyMap;
|
||||
import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
import com.facebook.react.uimanager.annotations.ReactPropGroup;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||
import org.powermock.modules.junit4.rule.PowerMockRule;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.reset;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
|
||||
import com.facebook.react.bridge.JavaOnlyMap;
|
||||
import com.facebook.react.bridge.ReadableArray;
|
||||
import com.facebook.react.bridge.ReadableMap;
|
||||
import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
import com.facebook.react.uimanager.annotations.ReactPropGroup;
|
||||
import javax.annotation.Nullable;
|
||||
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.modules.junit4.rule.PowerMockRule;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
|
||||
/**
|
||||
* Test {@link ReactProp} annotation for {@link ReactShadowNode}. More comprahensive test of this
|
||||
* annotation can be found in {@link ReactPropAnnotationSetterTest} where we test all possible types
|
||||
@@ -59,7 +61,7 @@ public class ReactPropForShadowNodeSetterTest {
|
||||
return new ReactStylesDiffMap(JavaOnlyMap.of(keysAndValues));
|
||||
}
|
||||
|
||||
private class ShadowViewUnderTest extends ReactShadowNodeImpl {
|
||||
private class ShadowViewUnderTest extends ReactShadowNode {
|
||||
|
||||
private ViewManagerUpdatesReceiver mViewManagerUpdatesReceiver;
|
||||
|
||||
|
||||
@@ -9,12 +9,15 @@
|
||||
|
||||
package com.facebook.react.uimanager;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.facebook.react.uimanager.annotations.ReactProp;
|
||||
import com.facebook.react.uimanager.annotations.ReactPropGroup;
|
||||
import java.util.Map;
|
||||
import org.junit.Rule;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.Rule;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||
import org.powermock.modules.junit4.rule.PowerMockRule;
|
||||
@@ -66,61 +69,55 @@ public class ReactPropForShadowNodeSpecTest {
|
||||
|
||||
@Test(expected = RuntimeException.class)
|
||||
public void testMethodWithWrongNumberOfParams() {
|
||||
new BaseViewManager(
|
||||
new ReactShadowNodeImpl() {
|
||||
@ReactProp(name = "prop")
|
||||
public void setterWithIncorrectNumberOfArgs(boolean value, int anotherValue) {}
|
||||
}.getClass())
|
||||
.getNativeProps();
|
||||
new BaseViewManager(new ReactShadowNode() {
|
||||
@ReactProp(name = "prop")
|
||||
public void setterWithIncorrectNumberOfArgs(boolean value, int anotherValue) {
|
||||
}
|
||||
}.getClass()).getNativeProps();
|
||||
}
|
||||
|
||||
@Test(expected = RuntimeException.class)
|
||||
public void testMethodWithTooFewParams() {
|
||||
new BaseViewManager(
|
||||
new ReactShadowNodeImpl() {
|
||||
@ReactProp(name = "prop")
|
||||
public void setterWithNoArgs() {}
|
||||
}.getClass())
|
||||
.getNativeProps();
|
||||
new BaseViewManager(new ReactShadowNode() {
|
||||
@ReactProp(name = "prop")
|
||||
public void setterWithNoArgs() {
|
||||
}
|
||||
}.getClass()).getNativeProps();
|
||||
}
|
||||
|
||||
@Test(expected = RuntimeException.class)
|
||||
public void testUnsupportedValueType() {
|
||||
new BaseViewManager(
|
||||
new ReactShadowNodeImpl() {
|
||||
@ReactProp(name = "prop")
|
||||
public void setterWithMap(Map value) {}
|
||||
}.getClass())
|
||||
.getNativeProps();
|
||||
new BaseViewManager(new ReactShadowNode() {
|
||||
@ReactProp(name = "prop")
|
||||
public void setterWithMap(Map value) {
|
||||
}
|
||||
}.getClass()).getNativeProps();
|
||||
}
|
||||
|
||||
@Test(expected = RuntimeException.class)
|
||||
public void testGroupInvalidNumberOfParams() {
|
||||
new BaseViewManager(
|
||||
new ReactShadowNodeImpl() {
|
||||
@ReactPropGroup(names = {"prop1", "prop2"})
|
||||
public void setterWithTooManyParams(int index, float value, boolean bool) {}
|
||||
}.getClass())
|
||||
.getNativeProps();
|
||||
new BaseViewManager(new ReactShadowNode() {
|
||||
@ReactPropGroup(names = {"prop1", "prop2"})
|
||||
public void setterWithTooManyParams(int index, float value, boolean bool) {
|
||||
}
|
||||
}.getClass()).getNativeProps();
|
||||
}
|
||||
|
||||
@Test(expected = RuntimeException.class)
|
||||
public void testGroupTooFewParams() {
|
||||
new BaseViewManager(
|
||||
new ReactShadowNodeImpl() {
|
||||
@ReactPropGroup(names = {"prop1", "prop2"})
|
||||
public void setterWithTooManyParams(int index) {}
|
||||
}.getClass())
|
||||
.getNativeProps();
|
||||
new BaseViewManager(new ReactShadowNode() {
|
||||
@ReactPropGroup(names = {"prop1", "prop2"})
|
||||
public void setterWithTooManyParams(int index) {
|
||||
}
|
||||
}.getClass()).getNativeProps();
|
||||
}
|
||||
|
||||
@Test(expected = RuntimeException.class)
|
||||
public void testGroupNoIndexParam() {
|
||||
new BaseViewManager(
|
||||
new ReactShadowNodeImpl() {
|
||||
@ReactPropGroup(names = {"prop1", "prop2"})
|
||||
public void setterWithTooManyParams(float value, boolean bool) {}
|
||||
}.getClass())
|
||||
.getNativeProps();
|
||||
new BaseViewManager(new ReactShadowNode() {
|
||||
@ReactPropGroup(names = {"prop1", "prop2"})
|
||||
public void setterWithTooManyParams(float value, boolean bool) {
|
||||
}
|
||||
}.getClass()).getNativeProps();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user