mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Add a nativeID prop to allow native code to reference react managed views
Reviewed By: sahrens Differential Revision: D4786713 fbshipit-source-id: af9cef0737c010b429d52d00181c00bd81f13f5b
This commit is contained in:
committed by
Facebook Github Bot
parent
e154117f37
commit
909af08f24
@@ -13,13 +13,14 @@ deps = [
|
||||
react_native_target("java/com/facebook/react/modules/appstate:appstate"),
|
||||
react_native_target("java/com/facebook/react/modules/core:core"),
|
||||
react_native_target("java/com/facebook/react/modules/datepicker:datepicker"),
|
||||
react_native_target("java/com/facebook/react/modules/deviceinfo:deviceinfo"),
|
||||
react_native_target("java/com/facebook/react/modules/share:share"),
|
||||
react_native_target("java/com/facebook/react/modules/systeminfo:systeminfo"),
|
||||
react_native_target("java/com/facebook/react/modules/deviceinfo:deviceinfo"),
|
||||
react_native_target("java/com/facebook/react/modules/timepicker:timepicker"),
|
||||
react_native_target("java/com/facebook/react/touch:touch"),
|
||||
react_native_target("java/com/facebook/react/uimanager:uimanager"),
|
||||
react_native_target("java/com/facebook/react/uimanager/annotations:annotations"),
|
||||
react_native_target("java/com/facebook/react/uimanager/util:util"),
|
||||
react_native_target("java/com/facebook/react/views/picker:picker"),
|
||||
react_native_target("java/com/facebook/react/views/progressbar:progressbar"),
|
||||
react_native_target("java/com/facebook/react/views/scroll:scroll"),
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Copyright (c) 2014-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
package com.facebook.react.tests;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.facebook.react.testing.ReactAppInstrumentationTestCase;
|
||||
import com.facebook.react.uimanager.util.ReactFindViewUtil;
|
||||
|
||||
/**
|
||||
* Tests that the 'nativeID' property can be set on various views.
|
||||
* The 'nativeID' property is used to reference react managed views from native code.
|
||||
*/
|
||||
public class NativeIdTestCase extends ReactAppInstrumentationTestCase {
|
||||
|
||||
@Override
|
||||
protected String getReactApplicationKeyUnderTest() {
|
||||
return "NativeIdTestApp";
|
||||
}
|
||||
|
||||
private final List<String> viewTags = Arrays.asList(
|
||||
"Image",
|
||||
"Text",
|
||||
"TouchableBounce",
|
||||
"TouchableHighlight",
|
||||
"TouchableOpacity",
|
||||
"TouchableWithoutFeedback",
|
||||
"TextInput",
|
||||
"View");
|
||||
|
||||
public void testPropertyIsSetForViews() {
|
||||
for (String nativeId : viewTags) {
|
||||
View viewWithTag = ReactFindViewUtil.findViewByNativeId(
|
||||
getActivity().getRootView(),
|
||||
nativeId);
|
||||
assertNotNull(
|
||||
"View with nativeID " + nativeId + " was not found. Check NativeIdTestModule.js.",
|
||||
viewWithTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user