Continuous Integration cleanup
Reviewed By: yungsters Differential Revision: D24700192 fbshipit-source-id: 239a8ad4848a41ad721a635d4ec37d990989f041
This commit is contained in:
Родитель
729e535137
Коммит
3e77e15526
|
@ -20,8 +20,7 @@
|
|||
|
||||
static const NSTimeInterval kTestTimeoutSeconds = 120;
|
||||
|
||||
@implementation RCTTestRunner
|
||||
{
|
||||
@implementation RCTTestRunner {
|
||||
FBSnapshotTestController *_testController;
|
||||
RCTBridgeModuleListProvider _moduleProvider;
|
||||
NSString *_appPath;
|
||||
|
@ -62,7 +61,8 @@ static const NSTimeInterval kTestTimeoutSeconds = 120;
|
|||
|
||||
if ((self = [super init])) {
|
||||
if (!referenceDirectory.length) {
|
||||
referenceDirectory = [[NSBundle bundleForClass:self.class].resourcePath stringByAppendingPathComponent:@"ReferenceImages"];
|
||||
referenceDirectory =
|
||||
[[NSBundle bundleForClass:self.class].resourcePath stringByAppendingPathComponent:@"ReferenceImages"];
|
||||
}
|
||||
|
||||
NSString *sanitizedAppName = [app stringByReplacingOccurrencesOfString:@"/" withString:@"-"];
|
||||
|
@ -82,13 +82,13 @@ static const NSTimeInterval kTestTimeoutSeconds = 120;
|
|||
return self;
|
||||
}
|
||||
|
||||
RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||
RCT_NOT_IMPLEMENTED(-(instancetype)init)
|
||||
|
||||
- (NSURL *)defaultScriptURL
|
||||
{
|
||||
if (getenv("CI_USE_PACKAGER") || _useBundler) {
|
||||
NSString *bundlePrefix = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"RN_BUNDLE_PREFIX"];
|
||||
return [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@%@.bundle?platform=ios&dev=true", bundlePrefix, _appPath]];
|
||||
return [NSURL
|
||||
URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@.bundle?platform=ios&dev=true", _appPath]];
|
||||
} else {
|
||||
return [[NSBundle bundleForClass:[RCTBridge class]] URLForResource:@"main" withExtension:@"jsbundle"];
|
||||
}
|
||||
|
@ -121,53 +121,63 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
|||
[self runTest:test module:moduleName initialProps:nil configurationBlock:nil expectErrorBlock:nil];
|
||||
}
|
||||
|
||||
- (void)runTest:(SEL)test module:(NSString *)moduleName
|
||||
initialProps:(NSDictionary<NSString *, id> *)initialProps
|
||||
configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock
|
||||
- (void)runTest:(SEL)test
|
||||
module:(NSString *)moduleName
|
||||
initialProps:(NSDictionary<NSString *, id> *)initialProps
|
||||
configurationBlock:(void (^)(RCTRootView *rootView))configurationBlock
|
||||
{
|
||||
[self runTest:test module:moduleName initialProps:initialProps configurationBlock:configurationBlock expectErrorBlock:nil];
|
||||
[self runTest:test
|
||||
module:moduleName
|
||||
initialProps:initialProps
|
||||
configurationBlock:configurationBlock
|
||||
expectErrorBlock:nil];
|
||||
}
|
||||
|
||||
- (void)runTest:(SEL)test module:(NSString *)moduleName
|
||||
initialProps:(NSDictionary<NSString *, id> *)initialProps
|
||||
configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock
|
||||
expectErrorRegex:(NSString *)errorRegex
|
||||
- (void)runTest:(SEL)test
|
||||
module:(NSString *)moduleName
|
||||
initialProps:(NSDictionary<NSString *, id> *)initialProps
|
||||
configurationBlock:(void (^)(RCTRootView *rootView))configurationBlock
|
||||
expectErrorRegex:(NSString *)errorRegex
|
||||
{
|
||||
BOOL(^expectErrorBlock)(NSString *error) = ^BOOL(NSString *error){
|
||||
BOOL (^expectErrorBlock)(NSString *error) = ^BOOL(NSString *error) {
|
||||
return [error rangeOfString:errorRegex options:NSRegularExpressionSearch].location != NSNotFound;
|
||||
};
|
||||
|
||||
[self runTest:test module:moduleName initialProps:initialProps configurationBlock:configurationBlock expectErrorBlock:expectErrorBlock];
|
||||
[self runTest:test
|
||||
module:moduleName
|
||||
initialProps:initialProps
|
||||
configurationBlock:configurationBlock
|
||||
expectErrorBlock:expectErrorBlock];
|
||||
}
|
||||
|
||||
- (void)runTest:(SEL)test module:(NSString *)moduleName
|
||||
initialProps:(NSDictionary<NSString *, id> *)initialProps
|
||||
configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock
|
||||
expectErrorBlock:(BOOL(^)(NSString *error))expectErrorBlock
|
||||
- (void)runTest:(SEL)test
|
||||
module:(NSString *)moduleName
|
||||
initialProps:(NSDictionary<NSString *, id> *)initialProps
|
||||
configurationBlock:(void (^)(RCTRootView *rootView))configurationBlock
|
||||
expectErrorBlock:(BOOL (^)(NSString *error))expectErrorBlock
|
||||
{
|
||||
__weak RCTBridge *batchedBridge;
|
||||
NSNumber *rootTag;
|
||||
RCTLogFunction defaultLogFunction = RCTGetLogFunction();
|
||||
// Catch all error logs, that are equivalent to redboxes in dev mode.
|
||||
__block NSMutableArray<NSString *> *errors = nil;
|
||||
RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
|
||||
defaultLogFunction(level, source, fileName, lineNumber, message);
|
||||
if (level >= RCTLogLevelError) {
|
||||
if (errors == nil) {
|
||||
errors = [NSMutableArray new];
|
||||
}
|
||||
[errors addObject:message];
|
||||
}
|
||||
});
|
||||
RCTSetLogFunction(
|
||||
^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
|
||||
defaultLogFunction(level, source, fileName, lineNumber, message);
|
||||
if (level >= RCTLogLevelError) {
|
||||
if (errors == nil) {
|
||||
errors = [NSMutableArray new];
|
||||
}
|
||||
[errors addObject:message];
|
||||
}
|
||||
});
|
||||
|
||||
@autoreleasepool {
|
||||
RCTBridge *bridge;
|
||||
if (_bridgeDelegate) {
|
||||
bridge = [[RCTBridge alloc] initWithDelegate:_bridgeDelegate launchOptions:nil];
|
||||
} else {
|
||||
bridge= [[RCTBridge alloc] initWithBundleURL:_scriptURL
|
||||
moduleProvider:_moduleProvider
|
||||
launchOptions:nil];
|
||||
bridge = [[RCTBridge alloc] initWithBundleURL:_scriptURL moduleProvider:_moduleProvider launchOptions:nil];
|
||||
}
|
||||
[bridge.devSettings setIsDebuggingRemotely:_useJSDebugger];
|
||||
batchedBridge = [bridge batchedBridge];
|
||||
|
@ -183,7 +193,9 @@ expectErrorBlock:(BOOL(^)(NSString *error))expectErrorBlock
|
|||
|
||||
@autoreleasepool {
|
||||
// The rootView needs to be deallocated after this @autoreleasepool block exits.
|
||||
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:moduleName initialProperties:initialProps];
|
||||
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
|
||||
moduleName:moduleName
|
||||
initialProperties:initialProps];
|
||||
#if TARGET_OS_TV
|
||||
rootView.frame = CGRectMake(0, 0, 1920, 1080); // Standard screen size for tvOS
|
||||
#else
|
||||
|
@ -210,20 +222,22 @@ expectErrorBlock:(BOOL(^)(NSString *error))expectErrorBlock
|
|||
}
|
||||
|
||||
// From this point on catch only fatal errors.
|
||||
RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
|
||||
defaultLogFunction(level, source, fileName, lineNumber, message);
|
||||
if (level >= RCTLogLevelFatal) {
|
||||
if (errors == nil) {
|
||||
errors = [NSMutableArray new];
|
||||
}
|
||||
[errors addObject:message];
|
||||
}
|
||||
});
|
||||
RCTSetLogFunction(
|
||||
^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
|
||||
defaultLogFunction(level, source, fileName, lineNumber, message);
|
||||
if (level >= RCTLogLevelFatal) {
|
||||
if (errors == nil) {
|
||||
errors = [NSMutableArray new];
|
||||
}
|
||||
[errors addObject:message];
|
||||
}
|
||||
});
|
||||
|
||||
#if RCT_DEV
|
||||
NSArray<UIView *> *nonLayoutSubviews = [vc.view.subviews filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id subview, NSDictionary *bindings) {
|
||||
return ![NSStringFromClass([subview class]) isEqualToString:@"_UILayoutGuide"];
|
||||
}]];
|
||||
NSArray<UIView *> *nonLayoutSubviews = [vc.view.subviews
|
||||
filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id subview, NSDictionary *bindings) {
|
||||
return ![NSStringFromClass([subview class]) isEqualToString:@"_UILayoutGuide"];
|
||||
}]];
|
||||
|
||||
RCTAssert(nonLayoutSubviews.count == 0, @"There shouldn't be any other views: %@", nonLayoutSubviews);
|
||||
#endif
|
||||
|
@ -232,7 +246,8 @@ expectErrorBlock:(BOOL(^)(NSString *error))expectErrorBlock
|
|||
RCTAssert(expectErrorBlock(errors[0]), @"Expected an error but the first one was missing or did not match.");
|
||||
} else {
|
||||
RCTAssert(errors == nil, @"RedBox errors: %@", errors);
|
||||
RCTAssert(testModule.status != RCTTestStatusPending, @"Test didn't finish within %0.f seconds", kTestTimeoutSeconds);
|
||||
RCTAssert(
|
||||
testModule.status != RCTTestStatusPending, @"Test didn't finish within %0.f seconds", kTestTimeoutSeconds);
|
||||
RCTAssert(testModule.status == RCTTestStatusPassed, @"Test failed");
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,5 @@
|
|||
</array>
|
||||
<key>UIUserInterfaceStyle</key>
|
||||
<string>Automatic</string>
|
||||
<key>RN_BUNDLE_PREFIX</key>
|
||||
<string>$(RN_BUNDLE_PREFIX)</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
@ -21,19 +21,19 @@
|
|||
#import <React/JSCExecutorFactory.h>
|
||||
#endif
|
||||
|
||||
#import <React/RCTJSIExecutorRuntimeInstaller.h>
|
||||
#import <React/RCTBridge.h>
|
||||
#import <React/RCTBundleURLProvider.h>
|
||||
#import <React/RCTCxxBridgeDelegate.h>
|
||||
#import <React/RCTJavaScriptLoader.h>
|
||||
#import <React/RCTLinkingManager.h>
|
||||
#import <React/RCTImageLoader.h>
|
||||
#import <React/RCTLocalAssetImageLoader.h>
|
||||
#import <React/RCTGIFImageDecoder.h>
|
||||
#import <React/RCTNetworking.h>
|
||||
#import <React/RCTHTTPRequestHandler.h>
|
||||
#import <React/RCTDataRequestHandler.h>
|
||||
#import <React/RCTFileRequestHandler.h>
|
||||
#import <React/RCTGIFImageDecoder.h>
|
||||
#import <React/RCTHTTPRequestHandler.h>
|
||||
#import <React/RCTImageLoader.h>
|
||||
#import <React/RCTJSIExecutorRuntimeInstaller.h>
|
||||
#import <React/RCTJavaScriptLoader.h>
|
||||
#import <React/RCTLinkingManager.h>
|
||||
#import <React/RCTLocalAssetImageLoader.h>
|
||||
#import <React/RCTNetworking.h>
|
||||
#import <React/RCTRootView.h>
|
||||
|
||||
#import <cxxreact/JSExecutor.h>
|
||||
|
@ -43,9 +43,9 @@
|
|||
#endif
|
||||
|
||||
#ifdef RN_FABRIC_ENABLED
|
||||
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
|
||||
#import <React/RCTSurfacePresenter.h>
|
||||
#import <React/RCTSurfacePresenterBridgeAdapter.h>
|
||||
#import <React/RCTFabricSurfaceHostingProxyRootView.h>
|
||||
|
||||
#import <react/config/ReactNativeConfig.h>
|
||||
#endif
|
||||
|
@ -66,8 +66,7 @@
|
|||
|
||||
#import "RNTesterTurboModuleProvider.h"
|
||||
|
||||
@interface AppDelegate() <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate>{
|
||||
|
||||
@interface AppDelegate () <RCTCxxBridgeDelegate, RCTTurboModuleManagerDelegate> {
|
||||
#ifdef RN_FABRIC_ENABLED
|
||||
RCTSurfacePresenterBridgeAdapter *_bridgeAdapter;
|
||||
std::shared_ptr<const facebook::react::ReactNativeConfig> _reactNativeConfig;
|
||||
|
@ -84,14 +83,14 @@
|
|||
{
|
||||
RCTEnableTurboModule(YES);
|
||||
|
||||
_bridge = [[RCTBridge alloc] initWithDelegate:self
|
||||
launchOptions:launchOptions];
|
||||
_bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
|
||||
|
||||
// Appetizer.io params check
|
||||
NSDictionary *initProps = @{};
|
||||
NSString *_routeUri = [[NSUserDefaults standardUserDefaults] stringForKey:@"route"];
|
||||
if (_routeUri) {
|
||||
initProps = @{@"exampleFromAppetizeParams": [NSString stringWithFormat:@"rntester://example/%@Example", _routeUri]};
|
||||
initProps =
|
||||
@{@"exampleFromAppetizeParams" : [NSString stringWithFormat:@"rntester://example/%@Example", _routeUri]};
|
||||
}
|
||||
|
||||
#ifdef RN_FABRIC_ENABLED
|
||||
|
@ -100,12 +99,13 @@
|
|||
|
||||
_contextContainer->insert("ReactNativeConfig", _reactNativeConfig);
|
||||
|
||||
_bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:_bridge
|
||||
contextContainer:_contextContainer];
|
||||
_bridgeAdapter = [[RCTSurfacePresenterBridgeAdapter alloc] initWithBridge:_bridge contextContainer:_contextContainer];
|
||||
|
||||
_bridge.surfacePresenter = _bridgeAdapter.surfacePresenter;
|
||||
|
||||
UIView *rootView = [[RCTFabricSurfaceHostingProxyRootView alloc] initWithBridge:_bridge moduleName:@"RNTesterApp" initialProperties:initProps];
|
||||
UIView *rootView = [[RCTFabricSurfaceHostingProxyRootView alloc] initWithBridge:_bridge
|
||||
moduleName:@"RNTesterApp"
|
||||
initialProperties:initProps];
|
||||
#else
|
||||
UIView *rootView = [[RCTRootView alloc] initWithBridge:_bridge moduleName:@"RNTesterApp" initialProperties:initProps];
|
||||
#endif
|
||||
|
@ -121,9 +121,7 @@
|
|||
|
||||
- (NSURL *)sourceURLForBridge:(__unused RCTBridge *)bridge
|
||||
{
|
||||
NSString *bundlePrefix = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"RN_BUNDLE_PREFIX"];
|
||||
NSString *bundleRoot = [NSString stringWithFormat:@"%@packages/rn-tester/js/RNTesterApp.ios", bundlePrefix];
|
||||
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:bundleRoot
|
||||
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"packages/rn-tester/js/RNTesterApp.ios"
|
||||
fallbackResource:nil];
|
||||
}
|
||||
|
||||
|
@ -145,7 +143,7 @@
|
|||
|
||||
- (BOOL)application:(UIApplication *)app
|
||||
openURL:(NSURL *)url
|
||||
options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options
|
||||
options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options
|
||||
{
|
||||
return [RCTLinkingManager application:app openURL:url options:options];
|
||||
}
|
||||
|
@ -154,12 +152,10 @@
|
|||
onProgress:(RCTSourceLoadProgressBlock)onProgress
|
||||
onComplete:(RCTSourceLoadBlock)loadCallback
|
||||
{
|
||||
[RCTJavaScriptLoader loadBundleAtURL:[self sourceURLForBridge:bridge]
|
||||
onProgress:onProgress
|
||||
onComplete:loadCallback];
|
||||
[RCTJavaScriptLoader loadBundleAtURL:[self sourceURLForBridge:bridge] onProgress:onProgress onComplete:loadCallback];
|
||||
}
|
||||
|
||||
# pragma mark - RCTCxxBridgeDelegate
|
||||
#pragma mark - RCTCxxBridgeDelegate
|
||||
|
||||
- (std::unique_ptr<facebook::react::JSExecutorFactory>)jsExecutorFactoryForBridge:(RCTBridge *)bridge
|
||||
{
|
||||
|
@ -182,19 +178,17 @@
|
|||
#else
|
||||
return std::make_unique<facebook::react::JSCExecutorFactory>(
|
||||
#endif
|
||||
facebook::react::RCTJSIExecutorRuntimeInstaller([weakSelf, bridge](facebook::jsi::Runtime &runtime) {
|
||||
if (!bridge) {
|
||||
return;
|
||||
}
|
||||
__typeof(self) strongSelf = weakSelf;
|
||||
if (strongSelf) {
|
||||
facebook::react::RuntimeExecutor syncRuntimeExecutor = [&](std::function<void(facebook::jsi::Runtime &runtime_)> &&callback) {
|
||||
callback(runtime);
|
||||
};
|
||||
[strongSelf->_turboModuleManager installJSBindingWithRuntimeExecutor:syncRuntimeExecutor];
|
||||
}
|
||||
})
|
||||
);
|
||||
facebook::react::RCTJSIExecutorRuntimeInstaller([weakSelf, bridge](facebook::jsi::Runtime &runtime) {
|
||||
if (!bridge) {
|
||||
return;
|
||||
}
|
||||
__typeof(self) strongSelf = weakSelf;
|
||||
if (strongSelf) {
|
||||
facebook::react::RuntimeExecutor syncRuntimeExecutor =
|
||||
[&](std::function<void(facebook::jsi::Runtime & runtime_)> &&callback) { callback(runtime); };
|
||||
[strongSelf->_turboModuleManager installJSBindingWithRuntimeExecutor:syncRuntimeExecutor];
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
#pragma mark RCTTurboModuleManagerDelegate
|
||||
|
@ -211,7 +205,8 @@
|
|||
}
|
||||
|
||||
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:(const std::string &)name
|
||||
initParams:(const facebook::react::ObjCTurboModule::InitParams &)params
|
||||
initParams:
|
||||
(const facebook::react::ObjCTurboModule::InitParams &)params
|
||||
{
|
||||
return facebook::react::RNTesterTurboModuleProvider(name, params);
|
||||
}
|
||||
|
@ -219,13 +214,15 @@
|
|||
- (id<RCTTurboModule>)getModuleInstanceFromClass:(Class)moduleClass
|
||||
{
|
||||
if (moduleClass == RCTImageLoader.class) {
|
||||
return [[moduleClass alloc] initWithRedirectDelegate:nil loadersProvider:^NSArray<id<RCTImageURLLoader>> *{
|
||||
return @[[RCTLocalAssetImageLoader new]];
|
||||
} decodersProvider:^NSArray<id<RCTImageDataDecoder>> *{
|
||||
return @[[RCTGIFImageDecoder new]];
|
||||
}];
|
||||
return [[moduleClass alloc] initWithRedirectDelegate:nil
|
||||
loadersProvider:^NSArray<id<RCTImageURLLoader>> * {
|
||||
return @ [[RCTLocalAssetImageLoader new]];
|
||||
}
|
||||
decodersProvider:^NSArray<id<RCTImageDataDecoder>> * {
|
||||
return @ [[RCTGIFImageDecoder new]];
|
||||
}];
|
||||
} else if (moduleClass == RCTNetworking.class) {
|
||||
return [[moduleClass alloc] initWithHandlersProvider:^NSArray<id<RCTURLRequestHandler>> *{
|
||||
return [[moduleClass alloc] initWithHandlersProvider:^NSArray<id<RCTURLRequestHandler>> * {
|
||||
return @[
|
||||
[RCTHTTPRequestHandler new],
|
||||
[RCTDataRequestHandler new],
|
||||
|
@ -237,24 +234,27 @@
|
|||
return [moduleClass new];
|
||||
}
|
||||
|
||||
# pragma mark - Push Notifications
|
||||
#pragma mark - Push Notifications
|
||||
|
||||
#if !TARGET_OS_TV && !TARGET_OS_UIKITFORMAC
|
||||
|
||||
// Required to register for notifications
|
||||
- (void)application:(__unused UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
|
||||
- (void)application:(__unused UIApplication *)application
|
||||
didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
|
||||
{
|
||||
[RCTPushNotificationManager didRegisterUserNotificationSettings:notificationSettings];
|
||||
}
|
||||
|
||||
// Required for the remoteNotificationsRegistered event.
|
||||
- (void)application:(__unused UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
|
||||
- (void)application:(__unused UIApplication *)application
|
||||
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
|
||||
{
|
||||
[RCTPushNotificationManager didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
|
||||
}
|
||||
|
||||
// Required for the remoteNotificationRegistrationError event.
|
||||
- (void)application:(__unused UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
|
||||
- (void)application:(__unused UIApplication *)application
|
||||
didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
|
||||
{
|
||||
[RCTPushNotificationManager didFailToRegisterForRemoteNotificationsWithError:error];
|
||||
}
|
||||
|
@ -266,7 +266,8 @@
|
|||
}
|
||||
|
||||
// Required for the localNotificationReceived event.
|
||||
- (void)application:(__unused UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
|
||||
- (void)application:(__unused UIApplication *)application
|
||||
didReceiveLocalNotification:(UILocalNotification *)notification
|
||||
{
|
||||
[RCTPushNotificationManager didReceiveLocalNotification:notification];
|
||||
}
|
||||
|
|
|
@ -60,7 +60,5 @@
|
|||
<false/>
|
||||
<key>NSPhotoLibraryUsageDescription</key>
|
||||
<string>You need to add NSPhotoLibraryUsageDescription key in Info.plist to enable photo library usage, otherwise it is going to *fail silently*!</string>
|
||||
<key>RN_BUNDLE_PREFIX</key>
|
||||
<string>$(RN_BUNDLE_PREFIX)</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
@ -15,8 +15,7 @@
|
|||
|
||||
@end
|
||||
|
||||
@implementation RCTLoggingTests
|
||||
{
|
||||
@implementation RCTLoggingTests {
|
||||
RCTBridge *_bridge;
|
||||
|
||||
dispatch_semaphore_t _logSem;
|
||||
|
@ -29,9 +28,9 @@
|
|||
{
|
||||
NSURL *scriptURL;
|
||||
if (getenv("CI_USE_PACKAGER")) {
|
||||
NSString *bundlePrefix = [[[NSBundle mainBundle] infoDictionary] valueForKey:@"RN_BUNDLE_PREFIX"];
|
||||
NSString *app = @"IntegrationTests/IntegrationTestsApp";
|
||||
scriptURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@%@.bundle?platform=ios&dev=true", bundlePrefix, app]];
|
||||
scriptURL =
|
||||
[NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@.bundle?platform=ios&dev=true", app]];
|
||||
} else {
|
||||
scriptURL = [[NSBundle bundleForClass:[RCTBridge class]] URLForResource:@"main" withExtension:@"jsbundle"];
|
||||
}
|
||||
|
@ -59,18 +58,23 @@
|
|||
{
|
||||
// First console log call will fire after 2.0 sec, to allow for any initial log messages
|
||||
// that might come in (seeing this in tvOS)
|
||||
[_bridge enqueueJSCall:@"LoggingTestModule.logToConsoleAfterWait" args:@[@"Invoking console.log",@2000]];
|
||||
[_bridge enqueueJSCall:@"LoggingTestModule.logToConsoleAfterWait" args:@[ @"Invoking console.log", @2000 ]];
|
||||
// Spin native layer for 1.9 sec
|
||||
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.9]];
|
||||
// Now set the log function to signal the semaphore
|
||||
RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, __unused NSString *fileName, __unused NSNumber *lineNumber, NSString *message) {
|
||||
if (source == RCTLogSourceJavaScript) {
|
||||
self->_lastLogLevel = level;
|
||||
self->_lastLogSource = source;
|
||||
self->_lastLogMessage = message;
|
||||
dispatch_semaphore_signal(self->_logSem);
|
||||
}
|
||||
});
|
||||
RCTSetLogFunction(
|
||||
^(RCTLogLevel level,
|
||||
RCTLogSource source,
|
||||
__unused NSString *fileName,
|
||||
__unused NSNumber *lineNumber,
|
||||
NSString *message) {
|
||||
if (source == RCTLogSourceJavaScript) {
|
||||
self->_lastLogLevel = level;
|
||||
self->_lastLogSource = source;
|
||||
self->_lastLogMessage = message;
|
||||
dispatch_semaphore_signal(self->_logSem);
|
||||
}
|
||||
});
|
||||
// Wait for console log to signal the semaphore
|
||||
dispatch_semaphore_wait(_logSem, DISPATCH_TIME_FOREVER);
|
||||
|
||||
|
@ -78,21 +82,21 @@
|
|||
XCTAssertEqual(_lastLogSource, RCTLogSourceJavaScript);
|
||||
XCTAssertEqualObjects(_lastLogMessage, @"Invoking console.log");
|
||||
|
||||
[_bridge enqueueJSCall:@"LoggingTestModule.warning" args:@[@"Generating warning"]];
|
||||
[_bridge enqueueJSCall:@"LoggingTestModule.warning" args:@[ @"Generating warning" ]];
|
||||
dispatch_semaphore_wait(_logSem, DISPATCH_TIME_FOREVER);
|
||||
|
||||
XCTAssertEqual(_lastLogLevel, RCTLogLevelWarning);
|
||||
XCTAssertEqual(_lastLogSource, RCTLogSourceJavaScript);
|
||||
XCTAssertEqualObjects(_lastLogMessage, @"Generating warning");
|
||||
|
||||
[_bridge enqueueJSCall:@"LoggingTestModule.invariant" args:@[@"Invariant failed"]];
|
||||
[_bridge enqueueJSCall:@"LoggingTestModule.invariant" args:@[ @"Invariant failed" ]];
|
||||
dispatch_semaphore_wait(_logSem, DISPATCH_TIME_FOREVER);
|
||||
|
||||
XCTAssertEqual(_lastLogLevel, RCTLogLevelError);
|
||||
XCTAssertEqual(_lastLogSource, RCTLogSourceJavaScript);
|
||||
XCTAssertTrue([_lastLogMessage containsString:@"Invariant Violation: Invariant failed"]);
|
||||
|
||||
[_bridge enqueueJSCall:@"LoggingTestModule.logErrorToConsole" args:@[@"Invoking console.error"]];
|
||||
[_bridge enqueueJSCall:@"LoggingTestModule.logErrorToConsole" args:@[ @"Invoking console.error" ]];
|
||||
dispatch_semaphore_wait(_logSem, DISPATCH_TIME_FOREVER);
|
||||
|
||||
// For local bundles, we'll first get a warning about symbolication
|
||||
|
@ -104,7 +108,7 @@
|
|||
XCTAssertEqual(_lastLogSource, RCTLogSourceJavaScript);
|
||||
XCTAssertEqualObjects(_lastLogMessage, @"Invoking console.error");
|
||||
|
||||
[_bridge enqueueJSCall:@"LoggingTestModule.throwError" args:@[@"Throwing an error"]];
|
||||
[_bridge enqueueJSCall:@"LoggingTestModule.throwError" args:@[ @"Throwing an error" ]];
|
||||
dispatch_semaphore_wait(_logSem, DISPATCH_TIME_FOREVER);
|
||||
|
||||
// For local bundles, we'll first get a warning about symbolication
|
||||
|
|
|
@ -42,11 +42,6 @@
|
|||
value = "1"
|
||||
isEnabled = "YES">
|
||||
</EnvironmentVariable>
|
||||
<EnvironmentVariable
|
||||
key = "RN_BUNDLE_PREFIX"
|
||||
value = ""
|
||||
isEnabled = "YES">
|
||||
</EnvironmentVariable>
|
||||
</EnvironmentVariables>
|
||||
<Testables>
|
||||
<TestableReference
|
||||
|
|
Загрузка…
Ссылка в новой задаче