Skip to content

Commit

Permalink
Re-enable testUnderlyingBridgeIsDeallocated
Browse files Browse the repository at this point in the history
Reviewed By: jspahrsummers

Differential Revision: D2803543

fb-gh-sync-id: d62b68b1e23fad2a0b3d4e490459b1f38ca2dca1
  • Loading branch information
javache authored and facebook-github-bot-6 committed Jan 6, 2016
1 parent e730a9f commit 435efad
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 28 deletions.
25 changes: 15 additions & 10 deletions Examples/UIExplorer/UIExplorerUnitTests/RCTAllocationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@
#import "RCTRootView.h"

#define RUN_RUNLOOP_WHILE(CONDITION) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wshadow\"") \
NSDate *timeout = [[NSDate date] dateByAddingTimeInterval:5]; \
while ((CONDITION) && [timeout timeIntervalSinceNow] > 0) { \
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:timeout]; \
} \
_Pragma("clang diagnostic pop")
{ \
NSDate *timeout = [NSDate dateWithTimeIntervalSinceNow:5]; \
while ((CONDITION) && [timeout timeIntervalSinceNow] > 0) { \
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; \
} \
}

@interface RCTJavaScriptContext : NSObject

Expand Down Expand Up @@ -212,8 +211,6 @@ - (void)testContentViewIsInvalidated
XCTAssertFalse(rootContentView.userInteractionEnabled, @"RCTContentView should have been invalidated");
}

// This test is flaky, and needs to be fixed before re-enabling. See t9456702.
#if 0
- (void)testUnderlyingBridgeIsDeallocated
{
RCTBridge *bridge;
Expand All @@ -229,7 +226,15 @@ - (void)testUnderlyingBridgeIsDeallocated

XCTAssertNotNil(bridge, @"RCTBridge should not have been deallocated");
XCTAssertNil(batchedBridge, @"RCTBatchedBridge should have been deallocated");

// Wait to complete the test until the new batchedbridge is also deallocated
@autoreleasepool {
batchedBridge = bridge.batchedBridge;
bridge = nil;
}

RUN_RUNLOOP_WHILE(batchedBridge != nil);
XCTAssertNil(batchedBridge);
}
#endif

@end
14 changes: 6 additions & 8 deletions Examples/UIExplorer/UIExplorerUnitTests/RCTBridgeTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,13 @@
#import "RCTJavaScriptExecutor.h"
#import "RCTUtils.h"


#define RUN_RUNLOOP_WHILE(CONDITION) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wshadow\"") \
NSDate *timeout = [[NSDate date] dateByAddingTimeInterval:0.1]; \
while ((CONDITION) && [timeout timeIntervalSinceNow] > 0) { \
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:timeout]; \
} \
_Pragma("clang diagnostic pop")
{ \
NSDate *timeout = [NSDate dateWithTimeIntervalSinceNow:5]; \
while ((CONDITION) && [timeout timeIntervalSinceNow] > 0) { \
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; \
} \
}

@interface TestExecutor : NSObject <RCTJavaScriptExecutor>

Expand Down
13 changes: 6 additions & 7 deletions Examples/UIExplorer/UIExplorerUnitTests/RCTGzipTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@
#import "RCTNetworking.h"

#define RUN_RUNLOOP_WHILE(CONDITION) \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wshadow\"") \
NSDate *timeout = [[NSDate date] dateByAddingTimeInterval:5]; \
while ((CONDITION) && [timeout timeIntervalSinceNow] > 0) { \
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:timeout]; \
} \
_Pragma("clang diagnostic pop")
{ \
NSDate *timeout = [NSDate dateWithTimeIntervalSinceNow:5]; \
while ((CONDITION) && [timeout timeIntervalSinceNow] > 0) { \
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; \
} \
}

extern BOOL RCTIsGzippedData(NSData *data);

Expand Down
7 changes: 4 additions & 3 deletions React/Base/RCTBatchedBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ - (void)start
dispatch_group_notify(initModulesAndLoadSource, dispatch_get_main_queue(), ^{
RCTBatchedBridge *strongSelf = weakSelf;
if (sourceCode && strongSelf.loading) {
dispatch_async(bridgeQueue, ^{
[weakSelf executeSourceCode:sourceCode];
});
[strongSelf executeSourceCode:sourceCode];
}
});
}
Expand Down Expand Up @@ -570,6 +568,7 @@ - (void)invalidate
}

RCTAssertMainThread();
RCTAssert(_javaScriptExecutor != nil, @"Can't complete invalidation without a JS executor");

_loading = NO;
_valid = NO;
Expand Down Expand Up @@ -605,11 +604,13 @@ - (void)invalidate
if (RCTProfileIsProfiling()) {
RCTProfileUnhookModules(self);
}

_moduleDataByName = nil;
_moduleDataByID = nil;
_moduleClassesByID = nil;
_modulesByName_DEPRECATED = nil;
_frameUpdateObservers = nil;
_pendingCalls = nil;

}];
});
Expand Down

0 comments on commit 435efad

Please sign in to comment.