From 072390ec5cd99928f83aa78fb1b84d96df61fabf Mon Sep 17 00:00:00 2001 From: Nick Lockwood Date: Tue, 25 Aug 2015 11:02:42 -0100 Subject: [PATCH] Fixed SampleAppTests --- .../iOS/SampleApp.xcodeproj/project.pbxproj | 10 ++++++++ .../xcshareddata/xcschemes/SampleApp.xcscheme | 24 +++++++++++++++++++ .../iOS/SampleAppTests/SampleAppTests.m | 19 +++++++++------ 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/Examples/SampleApp/iOS/SampleApp.xcodeproj/project.pbxproj b/Examples/SampleApp/iOS/SampleApp.xcodeproj/project.pbxproj index bb15add6f..e0225c7c7 100644 --- a/Examples/SampleApp/iOS/SampleApp.xcodeproj/project.pbxproj +++ b/Examples/SampleApp/iOS/SampleApp.xcodeproj/project.pbxproj @@ -565,6 +565,11 @@ "DEBUG=1", "$(inherited)", ); + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../../React/**", + ); INFOPLIST_FILE = SampleAppTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -582,6 +587,11 @@ "$(SDKROOT)/Developer/Library/Frameworks", "$(inherited)", ); + HEADER_SEARCH_PATHS = ( + "$(inherited)", + /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, + "$(SRCROOT)/../../../React/**", + ); INFOPLIST_FILE = SampleAppTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; diff --git a/Examples/SampleApp/iOS/SampleApp.xcodeproj/xcshareddata/xcschemes/SampleApp.xcscheme b/Examples/SampleApp/iOS/SampleApp.xcodeproj/xcshareddata/xcschemes/SampleApp.xcscheme index f0a3ea9ae..6a3c2997a 100644 --- a/Examples/SampleApp/iOS/SampleApp.xcodeproj/xcshareddata/xcschemes/SampleApp.xcscheme +++ b/Examples/SampleApp/iOS/SampleApp.xcodeproj/xcshareddata/xcschemes/SampleApp.xcscheme @@ -20,6 +20,20 @@ ReferencedContainer = "container:SampleApp.xcodeproj"> + + + + + + + + #import -#import "RCTAssert.h" -#import "RCTRedBox.h" +#import "RCTLog.h" #import "RCTRootView.h" #define TIMEOUT_SECONDS 240 @@ -23,7 +22,6 @@ @implementation SampleAppTests - - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test { if (test(view)) { @@ -37,18 +35,23 @@ return NO; } -- (void)testRendersWelcomeScreen { +- (void)testRendersWelcomeScreen +{ UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; BOOL foundElement = NO; - NSString *redboxError = nil; + + __block NSString *redboxError = nil; + RCTSetLogFunction(^(RCTLogLevel level, NSString *fileName, NSNumber *lineNumber, NSString *message) { + if (level >= RCTLogLevelError) { + redboxError = message; + } + }); while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; - redboxError = [[RCTRedBox sharedInstance] currentErrorMessage]; - foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { return YES; @@ -57,6 +60,8 @@ }]; } + RCTSetLogFunction(RCTDefaultLogFunction); + XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); }