Fix to make RealmReact tests work in Chrome again

Left the RealmReactChromeTests commented out for now until it's confirmed to work in the CI environment.
This commit is contained in:
Scott Kyle 2015-11-02 13:37:37 -08:00
parent aa55b61b86
commit 7181a00f01
1 changed files with 10 additions and 21 deletions

View File

@ -12,9 +12,6 @@
extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSGlobalContextRef ctx, bool includesNativeCallStack); extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSGlobalContextRef ctx, bool includesNativeCallStack);
@interface RCTDevMenu () <RCTInvalidating>
@end
@interface RealmReactTests : RealmJSTests @interface RealmReactTests : RealmJSTests
@end @end
@ -23,6 +20,12 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG
@implementation RealmReactTests @implementation RealmReactTests
+ (void)load {
// We don't want the RCTDevMenu from switching the executor class from underneath us.
IMP init = class_getMethodImplementation([NSObject class], @selector(init));
class_replaceMethod([RCTDevMenu class], @selector(init), init, NULL);
}
+ (Class)executorClass { + (Class)executorClass {
return NSClassFromString(@"RCTContextExecutor"); return NSClassFromString(@"RCTContextExecutor");
} }
@ -33,10 +36,7 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG
+ (id<RCTJavaScriptExecutor>)currentExecutor { + (id<RCTJavaScriptExecutor>)currentExecutor {
Class executorClass = [self executorClass]; Class executorClass = [self executorClass];
if (!executorClass) { assert(executorClass);
NSLog(@"%@: Executor class not found", self);
exit(1);
}
static RCTBridge *s_bridge; static RCTBridge *s_bridge;
if (!s_bridge) { if (!s_bridge) {
@ -44,20 +44,9 @@ extern void JSGlobalContextSetIncludesNativeCallStackWhenReportingExceptions(JSG
} }
if (!s_bridge.valid) { if (!s_bridge.valid) {
NSNotification *notification = [self waitForNotification:RCTDidCreateNativeModules]; NSNotification *notification = [self waitForNotification:RCTJavaScriptDidLoadNotification];
s_bridge = notification.object; s_bridge = notification.userInfo[@"bridge"];
assert(s_bridge);
if (!s_bridge) {
NSLog(@"No RCTBridge provided by RCTJavaScriptDidLoadNotification");
exit(1);
}
#ifdef DEBUG
// We don't want the RCTDevMenu from switching the executor class from underneath us.
[s_bridge.devMenu invalidate];
#endif
[self waitForNotification:RCTJavaScriptDidLoadNotification];
} }
if (s_bridge.executorClass != executorClass) { if (s_bridge.executorClass != executorClass) {