mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-02 22:41:18 +08:00
Add interface for ReactShadowNode
Reviewed By: AaaChiuuu Differential Revision: D5871546 fbshipit-source-id: 7c338fe3b747a79377a54867c789028d221b3dd5
This commit is contained in:
committed by
Facebook Github Bot
parent
6334ed2ff3
commit
08befb730b
@@ -9,27 +9,25 @@
|
||||
|
||||
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
|
||||
@@ -61,7 +59,7 @@ public class ReactPropForShadowNodeSetterTest {
|
||||
return new ReactStylesDiffMap(JavaOnlyMap.of(keysAndValues));
|
||||
}
|
||||
|
||||
private class ShadowViewUnderTest extends ReactShadowNode {
|
||||
private class ShadowViewUnderTest extends ReactShadowNodeImpl {
|
||||
|
||||
private ViewManagerUpdatesReceiver mViewManagerUpdatesReceiver;
|
||||
|
||||
|
||||
@@ -9,15 +9,12 @@
|
||||
|
||||
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 org.junit.Test;
|
||||
import java.util.Map;
|
||||
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;
|
||||
@@ -69,55 +66,61 @@ public class ReactPropForShadowNodeSpecTest {
|
||||
|
||||
@Test(expected = RuntimeException.class)
|
||||
public void testMethodWithWrongNumberOfParams() {
|
||||
new BaseViewManager(new ReactShadowNode() {
|
||||
@ReactProp(name = "prop")
|
||||
public void setterWithIncorrectNumberOfArgs(boolean value, int anotherValue) {
|
||||
}
|
||||
}.getClass()).getNativeProps();
|
||||
new BaseViewManager(
|
||||
new ReactShadowNodeImpl() {
|
||||
@ReactProp(name = "prop")
|
||||
public void setterWithIncorrectNumberOfArgs(boolean value, int anotherValue) {}
|
||||
}.getClass())
|
||||
.getNativeProps();
|
||||
}
|
||||
|
||||
@Test(expected = RuntimeException.class)
|
||||
public void testMethodWithTooFewParams() {
|
||||
new BaseViewManager(new ReactShadowNode() {
|
||||
@ReactProp(name = "prop")
|
||||
public void setterWithNoArgs() {
|
||||
}
|
||||
}.getClass()).getNativeProps();
|
||||
new BaseViewManager(
|
||||
new ReactShadowNodeImpl() {
|
||||
@ReactProp(name = "prop")
|
||||
public void setterWithNoArgs() {}
|
||||
}.getClass())
|
||||
.getNativeProps();
|
||||
}
|
||||
|
||||
@Test(expected = RuntimeException.class)
|
||||
public void testUnsupportedValueType() {
|
||||
new BaseViewManager(new ReactShadowNode() {
|
||||
@ReactProp(name = "prop")
|
||||
public void setterWithMap(Map value) {
|
||||
}
|
||||
}.getClass()).getNativeProps();
|
||||
new BaseViewManager(
|
||||
new ReactShadowNodeImpl() {
|
||||
@ReactProp(name = "prop")
|
||||
public void setterWithMap(Map value) {}
|
||||
}.getClass())
|
||||
.getNativeProps();
|
||||
}
|
||||
|
||||
@Test(expected = RuntimeException.class)
|
||||
public void testGroupInvalidNumberOfParams() {
|
||||
new BaseViewManager(new ReactShadowNode() {
|
||||
@ReactPropGroup(names = {"prop1", "prop2"})
|
||||
public void setterWithTooManyParams(int index, float value, boolean bool) {
|
||||
}
|
||||
}.getClass()).getNativeProps();
|
||||
new BaseViewManager(
|
||||
new ReactShadowNodeImpl() {
|
||||
@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 ReactShadowNode() {
|
||||
@ReactPropGroup(names = {"prop1", "prop2"})
|
||||
public void setterWithTooManyParams(int index) {
|
||||
}
|
||||
}.getClass()).getNativeProps();
|
||||
new BaseViewManager(
|
||||
new ReactShadowNodeImpl() {
|
||||
@ReactPropGroup(names = {"prop1", "prop2"})
|
||||
public void setterWithTooManyParams(int index) {}
|
||||
}.getClass())
|
||||
.getNativeProps();
|
||||
}
|
||||
|
||||
@Test(expected = RuntimeException.class)
|
||||
public void testGroupNoIndexParam() {
|
||||
new BaseViewManager(new ReactShadowNode() {
|
||||
@ReactPropGroup(names = {"prop1", "prop2"})
|
||||
public void setterWithTooManyParams(float value, boolean bool) {
|
||||
}
|
||||
}.getClass()).getNativeProps();
|
||||
new BaseViewManager(
|
||||
new ReactShadowNodeImpl() {
|
||||
@ReactPropGroup(names = {"prop1", "prop2"})
|
||||
public void setterWithTooManyParams(float value, boolean bool) {}
|
||||
}.getClass())
|
||||
.getNativeProps();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user