mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-02 17:47:21 +08:00
Use tag ids for testID
Summary: View tags are currently used for end-to-end test IDs. We'd like to overload the tag field with other information such as nativeID (for native refs) and transitionID (for shared element transitions) in the future. Added a key for testID's tag Reviewed By: AaaChiuuu Differential Revision: D4833045 fbshipit-source-id: c2f9371c9a3dbb2411e114f4f096f723ac3132c0
This commit is contained in:
committed by
Facebook Github Bot
parent
da43c297f4
commit
3bf367cbb7
@@ -21,6 +21,8 @@ android_library(
|
||||
react_native_dep("third-party/java/junit:junit"),
|
||||
react_native_dep("third-party/java/mockito:mockito"),
|
||||
react_native_dep("third-party/java/testing-support-lib:runner"),
|
||||
react_native_integration_tests_target("java/com/facebook/react/testing/idledetection:idledetection"),
|
||||
react_native_integration_tests_target("java/com/facebook/react/testing/network:network"),
|
||||
react_native_target("java/com/facebook/react:react"),
|
||||
react_native_target("java/com/facebook/react/bridge:bridge"),
|
||||
react_native_target("java/com/facebook/react/common:common"),
|
||||
@@ -32,7 +34,6 @@ android_library(
|
||||
react_native_target("java/com/facebook/react/modules/debug:interfaces"),
|
||||
react_native_target("java/com/facebook/react/shell:shell"),
|
||||
react_native_target("java/com/facebook/react/uimanager:uimanager"),
|
||||
react_native_integration_tests_target("java/com/facebook/react/testing/idledetection:idledetection"),
|
||||
react_native_integration_tests_target("java/com/facebook/react/testing/network:network"),
|
||||
react_native_target("res:uimanager"),
|
||||
],
|
||||
)
|
||||
|
||||
@@ -17,6 +17,7 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.facebook.react.NativeModuleRegistryBuilder;
|
||||
import com.facebook.react.R;
|
||||
import com.facebook.react.ReactInstanceManager;
|
||||
import com.facebook.react.ReactInstanceManagerBuilder;
|
||||
import com.facebook.react.bridge.CatalystInstance;
|
||||
@@ -187,7 +188,9 @@ public class ReactTestHelper {
|
||||
}
|
||||
|
||||
public static String getTestId(View view) {
|
||||
return view.getTag() instanceof String ? (String) view.getTag() : null;
|
||||
return view.getTag(R.id.react_test_id) instanceof String
|
||||
? (String) view.getTag(R.id.react_test_id)
|
||||
: null;
|
||||
}
|
||||
|
||||
private static View findChild(View root, Predicate<View> predicate) {
|
||||
@@ -211,7 +214,7 @@ public class ReactTestHelper {
|
||||
return new Predicate<View>() {
|
||||
@Override
|
||||
public boolean apply(View view) {
|
||||
Object tag = view.getTag();
|
||||
Object tag = getTestId(view);
|
||||
return tag != null && tag.equals(tagValue);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user