From a17464769852cfaec0be7aace9869c544f9d36d7 Mon Sep 17 00:00:00 2001 From: Eli White Date: Mon, 29 Jul 2019 14:35:08 -0700 Subject: [PATCH] Change fixture Summary: I want a fixture with all the types, so refactoring this so future diffs in the stack are cleaner Reviewed By: JoshuaGross Differential Revision: D16509803 fbshipit-source-id: 1f4873701a8ff842f50976377003e1abff187278 --- .../components/__test_fixtures__/fixtures.js | 23 +----------- .../GenerateComponentHObjCpp-test.js.snap | 35 ++----------------- .../GeneratePropsJavaDelegate-test.js.snap | 7 ++-- .../GeneratePropsJavaInterface-test.js.snap | 3 +- .../GenerateViewConfigJs-test.js.snap | 14 ++------ 5 files changed, 10 insertions(+), 72 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 e1d36d9ecbaf88..84a9ffaf28984a 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 @@ -930,7 +930,7 @@ const COMMANDS: SchemaType = { }, }, { - name: 'hotspotUpdate', + name: 'allTypes', optional: false, typeAnnotation: { type: 'FunctionTypeAnnotation', @@ -941,27 +941,6 @@ const COMMANDS: SchemaType = { type: 'Int32TypeAnnotation', }, }, - { - name: 'y', - typeAnnotation: { - type: 'Int32TypeAnnotation', - }, - }, - ], - }, - }, - { - name: 'scrollTo', - optional: false, - typeAnnotation: { - type: 'FunctionTypeAnnotation', - params: [ - { - name: 'y', - typeAnnotation: { - type: 'Int32TypeAnnotation', - }, - }, { name: 'animated', typeAnnotation: { 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 7732177b6aa33e..03707d2a32d5d3 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 @@ -86,8 +86,7 @@ NS_ASSUME_NONNULL_BEGIN @protocol CommandNativeComponentViewProtocol - (void)flashScrollIndicators; -- (void)hotspotUpdate:(NSInteger)x y:(NSInteger)y; -- (void)scrollTo:(NSInteger)y animated:(BOOL)animated; +- (void)allTypes:(NSInteger)x animated:(BOOL)animated; @end RCT_EXTERN inline void CommandNativeComponentHandleCommand( @@ -109,7 +108,7 @@ RCT_EXTERN inline void CommandNativeComponentHandleCommand( return; } -if ([commandName isEqualToString:@\\"hotspotUpdate\\"]) { +if ([commandName isEqualToString:@\\"allTypes\\"]) { #if RCT_DEBUG if ([args count] != 2) { RCTLogError(@\\"%@ command %@ received %d arguments, expected %d.\\", @\\"CommandNativeComponent\\", commandName, (int)[args count], 2); @@ -125,34 +124,6 @@ if ([commandName isEqualToString:@\\"hotspotUpdate\\"]) { #endif NSInteger x = [(NSNumber *)arg0 intValue]; -#if RCT_DEBUG - NSObject *arg1 = args[1]; - if (!RCTValidateTypeOfViewCommandArgument(arg1, [NSNumber class], @\\"number\\", @\\"CommandNativeComponent\\", commandName, @\\"2nd\\")) { - return; - } -#endif - NSInteger y = [(NSNumber *)arg1 intValue]; - - [componentView hotspotUpdate:x y:y] - return; -} - -if ([commandName isEqualToString:@\\"scrollTo\\"]) { -#if RCT_DEBUG - if ([args count] != 2) { - RCTLogError(@\\"%@ command %@ received %d arguments, expected %d.\\", @\\"CommandNativeComponent\\", commandName, (int)[args count], 2); - return; - } -#endif - -#if RCT_DEBUG - NSObject *arg0 = args[0]; - if (!RCTValidateTypeOfViewCommandArgument(arg0, [NSNumber class], @\\"number\\", @\\"CommandNativeComponent\\", commandName, @\\"1st\\")) { - return; - } -#endif - NSInteger y = [(NSNumber *)arg0 intValue]; - #if RCT_DEBUG NSObject *arg1 = args[1]; if (!RCTValidateTypeOfViewCommandArgument(arg1, [NSNumber class], @\\"boolean\\", @\\"CommandNativeComponent\\", commandName, @\\"2nd\\")) { @@ -161,7 +132,7 @@ if ([commandName isEqualToString:@\\"scrollTo\\"]) { #endif BOOL animated = [(NSNumber *)arg1 boolValue]; - [componentView scrollTo:y animated:animated] + [componentView allTypes:x animated:animated] return; } 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 7298736e263185..13d5a9bd046be8 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 @@ -99,11 +99,8 @@ public class CommandNativeComponentViewManagerDelegate { case \\"flashScrollIndicators\\": viewManager.flashScrollIndicators(view); break; - case \\"hotspotUpdate\\": - viewManager.hotspotUpdate(view, args.getInt(0), args.getInt(1)); - break; - case \\"scrollTo\\": - viewManager.scrollTo(view, args.getInt(0), args.getBoolean(1)); + case \\"allTypes\\": + viewManager.allTypes(view, args.getInt(0), args.getBoolean(1)); break; } } 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 c61813c93964bc..cc7b4feca83f45 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 @@ -62,8 +62,7 @@ import android.view.View; public interface CommandNativeComponentViewManagerInterface { // No props void flashScrollIndicators(T view); - void hotspotUpdate(T view, int x, int y); - void scrollTo(T view, int y, boolean animated); + void allTypes(T view, int x, boolean animated); } ", } 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 11d15d3c5714ac..b4897e9f697b8d 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 @@ -152,19 +152,11 @@ export const Commands = { ); }, - hotspotUpdate(ref, x, y) { - UIManager.dispatchViewCommand( - findNodeHandle(ref), - UIManager.getViewManagerConfig(\\"CommandNativeComponent\\").Commands.hotspotUpdate, - [x, y] - ); - }, - - scrollTo(ref, y, animated) { + allTypes(ref, x, animated) { UIManager.dispatchViewCommand( findNodeHandle(ref), - UIManager.getViewManagerConfig(\\"CommandNativeComponent\\").Commands.scrollTo, - [y, animated] + UIManager.getViewManagerConfig(\\"CommandNativeComponent\\").Commands.allTypes, + [x, animated] ); } };