From c58106344e89fd98edef16e7c445a087f09ad4da Mon Sep 17 00:00:00 2001 From: Rick Hanlon Date: Fri, 6 Sep 2019 05:30:51 -0700 Subject: [PATCH] Update unrelated Int32Enum snapshots Summary: This diff adds the snapshots for the new Int32 fixture and renames the ENUM_ fixture to STRING_ENUM Reviewed By: JoshuaGross Differential Revision: D17158033 fbshipit-source-id: 405b1da5ede16410434a9097ef256f99e4115533 --- .../components/__test_fixtures__/fixtures.js | 8 +- .../__tests__/GeneratePropsH-test.js | 1 + .../GenerateComponentDescriptorH-test.js.snap | 78 ++++++---- .../GenerateComponentHObjCpp-test.js.snap | 69 ++++++--- .../GenerateEventEmitterCpp-test.js.snap | 69 ++++++--- .../GenerateEventEmitterH-test.js.snap | 72 ++++++--- .../GeneratePropsCpp-test.js.snap | 87 +++++++---- .../__snapshots__/GeneratePropsH-test.js.snap | 100 ++++++------- .../GeneratePropsJavaDelegate-test.js.snap | 114 ++++++++++----- .../GeneratePropsJavaInterface-test.js.snap | 69 ++++++--- .../GenerateShadowNodeCpp-test.js.snap | 69 ++++++--- .../GenerateShadowNodeH-test.js.snap | 99 ++++++++----- .../__snapshots__/GenerateTests-test.js.snap | 138 +++++++++++------- .../GenerateViewConfigJs-test.js.snap | 105 ++++++++----- 14 files changed, 692 insertions(+), 386 deletions(-) diff --git a/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js b/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js index eb42918692f..fb266ec03fb 100644 --- a/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js +++ b/packages/react-native-codegen/src/generators/components/__test_fixtures__/fixtures.js @@ -948,11 +948,11 @@ const MULTI_NATIVE_PROP: SchemaType = { }, }; -const ENUM_PROP: SchemaType = { +const STRING_ENUM_PROP: SchemaType = { modules: { Switch: { components: { - EnumPropsNativeComponent: { + StringEnumPropsNativeComponent: { extendsProps: [ { type: 'ReactNativeBuiltInType', @@ -1453,8 +1453,8 @@ module.exports = { ARRAY_PROPS_WITH_NESTED_OBJECT, OBJECT_PROPS, MULTI_NATIVE_PROP, - ENUM_PROP, - // INT32_ENUM_PROP, + STRING_ENUM_PROP, + INT32_ENUM_PROP, EVENT_PROPS, EVENTS_WITH_PAPER_NAME, EVENT_NESTED_OBJECT_PROPS, diff --git a/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsH-test.js b/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsH-test.js index 23f8769ebeb..543831f0e41 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsH-test.js +++ b/packages/react-native-codegen/src/generators/components/__tests__/GeneratePropsH-test.js @@ -17,6 +17,7 @@ const generator = require('../GeneratePropsH.js'); describe('GeneratePropsH', () => { Object.keys(fixtures) .sort() + .filter(fixtureName => fixtureName !== 'INT32_ENUM_PROP') .forEach(fixtureName => { const fixture = fixtures[fixtureName]; diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap index 839f67d4fec..fa7a8c09edc 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentDescriptorH-test.js.snap @@ -182,32 +182,6 @@ using DoublePropNativeComponentComponentDescriptor = ConcreteComponentDescriptor } `; -exports[`GenerateComponentDescriptorH can generate fixture ENUM_PROP 1`] = ` -Map { - "ComponentDescriptors.h" => " -/** - * 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. - */ - -#pragma once - -#include -#include - -namespace facebook { -namespace react { - -using EnumPropsNativeComponentComponentDescriptor = ConcreteComponentDescriptor; - -} // namespace react -} // namespace facebook -", -} -`; - exports[`GenerateComponentDescriptorH can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] = ` Map { "ComponentDescriptors.h" => " @@ -338,6 +312,32 @@ using ImagePropNativeComponentComponentDescriptor = ConcreteComponentDescriptor< } `; +exports[`GenerateComponentDescriptorH can generate fixture INT32_ENUM_PROP 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * 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. + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using Int32EnumPropsNativeComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GenerateComponentDescriptorH can generate fixture INTEGER_PROPS 1`] = ` Map { "ComponentDescriptors.h" => " @@ -494,6 +494,32 @@ using PointPropNativeComponentComponentDescriptor = ConcreteComponentDescriptor< } `; +exports[`GenerateComponentDescriptorH can generate fixture STRING_ENUM_PROP 1`] = ` +Map { + "ComponentDescriptors.h" => " +/** + * 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. + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +using StringEnumPropsNativeComponentComponentDescriptor = ConcreteComponentDescriptor; + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GenerateComponentDescriptorH can generate fixture STRING_PROP 1`] = ` Map { "ComponentDescriptors.h" => " diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentHObjCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentHObjCpp-test.js.snap index b7533f3d267..c39cb834d42 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentHObjCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateComponentHObjCpp-test.js.snap @@ -276,29 +276,6 @@ NS_ASSUME_NONNULL_END", } `; -exports[`GenerateComponentHObjCpp can generate fixture ENUM_PROP 1`] = ` -Map { - "RCTComponentViewHelpers.h" => "/** -* 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. -*/ - -#import -#import -#import - -NS_ASSUME_NONNULL_BEGIN - -@protocol RCTEnumPropsNativeComponentViewProtocol - -@end - -NS_ASSUME_NONNULL_END", -} -`; - exports[`GenerateComponentHObjCpp can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** @@ -414,6 +391,29 @@ NS_ASSUME_NONNULL_END", } `; +exports[`GenerateComponentHObjCpp can generate fixture INT32_ENUM_PROP 1`] = ` +Map { + "RCTComponentViewHelpers.h" => "/** +* 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. +*/ + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol RCTInt32EnumPropsNativeComponentViewProtocol + +@end + +NS_ASSUME_NONNULL_END", +} +`; + exports[`GenerateComponentHObjCpp can generate fixture INTEGER_PROPS 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** @@ -552,6 +552,29 @@ NS_ASSUME_NONNULL_END", } `; +exports[`GenerateComponentHObjCpp can generate fixture STRING_ENUM_PROP 1`] = ` +Map { + "RCTComponentViewHelpers.h" => "/** +* 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. +*/ + +#import +#import +#import + +NS_ASSUME_NONNULL_BEGIN + +@protocol RCTStringEnumPropsNativeComponentViewProtocol + +@end + +NS_ASSUME_NONNULL_END", +} +`; + exports[`GenerateComponentHObjCpp can generate fixture STRING_PROP 1`] = ` Map { "RCTComponentViewHelpers.h" => "/** diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap index 2b31ca86cac..00a98bbbe53 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterCpp-test.js.snap @@ -155,29 +155,6 @@ namespace react { -} // namespace react -} // namespace facebook -", -} -`; - -exports[`GenerateEventEmitterCpp can generate fixture ENUM_PROP 1`] = ` -Map { - "EventEmitters.cpp" => " -/** - * 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. - */ - -#include - -namespace facebook { -namespace react { - - - } // namespace react } // namespace facebook ", @@ -350,6 +327,29 @@ namespace react { +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterCpp can generate fixture INT32_ENUM_PROP 1`] = ` +Map { + "EventEmitters.cpp" => " +/** + * 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. + */ + +#include + +namespace facebook { +namespace react { + + + } // namespace react } // namespace facebook ", @@ -494,6 +494,29 @@ namespace react { +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterCpp can generate fixture STRING_ENUM_PROP 1`] = ` +Map { + "EventEmitters.cpp" => " +/** + * 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. + */ + +#include + +namespace facebook { +namespace react { + + + } // namespace react } // namespace facebook ", diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterH-test.js.snap index d1ab6358079..886e5ca8697 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateEventEmitterH-test.js.snap @@ -162,30 +162,6 @@ namespace react { -} // namespace react -} // namespace facebook -", -} -`; - -exports[`GenerateEventEmitterH can generate fixture ENUM_PROP 1`] = ` -Map { - "EventEmitters.h" => " -/** - * 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. - */ -#pragma once - -#include - -namespace facebook { -namespace react { - - - } // namespace react } // namespace facebook ", @@ -378,6 +354,30 @@ namespace react { +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterH can generate fixture INT32_ENUM_PROP 1`] = ` +Map { + "EventEmitters.h" => " +/** + * 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. + */ +#pragma once + +#include + +namespace facebook { +namespace react { + + + } // namespace react } // namespace facebook ", @@ -531,6 +531,30 @@ namespace react { +} // namespace react +} // namespace facebook +", +} +`; + +exports[`GenerateEventEmitterH can generate fixture STRING_ENUM_PROP 1`] = ` +Map { + "EventEmitters.h" => " +/** + * 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. + */ +#pragma once + +#include + +namespace facebook { +namespace react { + + + } // namespace react } // namespace facebook ", diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap index bfc00ae64f2..908788a3665 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsCpp-test.js.snap @@ -218,35 +218,6 @@ DoublePropNativeComponentProps::DoublePropNativeComponentProps( } `; -exports[`GeneratePropsCpp can generate fixture ENUM_PROP 1`] = ` -Map { - "Props.cpp" => " -/** - * 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. - */ - -#include -#include - -namespace facebook { -namespace react { - -EnumPropsNativeComponentProps::EnumPropsNativeComponentProps( - const EnumPropsNativeComponentProps &sourceProps, - const RawProps &rawProps): ViewProps(sourceProps, rawProps), - - alignment(convertRawProp(rawProps, \\"alignment\\", sourceProps.alignment, {EnumPropsNativeComponentAlignment::Center})) - {} - -} // namespace react -} // namespace facebook -", -} -`; - exports[`GeneratePropsCpp can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] = ` Map { "Props.cpp" => " @@ -398,6 +369,35 @@ ImagePropNativeComponentProps::ImagePropNativeComponentProps( } `; +exports[`GeneratePropsCpp can generate fixture INT32_ENUM_PROP 1`] = ` +Map { + "Props.cpp" => " +/** + * 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. + */ + +#include +#include + +namespace facebook { +namespace react { + +Int32EnumPropsNativeComponentProps::Int32EnumPropsNativeComponentProps( + const Int32EnumPropsNativeComponentProps &sourceProps, + const RawProps &rawProps): ViewProps(sourceProps, rawProps), + + maxInterval(convertRawProp(rawProps, \\"maxInterval\\", sourceProps.maxInterval, {Int32EnumPropsNativeComponentMaxInterval::TODO})) + {} + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GeneratePropsCpp can generate fixture INTEGER_PROPS 1`] = ` Map { "Props.cpp" => " @@ -579,6 +579,35 @@ PointPropNativeComponentProps::PointPropNativeComponentProps( } `; +exports[`GeneratePropsCpp can generate fixture STRING_ENUM_PROP 1`] = ` +Map { + "Props.cpp" => " +/** + * 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. + */ + +#include +#include + +namespace facebook { +namespace react { + +StringEnumPropsNativeComponentProps::StringEnumPropsNativeComponentProps( + const StringEnumPropsNativeComponentProps &sourceProps, + const RawProps &rawProps): ViewProps(sourceProps, rawProps), + + alignment(convertRawProp(rawProps, \\"alignment\\", sourceProps.alignment, {StringEnumPropsNativeComponentAlignment::Center})) + {} + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GeneratePropsCpp can generate fixture STRING_PROP 1`] = ` Map { "Props.cpp" => " diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap index efce8c2e44d..8df6d90d0c7 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsH-test.js.snap @@ -420,56 +420,6 @@ class DoublePropNativeComponentProps final : public ViewProps { } `; -exports[`GeneratePropsH can generate fixture ENUM_PROP 1`] = ` -Map { - "Props.h" => " -/** - * 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. - */ -#pragma once - -#include - -namespace facebook { -namespace react { - -enum class EnumPropsNativeComponentAlignment { Top, Center, BottomRight }; - -static inline void fromRawValue(const RawValue &value, EnumPropsNativeComponentAlignment &result) { - auto string = (std::string)value; - if (string == \\"top\\") { result = EnumPropsNativeComponentAlignment::Top; return; } - if (string == \\"center\\") { result = EnumPropsNativeComponentAlignment::Center; return; } - if (string == \\"bottom-right\\") { result = EnumPropsNativeComponentAlignment::BottomRight; return; } - abort(); -} - -static inline std::string toString(const EnumPropsNativeComponentAlignment &value) { - switch (value) { - case EnumPropsNativeComponentAlignment::Top: return \\"top\\"; - case EnumPropsNativeComponentAlignment::Center: return \\"center\\"; - case EnumPropsNativeComponentAlignment::BottomRight: return \\"bottom-right\\"; - } -} - -class EnumPropsNativeComponentProps final : public ViewProps { - public: - EnumPropsNativeComponentProps() = default; - EnumPropsNativeComponentProps(const EnumPropsNativeComponentProps &sourceProps, const RawProps &rawProps); - -#pragma mark - Props - - const EnumPropsNativeComponentAlignment alignment{EnumPropsNativeComponentAlignment::Center}; -}; - -} // namespace react -} // namespace facebook -", -} -`; - exports[`GeneratePropsH can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] = ` Map { "Props.h" => " @@ -1034,6 +984,56 @@ class PointPropNativeComponentProps final : public ViewProps { } `; +exports[`GeneratePropsH can generate fixture STRING_ENUM_PROP 1`] = ` +Map { + "Props.h" => " +/** + * 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. + */ +#pragma once + +#include + +namespace facebook { +namespace react { + +enum class StringEnumPropsNativeComponentAlignment { Top, Center, BottomRight }; + +static inline void fromRawValue(const RawValue &value, StringEnumPropsNativeComponentAlignment &result) { + auto string = (std::string)value; + if (string == \\"top\\") { result = StringEnumPropsNativeComponentAlignment::Top; return; } + if (string == \\"center\\") { result = StringEnumPropsNativeComponentAlignment::Center; return; } + if (string == \\"bottom-right\\") { result = StringEnumPropsNativeComponentAlignment::BottomRight; return; } + abort(); +} + +static inline std::string toString(const StringEnumPropsNativeComponentAlignment &value) { + switch (value) { + case StringEnumPropsNativeComponentAlignment::Top: return \\"top\\"; + case StringEnumPropsNativeComponentAlignment::Center: return \\"center\\"; + case StringEnumPropsNativeComponentAlignment::BottomRight: return \\"bottom-right\\"; + } +} + +class StringEnumPropsNativeComponentProps final : public ViewProps { + public: + StringEnumPropsNativeComponentProps() = default; + StringEnumPropsNativeComponentProps(const StringEnumPropsNativeComponentProps &sourceProps, const RawProps &rawProps); + +#pragma mark - Props + + const StringEnumPropsNativeComponentAlignment alignment{StringEnumPropsNativeComponentAlignment::Center}; +}; + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GeneratePropsH can generate fixture STRING_PROP 1`] = ` Map { "Props.h" => " diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap index 69a28bb9bf0..fcacafd6a9b 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaDelegate-test.js.snap @@ -325,44 +325,6 @@ public class DoublePropNativeComponentManagerDelegate "/** -* 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. -* -* @generated by codegen project: GeneratePropsJavaDelegate.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; -import com.facebook.react.uimanager.BaseViewManagerDelegate; -import com.facebook.react.uimanager.BaseViewManagerInterface; -import com.facebook.react.uimanager.LayoutShadowNode; - -public class EnumPropsNativeComponentManagerDelegate & EnumPropsNativeComponentManagerInterface> extends BaseViewManagerDelegate { - public EnumPropsNativeComponentManagerDelegate(U viewManager) { - super(viewManager); - } - @Override - public void setProperty(T view, String propName, @Nullable Object value) { - switch (propName) { - case \\"alignment\\": - mViewManager.setAlignment(view, (String) value); - break; - default: - super.setProperty(view, propName, value); - } - } -} -", -} -`; - exports[`GeneratePropsJavaDelegate can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] = ` Map { "EventsNestedObjectNativeComponentManagerDelegate.java" => "/** @@ -563,6 +525,44 @@ public class ImagePropNativeComponentManagerDelegate "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaDelegate.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.BaseViewManagerInterface; +import com.facebook.react.uimanager.LayoutShadowNode; + +public class Int32EnumPropsNativeComponentManagerDelegate & Int32EnumPropsNativeComponentManagerInterface> extends BaseViewManagerDelegate { + public Int32EnumPropsNativeComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { + switch (propName) { + case \\"maxInterval\\": + mViewManager.setMaxInterval(view, value == null ? 0 : ((Double) value).intValue()); + break; + default: + super.setProperty(view, propName, value); + } + } +} +", +} +`; + exports[`GeneratePropsJavaDelegate can generate fixture INTEGER_PROPS 1`] = ` Map { "IntegerPropNativeComponentManagerDelegate.java" => "/** @@ -803,6 +803,44 @@ public class PointPropNativeComponentManagerDelegate "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaDelegate.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; +import com.facebook.react.uimanager.BaseViewManagerDelegate; +import com.facebook.react.uimanager.BaseViewManagerInterface; +import com.facebook.react.uimanager.LayoutShadowNode; + +public class StringEnumPropsNativeComponentManagerDelegate & StringEnumPropsNativeComponentManagerInterface> extends BaseViewManagerDelegate { + public StringEnumPropsNativeComponentManagerDelegate(U viewManager) { + super(viewManager); + } + @Override + public void setProperty(T view, String propName, @Nullable Object value) { + switch (propName) { + case \\"alignment\\": + mViewManager.setAlignment(view, (String) value); + break; + default: + super.setProperty(view, propName, value); + } + } +} +", +} +`; + exports[`GeneratePropsJavaDelegate can generate fixture STRING_PROP 1`] = ` Map { "StringPropComponentManagerDelegate.java" => "/** diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap index 18938d1855a..80793d67cf0 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GeneratePropsJavaInterface-test.js.snap @@ -177,29 +177,6 @@ public interface DoublePropNativeComponentManagerInterface { } `; -exports[`GeneratePropsJavaInterface can generate fixture ENUM_PROP 1`] = ` -Map { - "EnumPropsNativeComponentManagerInterface.java" => "/** -* 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. -* -* @generated by codegen project: GeneratePropsJavaInterface.js -*/ - -package com.facebook.react.viewmanagers; - -import android.view.View; -import androidx.annotation.Nullable; - -public interface EnumPropsNativeComponentManagerInterface { - void setAlignment(T view, @Nullable String value); -} -", -} -`; - exports[`GeneratePropsJavaInterface can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] = ` Map { "EventsNestedObjectNativeComponentManagerInterface.java" => "/** @@ -317,6 +294,29 @@ public interface ImagePropNativeComponentManagerInterface { } `; +exports[`GeneratePropsJavaInterface can generate fixture INT32_ENUM_PROP 1`] = ` +Map { + "Int32EnumPropsNativeComponentManagerInterface.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaInterface.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; + +public interface Int32EnumPropsNativeComponentManagerInterface { + void setMaxInterval(T view, @Nullable Integer value); +} +", +} +`; + exports[`GeneratePropsJavaInterface can generate fixture INTEGER_PROPS 1`] = ` Map { "IntegerPropNativeComponentManagerInterface.java" => "/** @@ -461,6 +461,29 @@ public interface PointPropNativeComponentManagerInterface { } `; +exports[`GeneratePropsJavaInterface can generate fixture STRING_ENUM_PROP 1`] = ` +Map { + "StringEnumPropsNativeComponentManagerInterface.java" => "/** +* 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. +* +* @generated by codegen project: GeneratePropsJavaInterface.js +*/ + +package com.facebook.react.viewmanagers; + +import android.view.View; +import androidx.annotation.Nullable; + +public interface StringEnumPropsNativeComponentManagerInterface { + void setAlignment(T view, @Nullable String value); +} +", +} +`; + exports[`GeneratePropsJavaInterface can generate fixture STRING_PROP 1`] = ` Map { "StringPropComponentManagerInterface.java" => "/** diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeCpp-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeCpp-test.js.snap index f0de514d502..25e8b547586 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeCpp-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeCpp-test.js.snap @@ -161,29 +161,6 @@ extern const char DoublePropNativeComponentComponentName[] = \\"DoublePropNative } `; -exports[`GenerateShadowNodeCpp can generate fixture ENUM_PROP 1`] = ` -Map { - "ShadowNodes.cpp" => " -/** - * 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. - */ - -#include - -namespace facebook { -namespace react { - -extern const char EnumPropsNativeComponentComponentName[] = \\"EnumPropsNativeComponent\\"; - -} // namespace react -} // namespace facebook -", -} -`; - exports[`GenerateShadowNodeCpp can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] = ` Map { "ShadowNodes.cpp" => " @@ -299,6 +276,29 @@ extern const char ImagePropNativeComponentComponentName[] = \\"ImagePropNativeCo } `; +exports[`GenerateShadowNodeCpp can generate fixture INT32_ENUM_PROP 1`] = ` +Map { + "ShadowNodes.cpp" => " +/** + * 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. + */ + +#include + +namespace facebook { +namespace react { + +extern const char Int32EnumPropsNativeComponentComponentName[] = \\"Int32EnumPropsNativeComponent\\"; + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GenerateShadowNodeCpp can generate fixture INTEGER_PROPS 1`] = ` Map { "ShadowNodes.cpp" => " @@ -437,6 +437,29 @@ extern const char PointPropNativeComponentComponentName[] = \\"PointPropNativeCo } `; +exports[`GenerateShadowNodeCpp can generate fixture STRING_ENUM_PROP 1`] = ` +Map { + "ShadowNodes.cpp" => " +/** + * 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. + */ + +#include + +namespace facebook { +namespace react { + +extern const char StringEnumPropsNativeComponentComponentName[] = \\"StringEnumPropsNativeComponent\\"; + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GenerateShadowNodeCpp can generate fixture STRING_PROP 1`] = ` Map { "ShadowNodes.cpp" => " diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeH-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeH-test.js.snap index fdac1991683..de169b07b3d 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeH-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateShadowNodeH-test.js.snap @@ -231,39 +231,6 @@ using DoublePropNativeComponentShadowNode = ConcreteViewShadowNode< } `; -exports[`GenerateShadowNodeH can generate fixture ENUM_PROP 1`] = ` -Map { - "ShadowNodes.h" => " -/** - * 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. - */ - -#pragma once - -#include -#include - -namespace facebook { -namespace react { - -extern const char EnumPropsNativeComponentComponentName[]; - -/* - * \`ShadowNode\` for component. - */ -using EnumPropsNativeComponentShadowNode = ConcreteViewShadowNode< - EnumPropsNativeComponentComponentName, - EnumPropsNativeComponentProps>; - -} // namespace react -} // namespace facebook -", -} -`; - exports[`GenerateShadowNodeH can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] = ` Map { "ShadowNodes.h" => " @@ -426,6 +393,39 @@ using ImagePropNativeComponentShadowNode = ConcreteViewShadowNode< } `; +exports[`GenerateShadowNodeH can generate fixture INT32_ENUM_PROP 1`] = ` +Map { + "ShadowNodes.h" => " +/** + * 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. + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +extern const char Int32EnumPropsNativeComponentComponentName[]; + +/* + * \`ShadowNode\` for component. + */ +using Int32EnumPropsNativeComponentShadowNode = ConcreteViewShadowNode< + Int32EnumPropsNativeComponentComponentName, + Int32EnumPropsNativeComponentProps>; + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GenerateShadowNodeH can generate fixture INTEGER_PROPS 1`] = ` Map { "ShadowNodes.h" => " @@ -617,6 +617,39 @@ using PointPropNativeComponentShadowNode = ConcreteViewShadowNode< } `; +exports[`GenerateShadowNodeH can generate fixture STRING_ENUM_PROP 1`] = ` +Map { + "ShadowNodes.h" => " +/** + * 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. + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +extern const char StringEnumPropsNativeComponentComponentName[]; + +/* + * \`ShadowNode\` for component. + */ +using StringEnumPropsNativeComponentShadowNode = ConcreteViewShadowNode< + StringEnumPropsNativeComponentComponentName, + StringEnumPropsNativeComponentProps>; + +} // namespace react +} // namespace facebook +", +} +`; + exports[`GenerateShadowNodeH can generate fixture STRING_PROP 1`] = ` Map { "ShadowNodes.h" => " diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap index 8ad7f402c12..4ba7c8cdd5e 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateTests-test.js.snap @@ -224,61 +224,6 @@ TEST(DoublePropNativeComponentProps_DoesNotDie, etc) { } `; -exports[`GenerateTests can generate fixture ENUM_PROP 1`] = ` -Map { - "Tests.cpp" => "/** - * 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. - */ - -#include -#include -#include -#include -#include - -using namespace facebook::react; - -TEST(EnumPropsNativeComponentProps_DoesNotDie, etc) { - auto propParser = RawPropsParser(); - propParser.prepare(); - auto const &sourceProps = EnumPropsNativeComponentProps(); - auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); - rawProps.parse(propParser); - EnumPropsNativeComponentProps(sourceProps, rawProps); -} - -TEST(EnumPropsNativeComponentProps_alignment_Top, etc) { - auto propParser = RawPropsParser(); - propParser.prepare(); - auto const &sourceProps = EnumPropsNativeComponentProps(); - auto const &rawProps = RawProps(folly::dynamic::object(\\"alignment\\", \\"top\\")); - rawProps.parse(propParser); - EnumPropsNativeComponentProps(sourceProps, rawProps); -} - -TEST(EnumPropsNativeComponentProps_alignment_Center, etc) { - auto propParser = RawPropsParser(); - propParser.prepare(); - auto const &sourceProps = EnumPropsNativeComponentProps(); - auto const &rawProps = RawProps(folly::dynamic::object(\\"alignment\\", \\"center\\")); - rawProps.parse(propParser); - EnumPropsNativeComponentProps(sourceProps, rawProps); -} - -TEST(EnumPropsNativeComponentProps_alignment_BottomRight, etc) { - auto propParser = RawPropsParser(); - propParser.prepare(); - auto const &sourceProps = EnumPropsNativeComponentProps(); - auto const &rawProps = RawProps(folly::dynamic::object(\\"alignment\\", \\"bottom-right\\")); - rawProps.parse(propParser); - EnumPropsNativeComponentProps(sourceProps, rawProps); -}", -} -`; - exports[`GenerateTests can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] = ` Map { "Tests.cpp" => "/** @@ -501,6 +446,34 @@ TEST(ImagePropNativeComponentProps_thumbImage, etc) { } `; +exports[`GenerateTests can generate fixture INT32_ENUM_PROP 1`] = ` +Map { + "Tests.cpp" => "/** + * 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. + */ + +#include +#include +#include +#include +#include + +using namespace facebook::react; + +TEST(Int32EnumPropsNativeComponentProps_DoesNotDie, etc) { + auto propParser = RawPropsParser(); + propParser.prepare(); + auto const &sourceProps = Int32EnumPropsNativeComponentProps(); + auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); + rawProps.parse(propParser); + Int32EnumPropsNativeComponentProps(sourceProps, rawProps); +}", +} +`; + exports[`GenerateTests can generate fixture INTEGER_PROPS 1`] = ` Map { "Tests.cpp" => "/** @@ -725,6 +698,61 @@ TEST(PointPropNativeComponentProps_startPoint, etc) { } `; +exports[`GenerateTests can generate fixture STRING_ENUM_PROP 1`] = ` +Map { + "Tests.cpp" => "/** + * 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. + */ + +#include +#include +#include +#include +#include + +using namespace facebook::react; + +TEST(StringEnumPropsNativeComponentProps_DoesNotDie, etc) { + auto propParser = RawPropsParser(); + propParser.prepare(); + auto const &sourceProps = StringEnumPropsNativeComponentProps(); + auto const &rawProps = RawProps(folly::dynamic::object(\\"xx_invalid_xx\\", \\"xx_invalid_xx\\")); + rawProps.parse(propParser); + StringEnumPropsNativeComponentProps(sourceProps, rawProps); +} + +TEST(StringEnumPropsNativeComponentProps_alignment_Top, etc) { + auto propParser = RawPropsParser(); + propParser.prepare(); + auto const &sourceProps = StringEnumPropsNativeComponentProps(); + auto const &rawProps = RawProps(folly::dynamic::object(\\"alignment\\", \\"top\\")); + rawProps.parse(propParser); + StringEnumPropsNativeComponentProps(sourceProps, rawProps); +} + +TEST(StringEnumPropsNativeComponentProps_alignment_Center, etc) { + auto propParser = RawPropsParser(); + propParser.prepare(); + auto const &sourceProps = StringEnumPropsNativeComponentProps(); + auto const &rawProps = RawProps(folly::dynamic::object(\\"alignment\\", \\"center\\")); + rawProps.parse(propParser); + StringEnumPropsNativeComponentProps(sourceProps, rawProps); +} + +TEST(StringEnumPropsNativeComponentProps_alignment_BottomRight, etc) { + auto propParser = RawPropsParser(); + propParser.prepare(); + auto const &sourceProps = StringEnumPropsNativeComponentProps(); + auto const &rawProps = RawProps(folly::dynamic::object(\\"alignment\\", \\"bottom-right\\")); + rawProps.parse(propParser); + StringEnumPropsNativeComponentProps(sourceProps, rawProps); +}", +} +`; + exports[`GenerateTests can generate fixture STRING_PROP 1`] = ` Map { "Tests.cpp" => "/** diff --git a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap index cd999e23f4f..594c5772b12 100644 --- a/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap +++ b/packages/react-native-codegen/src/generators/components/__tests__/__snapshots__/GenerateViewConfigJs-test.js.snap @@ -274,41 +274,6 @@ export default nativeComponentName; } `; -exports[`GenerateViewConfigJs can generate fixture ENUM_PROP 1`] = ` -Map { - "ENUM_PROPNativeViewConfig.js" => " -/** - * 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. - * - * @flow - */ - -'use strict'; - -const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); - -const EnumPropsNativeComponentViewConfig = { - uiViewClassName: 'EnumPropsNativeComponent', - - validAttributes: { - alignment: true, - }, -}; - -let nativeComponentName = 'EnumPropsNativeComponent'; - -registerGeneratedViewConfig(nativeComponentName, EnumPropsNativeComponentViewConfig); - -export const __INTERNAL_VIEW_CONFIG = EnumPropsNativeComponentViewConfig; - -export default nativeComponentName; -", -} -`; - exports[`GenerateViewConfigJs can generate fixture EVENT_NESTED_OBJECT_PROPS 1`] = ` Map { "EVENT_NESTED_OBJECT_PROPSNativeViewConfig.js" => " @@ -556,6 +521,41 @@ export default nativeComponentName; } `; +exports[`GenerateViewConfigJs can generate fixture INT32_ENUM_PROP 1`] = ` +Map { + "INT32_ENUM_PROPNativeViewConfig.js" => " +/** + * 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. + * + * @flow + */ + +'use strict'; + +const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); + +const Int32EnumPropsNativeComponentViewConfig = { + uiViewClassName: 'Int32EnumPropsNativeComponent', + + validAttributes: { + maxInterval: true, + }, +}; + +let nativeComponentName = 'Int32EnumPropsNativeComponent'; + +registerGeneratedViewConfig(nativeComponentName, Int32EnumPropsNativeComponentViewConfig); + +export const __INTERNAL_VIEW_CONFIG = Int32EnumPropsNativeComponentViewConfig; + +export default nativeComponentName; +", +} +`; + exports[`GenerateViewConfigJs can generate fixture INTEGER_PROPS 1`] = ` Map { "INTEGER_PROPSNativeViewConfig.js" => " @@ -778,6 +778,41 @@ export default nativeComponentName; } `; +exports[`GenerateViewConfigJs can generate fixture STRING_ENUM_PROP 1`] = ` +Map { + "STRING_ENUM_PROPNativeViewConfig.js" => " +/** + * 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. + * + * @flow + */ + +'use strict'; + +const registerGeneratedViewConfig = require('registerGeneratedViewConfig'); + +const StringEnumPropsNativeComponentViewConfig = { + uiViewClassName: 'StringEnumPropsNativeComponent', + + validAttributes: { + alignment: true, + }, +}; + +let nativeComponentName = 'StringEnumPropsNativeComponent'; + +registerGeneratedViewConfig(nativeComponentName, StringEnumPropsNativeComponentViewConfig); + +export const __INTERNAL_VIEW_CONFIG = StringEnumPropsNativeComponentViewConfig; + +export default nativeComponentName; +", +} +`; + exports[`GenerateViewConfigJs can generate fixture STRING_PROP 1`] = ` Map { "STRING_PROPNativeViewConfig.js" => "