Prevent tests from ever opening Chrome

The test is commented out for now.
This commit is contained in:
Scott Kyle 2015-10-26 13:25:15 -07:00
parent 6d4b8d1e7b
commit a2cd949e09
4 changed files with 52 additions and 10 deletions

View File

@ -26,7 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "NO">
<Testables>
<TestableReference
skipped = "NO">
@ -53,6 +53,12 @@
ReferencedContainer = "container:RealmJS.xcodeproj">
</BuildableReference>
</MacroExpansion>
<CommandLineArguments>
<CommandLineArgument
argument = "-RealmReactEnableChromeDebugging NO"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>

View File

@ -40,7 +40,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "NO">
<Testables>
<TestableReference
skipped = "NO">
@ -62,6 +62,12 @@
ReferencedContainer = "container:ReactTests.xcodeproj">
</BuildableReference>
</MacroExpansion>
<CommandLineArguments>
<CommandLineArgument
argument = "-RealmReactEnableChromeDebugging NO"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>

View File

@ -19,8 +19,30 @@
#import "AppDelegate.h"
#import "RCTRootView.h"
static NSString * const RealmReactEnableChromeDebuggingKey = @"RealmReactEnableChromeDebugging";
static NSString * const RCTDevMenuKey = @"RCTDevMenu";
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
// Check if this default is explicitly set, otherwise just leave the settings as is.
if ([defaults objectForKey:RealmReactEnableChromeDebuggingKey]) {
NSMutableDictionary *settings = [([defaults dictionaryForKey:RCTDevMenuKey] ?: @{}) mutableCopy];
NSMutableDictionary *domain = [[defaults volatileDomainForName:NSArgumentDomain] mutableCopy];
settings[@"executorClass"] = [defaults boolForKey:RealmReactEnableChromeDebuggingKey] ? @"RCTWebSocketExecutor" : @"RCTContextExecutor";
domain[RCTDevMenuKey] = settings;
// Re-register the arguments domain (highest precedent and volatile) with our new overridden settings.
[defaults removeVolatileDomainForName:NSArgumentDomain];
[defaults setVolatileDomain:domain forName:NSArgumentDomain];
}
return YES;
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSURL *jsCodeLocation;

View File

@ -26,6 +26,9 @@
extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSGlobalContextRef ctx, bool includesNativeCallStack);
@interface RCTDevMenu () <RCTInvalidating>
@end
@interface RealmReactTests : RealmJSTests
@end
@ -34,12 +37,6 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG
@implementation RealmReactTests
+ (void)load {
// Swap the [RCTDevMenu init] method with [NSObject init] in order to disable RCTDevMenu completely.
IMP init = class_getMethodImplementation([NSObject class], @selector(init));
class_replaceMethod([RCTDevMenu class], @selector(init), init, NULL);
}
+ (Class)executorClass {
return NSClassFromString(@"RCTContextExecutor");
}
@ -56,14 +53,23 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG
}
static RCTBridge *s_bridge;
if (!s_bridge) {
[[NSNotificationCenter defaultCenter] postNotificationName:RCTReloadNotification object:nil];
}
if (!s_bridge.valid) {
NSNotification *notification = [self waitForNotification:RCTJavaScriptDidLoadNotification];;
s_bridge = notification.userInfo[@"bridge"];
NSNotification *notification = [self waitForNotification:RCTDidCreateNativeModules];
s_bridge = notification.object;
if (!s_bridge) {
NSLog(@"No RCTBridge provided by RCTJavaScriptDidLoadNotification");
exit(1);
}
// We don't want the RCTDevMenu from switching the executor class from underneath us.
[s_bridge.devMenu invalidate];
[self waitForNotification:RCTJavaScriptDidLoadNotification];
}
if (s_bridge.executorClass != executorClass) {
@ -190,6 +196,7 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG
@end
/* TODO: Re-enable once this works in CI
@implementation RealmReactChromeTests
+ (Class)executorClass {
@ -201,3 +208,4 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG
}
@end
*/