mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
Bring back D2570057 (previously backed out) + fixes
Reviewed By: nicklockwood Differential Revision: D2590604 fb-gh-sync-id: 63a0e0c6afda740f22aacb3f469d411f236fa16b
This commit is contained in:
committed by
facebook-github-bot-7
parent
89f1e6732e
commit
40f513aa71
@@ -136,19 +136,25 @@ _Pragma("clang diagnostic pop")
|
||||
NSString *injectedStuff;
|
||||
RUN_RUNLOOP_WHILE(!(injectedStuff = executor.injectedStuff[@"__fbBatchedBridgeConfig"]));
|
||||
|
||||
NSDictionary *moduleConfig = RCTJSONParse(injectedStuff, NULL);
|
||||
NSDictionary *remoteModuleConfig = moduleConfig[@"remoteModuleConfig"];
|
||||
NSDictionary *testModuleConfig = remoteModuleConfig[@"TestModule"];
|
||||
NSDictionary *constants = testModuleConfig[@"constants"];
|
||||
NSDictionary *methods = testModuleConfig[@"methods"];
|
||||
__block NSNumber *testModuleID = nil;
|
||||
__block NSDictionary *testConstants = nil;
|
||||
__block NSNumber *testMethodID = nil;
|
||||
|
||||
NSArray *remoteModuleConfig = RCTJSONParse(injectedStuff, NULL)[@"remoteModuleConfig"];
|
||||
[remoteModuleConfig enumerateObjectsUsingBlock:^(id moduleConfig, NSUInteger i, BOOL *stop) {
|
||||
if ([moduleConfig isKindOfClass:[NSArray class]] && [moduleConfig[0] isEqualToString:@"TestModule"]) {
|
||||
testModuleID = @(i);
|
||||
testConstants = moduleConfig[1];
|
||||
testMethodID = @([moduleConfig[2] indexOfObject:@"testMethod"]);
|
||||
*stop = YES;
|
||||
}
|
||||
}];
|
||||
|
||||
XCTAssertNotNil(moduleConfig);
|
||||
XCTAssertNotNil(remoteModuleConfig);
|
||||
XCTAssertNotNil(testModuleConfig);
|
||||
XCTAssertNotNil(constants);
|
||||
XCTAssertEqualObjects(constants[@"eleventyMillion"], @42);
|
||||
XCTAssertNotNil(methods);
|
||||
XCTAssertNotNil(methods[@"testMethod"]);
|
||||
XCTAssertNotNil(testModuleID);
|
||||
XCTAssertNotNil(testConstants);
|
||||
XCTAssertEqualObjects(testConstants[@"eleventyMillion"], @42);
|
||||
XCTAssertNotNil(testMethodID);
|
||||
}
|
||||
|
||||
- (void)testCallNativeMethod
|
||||
@@ -158,13 +164,19 @@ _Pragma("clang diagnostic pop")
|
||||
NSString *injectedStuff;
|
||||
RUN_RUNLOOP_WHILE(!(injectedStuff = executor.injectedStuff[@"__fbBatchedBridgeConfig"]));
|
||||
|
||||
NSDictionary *moduleConfig = RCTJSONParse(injectedStuff, NULL);
|
||||
NSDictionary *remoteModuleConfig = moduleConfig[@"remoteModuleConfig"];
|
||||
NSDictionary *testModuleConfig = remoteModuleConfig[@"TestModule"];
|
||||
NSNumber *testModuleID = testModuleConfig[@"moduleID"];
|
||||
NSDictionary *methods = testModuleConfig[@"methods"];
|
||||
NSDictionary *testMethod = methods[@"testMethod"];
|
||||
NSNumber *testMethodID = testMethod[@"methodID"];
|
||||
__block NSNumber *testModuleID = nil;
|
||||
__block NSDictionary *testConstants = nil;
|
||||
__block NSNumber *testMethodID = nil;
|
||||
|
||||
NSArray *remoteModuleConfig = RCTJSONParse(injectedStuff, NULL)[@"remoteModuleConfig"];
|
||||
[remoteModuleConfig enumerateObjectsUsingBlock:^(id moduleConfig, NSUInteger i, __unused BOOL *stop) {
|
||||
if ([moduleConfig isKindOfClass:[NSArray class]] && [moduleConfig[0] isEqualToString:@"TestModule"]) {
|
||||
testModuleID = @(i);
|
||||
testConstants = moduleConfig[1];
|
||||
testMethodID = @([moduleConfig[2] indexOfObject:@"testMethod"]);
|
||||
*stop = YES;
|
||||
}
|
||||
}];
|
||||
|
||||
NSArray *args = @[@1234, @5678, @"stringy", @{@"a": @1}, @42];
|
||||
NSArray *buffer = @[@[testModuleID], @[testMethodID], @[args], @[], @1234567];
|
||||
|
||||
Reference in New Issue
Block a user