Skip to content

Commit

Permalink
Add e2e test for object props
Browse files Browse the repository at this point in the history
Summary: Adds e2e tests for cxx and java object props

Reviewed By: JoshuaGross

Differential Revision: D16759242

fbshipit-source-id: 2307dc4b3ba26222de510cf5876c582d35fc665c
  • Loading branch information
rickhanlonii authored and facebook-github-bot committed Aug 15, 2019
1 parent 56f9eb3 commit 70fc54a
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.facebook.react.uimanager;

import android.view.ViewGroup;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.viewmanagers.ObjectPropsNativeComponentManagerDelegate;
import com.facebook.react.viewmanagers.ObjectPropsNativeComponentManagerInterface;

public class ObjectPropsNativeComponentManager extends SimpleViewManager<ViewGroup>
implements ObjectPropsNativeComponentManagerInterface<ViewGroup> {

public static final String REACT_CLASS = "ObjectPropsNativeComponent";

@Override
public String getName() {
return REACT_CLASS;
}

private void test() {
ObjectPropsNativeComponentManagerDelegate<ViewGroup, ObjectPropsNativeComponentManager>
delegate = new ObjectPropsNativeComponentManagerDelegate<>(this);
}

@Override
public ViewGroup createViewInstance(ThemedReactContext context) {
throw new IllegalStateException();
}

@Override
public void setObjectProp(ViewGroup view, ReadableMap value) {}

@Override
public void setObjectArrayProp(ViewGroup view, ReadableMap value) {}

@Override
public void setObjectPrimitiveRequiredProp(ViewGroup view, ReadableMap value) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
* @flow
*/

'use strict';

import type {
PointValue,
ColorValue,
} from '../../../../../Libraries/StyleSheet/StyleSheetTypes';
import type {ImageSource} from '../../../../../Libraries/Image/ImageSource';
import type {
Int32,
Float,
WithDefault,
} from '../../../../../Libraries/Types/CodegenTypes';
import type {ViewProps} from '../../../../../Libraries/Components/View/ViewPropTypes';
import codegenNativeComponent from '../../../../../Libraries/Utilities/codegenNativeComponent';

type ObjectArrayPropType = $ReadOnly<{|
array: $ReadOnlyArray<string>,
|}>;

type NativeProps = $ReadOnly<{|
...ViewProps,

// Props
objectProp?: $ReadOnly<{|
stringProp?: WithDefault<string, ''>,
booleanProp: boolean,
floatProp: Float,
intProp: Int32,
stringEnumProp?: WithDefault<'small' | 'large', 'small'>,
|}>,
objectArrayProp: ObjectArrayPropType,
objectPrimitiveRequiredProp: $ReadOnly<{|
image: ImageSource,
color?: ColorValue,
point: ?PointValue,
|}>,
|}>;

export default codegenNativeComponent<NativeProps>(
'ObjectPropsNativeComponent',
);

0 comments on commit 70fc54a

Please sign in to comment.