Permalink
Browse files

Remove RCTBatchedBridge rule and all uses from the tree

Reviewed By: AaaChiuuu, javache

Differential Revision: D4889438

fbshipit-source-id: ba103ace8802f0976e09af6b491442e9aa723f49
  • Loading branch information...
mhorowitz authored and facebook-github-bot committed Apr 19, 2017
1 parent 3122328 commit 325228d6cf69535a45a736389996f2b2e9a36a7f
@@ -17,7 +17,6 @@
#import <React/RCTBridge+Private.h>
#import <React/RCTBridge.h>
#import <React/RCTJSCExecutor.h>
#import <React/RCTModuleMethod.h>
#import <React/RCTRootView.h>
@@ -78,9 +77,10 @@ - (void)setUp
NSString *bundleContents =
@"var __fbBatchedBridge = {"
" callFunctionReturnFlushedQueue: function() {},"
" invokeCallbackAndReturnFlushedQueue: function() {},"
" flushedQueue: function() {},"
" callFunctionReturnFlushedQueue: function() { return null; },"
" invokeCallbackAndReturnFlushedQueue: function() { return null; },"
" flushedQueue: function() { return null; },"
" callFunctionReturnResultAndFlushedQueue: function() { return null; },"
"};";
NSURL *tempDir = [NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES];
@@ -167,39 +167,6 @@ - (void)testModuleMethodsAreDeallocated
XCTAssertNil(weakMethod, @"RCTModuleMethod should have been deallocated");
}
- (void)testJavaScriptExecutorIsDeallocated
{
__weak id<RCTJavaScriptExecutor> weakExecutor;
@autoreleasepool {
RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:_bundleURL
moduleProvider:nil
launchOptions:nil];
weakExecutor = [bridge.batchedBridge valueForKey:@"javaScriptExecutor"];
XCTAssertNotNil(weakExecutor, @"JavaScriptExecutor should have been created");
(void)bridge;
}
RUN_RUNLOOP_WHILE(weakExecutor);
XCTAssertNil(weakExecutor, @"JavaScriptExecutor should have been released");
}
- (void)testJavaScriptContextIsDeallocated
{
__weak id weakContext;
@autoreleasepool {
RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:_bundleURL
moduleProvider:nil
launchOptions:nil];
id executor = [bridge.batchedBridge valueForKey:@"javaScriptExecutor"];
RUN_RUNLOOP_WHILE(!(weakContext = [executor valueForKey:@"_context"]));
XCTAssertNotNil(weakContext, @"RCTJavaScriptContext should have been created");
(void)bridge;
}
RUN_RUNLOOP_WHILE(weakContext);
XCTAssertNil(weakContext, @"RCTJavaScriptContext should have been deallocated");
}
- (void)testContentViewIsInvalidated
{
RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:_bundleURL
@@ -14,9 +14,22 @@
#import <XCTest/XCTest.h>
#import <React/RCTBridge+JavaScriptCore.h>
#import <React/RCTBridge.h>
#import <React/RCTDevMenu.h>
#define RUN_RUNLOOP_WHILE(CONDITION) \
{ \
NSDate *timeout = [NSDate dateWithTimeIntervalSinceNow:5]; \
while ((CONDITION)) { \
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; \
if ([timeout timeIntervalSinceNow] <= 0) { \
XCTFail(@"Runloop timed out before condition was met"); \
break; \
} \
} \
}
typedef void(^RCTDevMenuAlertActionHandler)(UIAlertAction *action);
@interface RCTDevMenu ()
@@ -42,6 +55,8 @@ - (void)setUp
_bridge = [[RCTBridge alloc] initWithBundleURL:[bundle URLForResource:@"UIExplorerUnitTestsBundle" withExtension:@"js"]
moduleProvider:nil
launchOptions:nil];
RUN_RUNLOOP_WHILE(_bridge.isLoading);
}
- (void)testShowCreatingActionSheet
@@ -51,7 +66,6 @@ - (void)testShowCreatingActionSheet
XCTAssertTrue([_bridge.devMenu isActionSheetShown]);
}
- (void)testClosingActionSheetAfterAction
{
for (RCTDevMenuItem *item in _bridge.devMenu.presentedItems) {
@@ -65,6 +65,17 @@ - (NSArray *)arguments
@end
@interface RCTDummyBridge : RCTBridge
- (void)dispatchBlock:(dispatch_block_t)block
queue:(dispatch_queue_t)queue;
@end
@implementation RCTDummyBridge
- (void)dispatchBlock:(dispatch_block_t)block
queue:(dispatch_queue_t)queue
{}
@end
@interface RCTEventDispatcherTests : XCTestCase
@end
@@ -84,7 +95,7 @@ - (void)setUp
{
[super setUp];
_bridge = [OCMockObject mockForClass:[RCTBatchedBridge class]];
_bridge = [OCMockObject mockForClass:[RCTDummyBridge class]];
_eventDispatcher = [RCTEventDispatcher new];
[_eventDispatcher setValue:_bridge forKey:@"bridge"];
@@ -121,9 +121,7 @@ - (void)tearDown
[super tearDown];
_notificationObserver = nil;
id<RCTJavaScriptExecutor> jsExecutor = _bridge.batchedBridge.javaScriptExecutor;
[_bridge invalidate];
RUN_RUNLOOP_WHILE(jsExecutor.isValid);
_bridge = nil;
}
@@ -179,9 +179,7 @@ - (void)tearDown
[[NSNotificationCenter defaultCenter] removeObserver:self name:RCTDidInitializeModuleNotification object:nil];
id<RCTJavaScriptExecutor> jsExecutor = _bridge.batchedBridge.javaScriptExecutor;
[_bridge invalidate];
RUN_RUNLOOP_WHILE(jsExecutor.isValid);
_bridge = nil;
}
@@ -10,7 +10,6 @@
#import "RCTTestRunner.h"
#import <React/RCTAssert.h>
#import <React/RCTBridge+Private.h>
#import <React/RCTLog.h>
#import <React/RCTRootView.h>
#import <React/RCTUtils.h>
@@ -27,23 +27,6 @@ RCT_EXTERN NSString *const RCTJSCThreadName;
*/
RCT_EXTERN NSString *const RCTJavaScriptContextCreatedNotification;
/**
* A key to a reference to a JSContext class, held in the the current thread's
* dictionary. The reference would point to the JSContext class in the JS VM
* used in React (or ComponenetScript). It is recommended not to access it
* through the thread's dictionary, but rather to use the `FBJSCurrentContext()`
* accessor, which will return the current JSContext in the currently used VM.
*/
RCT_EXTERN NSString *const RCTFBJSContextClassKey;
/**
* A key to a reference to a JSValue class, held in the the current thread's
* dictionary. The reference would point to the JSValue class in the JS VM
* used in React (or ComponenetScript). It is recommended not to access it
* through the thread's dictionary, but rather to use the `FBJSValue()` accessor.
*/
RCT_EXTERN NSString *const RCTFBJSValueClassKey;
/**
* Uses a JavaScriptCore context as the execution engine.
*/
@@ -38,8 +38,6 @@
NSString *const RCTJSCThreadName = @"com.facebook.react.JavaScript";
NSString *const RCTJavaScriptContextCreatedNotification = @"RCTJavaScriptContextCreatedNotification";
RCT_EXTERN NSString *const RCTFBJSContextClassKey = @"_RCTFBJSContextClassKey";
RCT_EXTERN NSString *const RCTFBJSValueClassKey = @"_RCTFBJSValueClassKey";
struct __attribute__((packed)) ModuleData {
uint32_t offset;
@@ -331,12 +329,6 @@ - (void)setUp
installBasicSynchronousHooksOnContext(context);
}
NSMutableDictionary *threadDictionary = [[NSThread currentThread] threadDictionary];
if (!threadDictionary[RCTFBJSContextClassKey] || !threadDictionary[RCTFBJSValueClassKey]) {
threadDictionary[RCTFBJSContextClassKey] = JSC_JSContext(contextRef);
threadDictionary[RCTFBJSValueClassKey] = JSC_JSValue(contextRef);
}
RCTFBQuickPerformanceLoggerConfigureHooks(context.JSGlobalContextRef);
__weak RCTJSCExecutor *weakSelf = self;

0 comments on commit 325228d

Please sign in to comment.