diff --git a/RNTester/Podfile b/RNTester/Podfile index a23083429b06b6..fcbd009cb4f56f 100644 --- a/RNTester/Podfile +++ b/RNTester/Podfile @@ -30,12 +30,12 @@ end target 'RNTesterUnitTests' do pods() - pod 'React-RCTTest', :path => "RCTTest" + pod 'React-RCTTest', :path => "./RCTTest" end target 'RNTesterIntegrationTests' do pods() - pod 'React-RCTTest', :path => "RCTTest" + pod 'React-RCTTest', :path => "./RCTTest" end post_install do |installer| diff --git a/RNTester/Podfile.lock b/RNTester/Podfile.lock index d29ee5e523365e..8dc339b91aa27c 100644 --- a/RNTester/Podfile.lock +++ b/RNTester/Podfile.lock @@ -245,8 +245,11 @@ PODS: - React-Core/RCTSettingsHeaders (= 1000.0.0) - ReactCommon/turbomodule/core (= 1000.0.0) - React-RCTTest (1000.0.0): + - Folly (= 2020.01.13.00) - React-Core (= 1000.0.0) - React-CoreModules (= 1000.0.0) + - React-jsi (= 1000.0.0) + - ReactCommon/turbomodule/core (= 1000.0.0) - React-RCTText (1000.0.0): - React-Core/RCTTextHeaders (= 1000.0.0) - React-RCTVibration (1000.0.0): @@ -304,7 +307,7 @@ DEPENDENCIES: - React-RCTNetwork (from `../Libraries/Network`) - React-RCTPushNotification (from `../Libraries/PushNotificationIOS`) - React-RCTSettings (from `../Libraries/Settings`) - - React-RCTTest (from `RCTTest`) + - React-RCTTest (from `./RCTTest`) - React-RCTText (from `../Libraries/Text`) - React-RCTVibration (from `../Libraries/Vibration`) - ReactCommon/callinvoker (from `../ReactCommon`) @@ -364,7 +367,7 @@ EXTERNAL SOURCES: React-RCTSettings: :path: "../Libraries/Settings" React-RCTTest: - :path: RCTTest + :path: "./RCTTest" React-RCTText: :path: "../Libraries/Text" React-RCTVibration: @@ -399,12 +402,12 @@ SPEC CHECKSUMS: React-RCTNetwork: d16dd52792dc3d66c3e23b464afe0f759d3a5670 React-RCTPushNotification: 9290035bbd9ecef15f03d760cc422a219b55be07 React-RCTSettings: f7daf792f772c8582b31c7aeeb1f146df61a52a7 - React-RCTTest: 80b44b7e8f5a30d9663c921adfb22a0b185e69f4 + React-RCTTest: e10acfa457347879d3723bc85f1d2754414b9d2c React-RCTText: b3eb3514addd9b105c0edb05ed32333428ba2a52 React-RCTVibration: e2856bb9408f7e8eccfe870e123e5644ab744219 ReactCommon: c3834cbee58b60f71c8155c04a3f44e60ec017fb Yoga: f7fa200d8c49f97b54c9421079e781fb900b5cae -PODFILE CHECKSUM: fa397603c9a8f7cb49d7edc7fe85536d0789f34f +PODFILE CHECKSUM: 31cb1ffc6e72e1bbb948da2fb648d4f7aca92168 COCOAPODS: 1.8.4 diff --git a/RNTester/RCTTest/RCTTestModule.m b/RNTester/RCTTest/RCTTestModule.mm similarity index 50% rename from RNTester/RCTTest/RCTTestModule.m rename to RNTester/RCTTest/RCTTestModule.mm index 0b43a53422b208..081a64ea95108b 100644 --- a/RNTester/RCTTest/RCTTestModule.m +++ b/RNTester/RCTTest/RCTTestModule.mm @@ -11,9 +11,69 @@ #import #import #import +#import #import "FBSnapshotTestController.h" +#import "RCTTestPlugins.h" + +@protocol NativeTestModuleSpec + +- (void)markTestCompleted; +- (void)markTestPassed:(BOOL)success; +- (void)verifySnapshot:(RCTResponseSenderBlock)callback; + +@end + +namespace facebook { + namespace react { + /** + * ObjC++ class for module 'TestModule' + */ + + class JSI_EXPORT NativeTestModuleSpecJSI : public ObjCTurboModule { + public: + NativeTestModuleSpecJSI(id instance, std::shared_ptr jsInvoker); + + }; + } // namespace react +} // namespace facebook + +namespace facebook { + namespace react { + + + static facebook::jsi::Value __hostFunction_NativeTestModuleSpecJSI_markTestCompleted(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { + return static_cast(turboModule).invokeObjCMethod(rt, VoidKind, "markTestCompleted", @selector(markTestCompleted), args, count); + } + + static facebook::jsi::Value __hostFunction_NativeTestModuleSpecJSI_markTestPassed(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { + return static_cast(turboModule).invokeObjCMethod(rt, VoidKind, "markTestPassed", @selector(markTestPassed:), args, count); + } + + static facebook::jsi::Value __hostFunction_NativeTestModuleSpecJSI_verifySnapshot(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { + return static_cast(turboModule).invokeObjCMethod(rt, VoidKind, "verifySnapshot", @selector(verifySnapshot:), args, count); + } + + + NativeTestModuleSpecJSI::NativeTestModuleSpecJSI(id instance, std::shared_ptr jsInvoker) + : ObjCTurboModule("TestModule", instance, jsInvoker) { + + methodMap_["markTestCompleted"] = MethodMetadata {0, __hostFunction_NativeTestModuleSpecJSI_markTestCompleted}; + + + methodMap_["markTestPassed"] = MethodMetadata {1, __hostFunction_NativeTestModuleSpecJSI_markTestPassed}; + + + methodMap_["verifySnapshot"] = MethodMetadata {1, __hostFunction_NativeTestModuleSpecJSI_verifySnapshot}; + } + + } // namespace react +} // namespace facebook + +@interface RCTTestModule() +@end + @implementation RCTTestModule { NSMutableDictionary *_snapshotCounter; } @@ -86,4 +146,13 @@ - (dispatch_queue_t)methodQueue }]; } +- (std::shared_ptr)getTurboModuleWithJsInvoker:(std::shared_ptr)jsInvoker +{ + return std::make_shared(self, jsInvoker); +} + @end + +Class RCTTestModuleCls(void) { + return RCTTestModule.class; +} diff --git a/RNTester/RCTTest/RCTTestPlugins.h b/RNTester/RCTTest/RCTTestPlugins.h new file mode 100644 index 00000000000000..1572f3a603a1a4 --- /dev/null +++ b/RNTester/RCTTest/RCTTestPlugins.h @@ -0,0 +1,40 @@ +/** + * 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 an internal plugin build system + */ + +#ifdef RN_DISABLE_OSS_PLUGIN_HEADER + +// FB Internal: FBRCTTestPlugins.h is autogenerated by the build system. +#import + +#else + +// OSS-compatibility layer + +#import + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wreturn-type-c-linkage" + +#ifdef __cplusplus +extern "C" { +#endif + +// RCTTurboModuleManagerDelegate should call this to resolve module classes. +Class RCTTestClassProvider(const char *name); + +// Lookup functions +Class RCTTestModuleCls(void) __attribute__((used)); + +#ifdef __cplusplus +} +#endif + +#pragma GCC diagnostic pop + +#endif // RN_DISABLE_OSS_PLUGIN_HEADER diff --git a/RNTester/RCTTest/RCTTestPlugins.mm b/RNTester/RCTTest/RCTTestPlugins.mm new file mode 100644 index 00000000000000..a057177b619d66 --- /dev/null +++ b/RNTester/RCTTest/RCTTestPlugins.mm @@ -0,0 +1,32 @@ +/** + * 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 an internal plugin build system + */ + +#ifndef RN_DISABLE_OSS_PLUGIN_HEADER + +// OSS-compatibility layer + +#import "RCTTestPlugins.h" + +#import +#import + +Class RCTTestClassProvider(const char *name) { + static std::unordered_map sCoreModuleClassMap = { + {"TestModule", RCTTestModuleCls}, + }; + + auto p = sCoreModuleClassMap.find(name); + if (p != sCoreModuleClassMap.end()) { + auto classFunc = p->second; + return classFunc(); + } + return nil; +} + +#endif // RN_DISABLE_OSS_PLUGIN_HEADER diff --git a/RNTester/RCTTest/React-RCTTest.podspec b/RNTester/RCTTest/React-RCTTest.podspec index d78745212024c0..a5c47025bc1d07 100644 --- a/RNTester/RCTTest/React-RCTTest.podspec +++ b/RNTester/RCTTest/React-RCTTest.podspec @@ -16,6 +16,9 @@ else source[:tag] = "v#{version}" end +folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' +folly_version = '2020.01.13.00' + Pod::Spec.new do |s| s.name = "React-RCTTest" s.version = version @@ -24,12 +27,21 @@ Pod::Spec.new do |s| s.license = package["license"] s.author = "Facebook, Inc. and its affiliates" s.platforms = { :ios => "10.0", :tvos => "10.0" } + s.compiler_flags = folly_compiler_flags + ' -Wno-nullability-completeness' s.source = source - s.source_files = "**/*.{h,m}" + s.source_files = "**/*.{h,m,mm}" s.preserve_paths = "package.json", "LICENSE", "LICENSE-docs" s.framework = "XCTest" s.header_dir = "RCTTest" + s.pod_target_xcconfig = { + "USE_HEADERMAP" => "YES", + "CLANG_CXX_LANGUAGE_STANDARD" => "c++14", + "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/Folly\"" + } + s.dependency "Folly", folly_version s.dependency "React-Core", version s.dependency "React-CoreModules", version + s.dependency "ReactCommon/turbomodule/core", version + s.dependency "React-jsi", version end diff --git a/RNTester/RNTesterPods.xcodeproj/project.pbxproj b/RNTester/RNTesterPods.xcodeproj/project.pbxproj index 2d85223c54b493..0aec830415d0fa 100644 --- a/RNTester/RNTesterPods.xcodeproj/project.pbxproj +++ b/RNTester/RNTesterPods.xcodeproj/project.pbxproj @@ -13,11 +13,11 @@ 27F441EC1BEBE5030039B79C /* FlexibleSizeExampleView.m in Sources */ = {isa = PBXBuildFile; fileRef = 27F441E81BEBE5030039B79C /* FlexibleSizeExampleView.m */; }; 2DDEF0101F84BF7B00DBDF73 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 2DDEF00F1F84BF7B00DBDF73 /* Images.xcassets */; }; 3D2AFAF51D646CF80089D1A3 /* legacy_image@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 3D2AFAF41D646CF80089D1A3 /* legacy_image@2x.png */; }; - 42C7FD8921D436BBA216216D /* libPods-RNTester.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EA4C77A9826FF02A56911142 /* libPods-RNTester.a */; }; + 57E63A755AEDF197848E52C0 /* libPods-RNTesterIntegrationTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 076801A3AA34E645F870C076 /* libPods-RNTesterIntegrationTests.a */; }; 5C60EB1C226440DB0018C04F /* AppDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C60EB1B226440DB0018C04F /* AppDelegate.mm */; }; 5CB07C9B226467E60039471C /* RNTesterTurboModuleProvider.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CB07C99226467E60039471C /* RNTesterTurboModuleProvider.mm */; }; - 69B65AC442B001534251D909 /* libPods-RNTesterIntegrationTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5BBFF3E3792E27C4FBA2CB43 /* libPods-RNTesterIntegrationTests.a */; }; - C23B0809CAE8A115772B092E /* libPods-RNTesterUnitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 42A6C306038665FDDA3E54E2 /* libPods-RNTesterUnitTests.a */; }; + CA98220F79ABB17F6FE10829 /* libPods-RNTester.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4610AEE3F1885AD3F6741BD1 /* libPods-RNTester.a */; }; + E24D92BB73326FCC593E9450 /* libPods-RNTesterUnitTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 060D8FF3BA18357FD288E8C8 /* libPods-RNTesterUnitTests.a */; }; E7C1241A22BEC44B00DA25C0 /* RNTesterIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E7C1241922BEC44B00DA25C0 /* RNTesterIntegrationTests.m */; }; E7DB20D122B2BAA6005AC45F /* RCTBundleURLProviderTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E7DB20A922B2BAA3005AC45F /* RCTBundleURLProviderTests.m */; }; E7DB20D222B2BAA6005AC45F /* RCTModuleInitNotificationRaceTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E7DB20AA22B2BAA3005AC45F /* RCTModuleInitNotificationRaceTests.m */; }; @@ -69,6 +69,8 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 060D8FF3BA18357FD288E8C8 /* libPods-RNTesterUnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNTesterUnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 076801A3AA34E645F870C076 /* libPods-RNTesterIntegrationTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNTesterIntegrationTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 13B07F961A680F5B00A75B9A /* RNTester.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = RNTester.app; sourceTree = BUILT_PRODUCTS_DIR; }; 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = RNTester/AppDelegate.h; sourceTree = ""; }; 13B07FB21A68108700A75B9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; @@ -81,8 +83,7 @@ 2DDEF00F1F84BF7B00DBDF73 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = RNTester/Images.xcassets; sourceTree = ""; }; 34028D6B10F47E490042EB27 /* Pods-RNTesterUnitTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNTesterUnitTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests.debug.xcconfig"; sourceTree = ""; }; 3D2AFAF41D646CF80089D1A3 /* legacy_image@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "legacy_image@2x.png"; path = "RNTester/legacy_image@2x.png"; sourceTree = ""; }; - 42A6C306038665FDDA3E54E2 /* libPods-RNTesterUnitTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNTesterUnitTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; - 5BBFF3E3792E27C4FBA2CB43 /* libPods-RNTesterIntegrationTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNTesterIntegrationTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; + 4610AEE3F1885AD3F6741BD1 /* libPods-RNTester.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNTester.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 5BEC8567F3741044B6A5EFC5 /* Pods-RNTester.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNTester.release.xcconfig"; path = "Pods/Target Support Files/Pods-RNTester/Pods-RNTester.release.xcconfig"; sourceTree = ""; }; 5C60EB1B226440DB0018C04F /* AppDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AppDelegate.mm; path = RNTester/AppDelegate.mm; sourceTree = ""; }; 5CB07C99226467E60039471C /* RNTesterTurboModuleProvider.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RNTesterTurboModuleProvider.mm; path = RNTester/RNTesterTurboModuleProvider.mm; sourceTree = ""; }; @@ -163,7 +164,6 @@ E7DB216122B2F3EC005AC45F /* RCTRootViewIntegrationTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTRootViewIntegrationTests.m; sourceTree = ""; }; E7DB218B22B41FCD005AC45F /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; E9618482EC8608D4872A6E28 /* Pods-RNTesterUnitTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RNTesterUnitTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests.release.xcconfig"; sourceTree = ""; }; - EA4C77A9826FF02A56911142 /* libPods-RNTester.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RNTester.a"; sourceTree = BUILT_PRODUCTS_DIR; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -171,7 +171,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( - 42C7FD8921D436BBA216216D /* libPods-RNTester.a in Frameworks */, + CA98220F79ABB17F6FE10829 /* libPods-RNTester.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -181,7 +181,7 @@ files = ( E7DB213122B2C649005AC45F /* JavaScriptCore.framework in Frameworks */, E7DB213222B2C67D005AC45F /* libOCMock.a in Frameworks */, - C23B0809CAE8A115772B092E /* libPods-RNTesterUnitTests.a in Frameworks */, + E24D92BB73326FCC593E9450 /* libPods-RNTesterUnitTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -191,7 +191,7 @@ files = ( E7DB218C22B41FCD005AC45F /* XCTest.framework in Frameworks */, E7DB216722B2F69F005AC45F /* JavaScriptCore.framework in Frameworks */, - 69B65AC442B001534251D909 /* libPods-RNTesterIntegrationTests.a in Frameworks */, + 57E63A755AEDF197848E52C0 /* libPods-RNTesterIntegrationTests.a in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -261,9 +261,9 @@ E7DB211822B2BD53005AC45F /* libReact-RCTText.a */, E7DB211A22B2BD53005AC45F /* libReact-RCTVibration.a */, E7DB212222B2BD53005AC45F /* libyoga.a */, - EA4C77A9826FF02A56911142 /* libPods-RNTester.a */, - 5BBFF3E3792E27C4FBA2CB43 /* libPods-RNTesterIntegrationTests.a */, - 42A6C306038665FDDA3E54E2 /* libPods-RNTesterUnitTests.a */, + 4610AEE3F1885AD3F6741BD1 /* libPods-RNTester.a */, + 076801A3AA34E645F870C076 /* libPods-RNTesterIntegrationTests.a */, + 060D8FF3BA18357FD288E8C8 /* libPods-RNTesterUnitTests.a */, ); name = Frameworks; sourceTree = "";