diff --git a/packages/rn-tester/IntegrationTests/PropertiesUpdateTest.js b/packages/rn-tester/IntegrationTests/PropertiesUpdateTest.js deleted file mode 100644 index 5c1355ac051..00000000000 --- a/packages/rn-tester/IntegrationTests/PropertiesUpdateTest.js +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - */ - -'use strict'; - -const React = require('react'); -const ReactNative = require('react-native'); -const {View} = ReactNative; - -const {TestModule} = ReactNative.NativeModules; - -class PropertiesUpdateTest extends React.Component { - render() { - if (this.props.markTestPassed) { - TestModule.markTestPassed(true); - } - return ; - } -} - -PropertiesUpdateTest.displayName = 'PropertiesUpdateTest'; - -module.exports = PropertiesUpdateTest; diff --git a/packages/rn-tester/IntegrationTests/RCTRootViewIntegrationTestApp.js b/packages/rn-tester/IntegrationTests/RCTRootViewIntegrationTestApp.js deleted file mode 100644 index 5fd9e57d932..00000000000 --- a/packages/rn-tester/IntegrationTests/RCTRootViewIntegrationTestApp.js +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - */ - -'use strict'; - -const React = require('react'); -const ReactNative = require('react-native'); - -const {AppRegistry, ScrollView, StyleSheet, Text, TouchableOpacity, View} = - ReactNative; - -/* Keep this list in sync with RCTRootViewIntegrationTests.m */ -const TESTS = [ - require('./PropertiesUpdateTest'), - require('./ReactContentSizeUpdateTest'), - require('./SizeFlexibilityUpdateTest'), -]; - -TESTS.forEach(test => - AppRegistry.registerComponent(test.displayName, () => test), -); - -class RCTRootViewIntegrationTestApp extends React.Component { - state = { - test: null, - }; - - render() { - if (this.state.test) { - return ( - - - - ); - } - return ( - - - Click on a test to run it in this shell for easier debugging and - development. Run all tests in the testing environment with cmd+U in - Xcode. - - - - {TESTS.map(test => [ - this.setState({test})} - style={styles.row}> - {test.displayName} - , - , - ])} - - - ); - } -} - -const styles = StyleSheet.create({ - container: { - backgroundColor: 'white', - marginTop: 40, - margin: 15, - }, - row: { - padding: 10, - }, - testName: { - fontWeight: '500', - }, - separator: { - height: 1, - backgroundColor: '#bbbbbb', - }, -}); - -AppRegistry.registerComponent( - 'RCTRootViewIntegrationTestApp', - () => RCTRootViewIntegrationTestApp, -); diff --git a/packages/rn-tester/IntegrationTests/ReactContentSizeUpdateTest.js b/packages/rn-tester/IntegrationTests/ReactContentSizeUpdateTest.js deleted file mode 100644 index ea00f975c37..00000000000 --- a/packages/rn-tester/IntegrationTests/ReactContentSizeUpdateTest.js +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and 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 strict-local - */ - -const RCTNativeAppEventEmitter = require('react-native/Libraries/EventEmitter/RCTNativeAppEventEmitter'); -const React = require('react'); -const ReactNative = require('react-native'); - -const {View} = ReactNative; - -const {TestModule} = ReactNative.NativeModules; -import {type EventSubscription} from 'react-native/Libraries/vendor/emitter/EventEmitter'; - -const reactViewWidth = 101; -const reactViewHeight = 102; -const newReactViewWidth = 201; -const newReactViewHeight = 202; - -type Props = {||}; - -type State = {| - height: number, - width: number, -|}; - -class ReactContentSizeUpdateTest extends React.Component { - _timeoutID: ?TimeoutID = null; - _subscription: ?EventSubscription = null; - - state: State = { - height: reactViewHeight, - width: reactViewWidth, - }; - - UNSAFE_componentWillMount() { - this._subscription = RCTNativeAppEventEmitter.addListener( - 'rootViewDidChangeIntrinsicSize', - this.rootViewDidChangeIntrinsicSize, - ); - } - - componentDidMount() { - this._timeoutID = setTimeout(() => { - this.updateViewSize(); - }, 1000); - } - - componentWillUnmount() { - if (this._timeoutID != null) { - clearTimeout(this._timeoutID); - } - - if (this._subscription != null) { - this._subscription.remove(); - } - } - - updateViewSize() { - this.setState({ - height: newReactViewHeight, - width: newReactViewWidth, - }); - } - - rootViewDidChangeIntrinsicSize: (intrinsicSize: State) => void = ( - intrinsicSize: State, - ) => { - if ( - intrinsicSize.height === newReactViewHeight && - intrinsicSize.width === newReactViewWidth - ) { - TestModule.markTestPassed(true); - } - }; - - render(): React.Node { - return ( - - ); - } -} - -module.exports = ReactContentSizeUpdateTest; diff --git a/packages/rn-tester/IntegrationTests/SizeFlexibilityUpdateTest.js b/packages/rn-tester/IntegrationTests/SizeFlexibilityUpdateTest.js deleted file mode 100644 index 79635eaffe5..00000000000 --- a/packages/rn-tester/IntegrationTests/SizeFlexibilityUpdateTest.js +++ /dev/null @@ -1,106 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and 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 strict-local - */ - -const RCTNativeAppEventEmitter = require('react-native/Libraries/EventEmitter/RCTNativeAppEventEmitter'); -const React = require('react'); -const ReactNative = require('react-native'); -const {View} = ReactNative; - -const {TestModule} = ReactNative.NativeModules; -import {type EventSubscription} from 'react-native/Libraries/vendor/emitter/EventEmitter'; - -const reactViewWidth = 111; -const reactViewHeight = 222; - -let finalState = false; - -type Props = $ReadOnly<{| - width: boolean, - height: boolean, - both: boolean, - none: boolean, -|}>; - -class SizeFlexibilityUpdateTest extends React.Component { - _subscription: ?EventSubscription = null; - - UNSAFE_componentWillMount() { - this._subscription = RCTNativeAppEventEmitter.addListener( - 'rootViewDidChangeIntrinsicSize', - this.rootViewDidChangeIntrinsicSize, - ); - } - - componentWillUnmount() { - if (this._subscription != null) { - this._subscription.remove(); - } - } - - markPassed: () => void = () => { - TestModule.markTestPassed(true); - finalState = true; - }; - - rootViewDidChangeIntrinsicSize: (intrinsicSize: { - height: number, - width: number, - ... - }) => void = (intrinsicSize: {width: number, height: number, ...}) => { - if (finalState) { - // If a test reaches its final state, it is not expected to do anything more - TestModule.markTestPassed(false); - return; - } - - if (this.props.both) { - if ( - intrinsicSize.width === reactViewWidth && - intrinsicSize.height === reactViewHeight - ) { - this.markPassed(); - return; - } - } - if (this.props.height) { - if ( - intrinsicSize.width !== reactViewWidth && - intrinsicSize.height === reactViewHeight - ) { - this.markPassed(); - return; - } - } - if (this.props.width) { - if ( - intrinsicSize.width === reactViewWidth && - intrinsicSize.height !== reactViewHeight - ) { - this.markPassed(); - return; - } - } - if (this.props.none) { - if ( - intrinsicSize.width !== reactViewWidth && - intrinsicSize.height !== reactViewHeight - ) { - this.markPassed(); - return; - } - } - }; - - render(): React.Node { - return ; - } -} - -module.exports = SizeFlexibilityUpdateTest; diff --git a/packages/rn-tester/RNTesterIntegrationTests/RCTRootViewIntegrationTests.m b/packages/rn-tester/RNTesterIntegrationTests/RCTRootViewIntegrationTests.m deleted file mode 100644 index 5ebcc0adc2c..00000000000 --- a/packages/rn-tester/RNTesterIntegrationTests/RCTRootViewIntegrationTests.m +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) Meta Platforms, Inc. and 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 -#import -#import -#import - -#define RCT_TEST_DATA_CONFIGURATION_BLOCK(appName, testType, input, block) \ - -(void)DISABLED_test##appName##_##testType##_##input \ - { \ - [_runner runTest:_cmd module:@ #appName initialProps:@{@ #input : @YES} configurationBlock:block]; \ - } - -#define RCT_TEST_CONFIGURATION_BLOCK(appName, block) \ - -(void)DISABLED_test##appName \ - { \ - [_runner runTest:_cmd module:@ #appName initialProps:nil configurationBlock:block]; \ - } - -#define RCTNone RCTRootViewSizeFlexibilityNone -#define RCTHeight RCTRootViewSizeFlexibilityHeight -#define RCTWidth RCTRootViewSizeFlexibilityWidth -#define RCTBoth RCTRootViewSizeFlexibilityWidthAndHeight - -typedef void (^ControlBlock)(RCTRootView *); - -@interface SizeFlexibilityTestDelegate : NSObject -@end - -@implementation SizeFlexibilityTestDelegate - -- (void)rootViewDidChangeIntrinsicSize:(RCTRootView *)rootView -{ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - - [rootView.eventDispatcher - sendAppEventWithName:@"rootViewDidChangeIntrinsicSize" - body:@{@"width" : @(rootView.intrinsicSize.width), @"height" : @(rootView.intrinsicSize.height)}]; -#pragma clang diagnostic pop -} - -@end - -static SizeFlexibilityTestDelegate *sizeFlexibilityDelegate(void) -{ - static SizeFlexibilityTestDelegate *delegate; - if (delegate == nil) { - delegate = [SizeFlexibilityTestDelegate new]; - } - - return delegate; -} - -static ControlBlock simpleSizeFlexibilityBlock(RCTRootViewSizeFlexibility sizeFlexibility) -{ - return ^(RCTRootView *rootView) { - rootView.delegate = sizeFlexibilityDelegate(); - rootView.sizeFlexibility = sizeFlexibility; - }; -} - -static ControlBlock multipleSizeFlexibilityUpdatesBlock(RCTRootViewSizeFlexibility finalSizeFlexibility) -{ - return ^(RCTRootView *rootView) { - NSInteger arr[4] = {RCTNone, RCTHeight, RCTWidth, RCTBoth}; - - rootView.delegate = sizeFlexibilityDelegate(); - - for (int i = 0; i < 4; ++i) { - if (arr[i] != finalSizeFlexibility) { - rootView.sizeFlexibility = arr[i]; - } - } - - rootView.sizeFlexibility = finalSizeFlexibility; - }; -} - -static ControlBlock reactContentSizeUpdateBlock(RCTRootViewSizeFlexibility sizeFlexibility) -{ - return ^(RCTRootView *rootView) { - rootView.delegate = sizeFlexibilityDelegate(); - rootView.sizeFlexibility = sizeFlexibility; - }; -} - -@interface RCTRootViewIntegrationTests : XCTestCase - -@end - -@implementation RCTRootViewIntegrationTests { - RCTTestRunner *_runner; -} - -- (void)setUp -{ - _runner = RCTInitRunnerForApp(@"IntegrationTests/RCTRootViewIntegrationTestApp", nil, nil); -} - -#pragma mark Logic Tests - -// This list should be kept in sync with RCTRootViewIntegrationTestsApp.js - -// Simple size flexibility tests - test if the content is measured properly -RCT_TEST_DATA_CONFIGURATION_BLOCK(SizeFlexibilityUpdateTest, SingleUpdate, none, simpleSizeFlexibilityBlock(RCTNone)); -RCT_TEST_DATA_CONFIGURATION_BLOCK( - SizeFlexibilityUpdateTest, - SingleUpdate, - height, - simpleSizeFlexibilityBlock(RCTHeight)); -RCT_TEST_DATA_CONFIGURATION_BLOCK(SizeFlexibilityUpdateTest, SingleUpdate, width, simpleSizeFlexibilityBlock(RCTWidth)); -RCT_TEST_DATA_CONFIGURATION_BLOCK(SizeFlexibilityUpdateTest, SingleUpdate, both, simpleSizeFlexibilityBlock(RCTBoth)); - -// Consider multiple size flexibility updates in a row. Test if the view's flexibility mode eventually is set to the -// expected value -RCT_TEST_DATA_CONFIGURATION_BLOCK( - SizeFlexibilityUpdateTest, - MultipleUpdates, - none, - multipleSizeFlexibilityUpdatesBlock(RCTNone)); -RCT_TEST_DATA_CONFIGURATION_BLOCK( - SizeFlexibilityUpdateTest, - MultipleUpdates, - height, - multipleSizeFlexibilityUpdatesBlock(RCTHeight)); -RCT_TEST_DATA_CONFIGURATION_BLOCK( - SizeFlexibilityUpdateTest, - MultipleUpdates, - width, - multipleSizeFlexibilityUpdatesBlock(RCTWidth)); -RCT_TEST_DATA_CONFIGURATION_BLOCK( - SizeFlexibilityUpdateTest, - MultipleUpdates, - both, - multipleSizeFlexibilityUpdatesBlock(RCTBoth)); - -// Test if the 'rootViewDidChangeIntrinsicSize' delegate method is called after the RN app decides internally to resize -RCT_TEST_CONFIGURATION_BLOCK(ReactContentSizeUpdateTest, reactContentSizeUpdateBlock(RCTBoth)) - -// Test if setting 'appProperties' property updates the RN app -RCT_TEST_CONFIGURATION_BLOCK(PropertiesUpdateTest, ^(RCTRootView *rootView) { - rootView.appProperties = @{@"markTestPassed" : @YES}; -}) - -@end diff --git a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj index 519976e9ee1..cdb5346aa50 100644 --- a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj +++ b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj @@ -56,7 +56,6 @@ E7DB216322B2F3EC005AC45F /* RCTLoggingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E7DB215E22B2F3EC005AC45F /* RCTLoggingTests.m */; }; E7DB216422B2F3EC005AC45F /* RCTUIManagerScenarioTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E7DB215F22B2F3EC005AC45F /* RCTUIManagerScenarioTests.m */; }; E7DB216522B2F3EC005AC45F /* RNTesterSnapshotTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E7DB216022B2F3EC005AC45F /* RNTesterSnapshotTests.m */; }; - E7DB216622B2F3EC005AC45F /* RCTRootViewIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E7DB216122B2F3EC005AC45F /* RCTRootViewIntegrationTests.m */; }; E7DB216722B2F69F005AC45F /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E7DB213022B2C649005AC45F /* JavaScriptCore.framework */; }; E7DB218C22B41FCD005AC45F /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E7DB218B22B41FCD005AC45F /* XCTest.framework */; }; /* End PBXBuildFile section */ @@ -176,7 +175,6 @@ E7DB215E22B2F3EC005AC45F /* RCTLoggingTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTLoggingTests.m; sourceTree = ""; }; E7DB215F22B2F3EC005AC45F /* RCTUIManagerScenarioTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTUIManagerScenarioTests.m; sourceTree = ""; }; E7DB216022B2F3EC005AC45F /* RNTesterSnapshotTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNTesterSnapshotTests.m; sourceTree = ""; }; - E7DB216122B2F3EC005AC45F /* RCTRootViewIntegrationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTRootViewIntegrationTests.m; sourceTree = ""; }; E7DB218B22B41FCD005AC45F /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = XCTest.framework; sourceTree = DEVELOPER_DIR; }; /* End PBXFileReference section */ @@ -391,7 +389,6 @@ children = ( E7C1241922BEC44B00DA25C0 /* RNTesterIntegrationTests.m */, E7DB215E22B2F3EC005AC45F /* RCTLoggingTests.m */, - E7DB216122B2F3EC005AC45F /* RCTRootViewIntegrationTests.m */, E7DB215F22B2F3EC005AC45F /* RCTUIManagerScenarioTests.m */, E7DB216022B2F3EC005AC45F /* RNTesterSnapshotTests.m */, E7DB215D22B2F3EC005AC45F /* RNTesterTestModule.m */, @@ -798,7 +795,6 @@ E7DB216222B2F3EC005AC45F /* RNTesterTestModule.m in Sources */, E7C1241A22BEC44B00DA25C0 /* RNTesterIntegrationTests.m in Sources */, E7DB216322B2F3EC005AC45F /* RCTLoggingTests.m in Sources */, - E7DB216622B2F3EC005AC45F /* RCTRootViewIntegrationTests.m in Sources */, E7DB216422B2F3EC005AC45F /* RCTUIManagerScenarioTests.m in Sources */, E7DB216522B2F3EC005AC45F /* RNTesterSnapshotTests.m in Sources */, );