mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-18 12:22:20 +08:00
Remove code for testing without JS bundle
Reviewed By: mmmulani Differential Revision: D3542347 fbshipit-source-id: d0dcfb65645faf515e6e48e6ff733646e1bcf907
This commit is contained in:
committed by
Facebook Github Bot 8
parent
2ae23d9f36
commit
81f59dfdc2
@@ -92,6 +92,11 @@ RCT_EXPORT_MODULE()
|
||||
block();
|
||||
}
|
||||
|
||||
- (void)executeAsyncBlockOnJavaScriptQueue:(dispatch_block_t)block
|
||||
{
|
||||
block();
|
||||
}
|
||||
|
||||
- (void)injectJSONText:(NSString *)script
|
||||
asGlobalObjectNamed:(NSString *)objectName
|
||||
callback:(RCTJavaScriptCompleteBlock)onComplete
|
||||
@@ -151,7 +156,8 @@ RCT_EXPORT_MODULE(TestModule)
|
||||
[super setUp];
|
||||
|
||||
_unregisteredTestModule = [UnregisteredTestModule new];
|
||||
_bridge = [[RCTBridge alloc] initWithBundleURL:nil
|
||||
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
|
||||
_bridge = [[RCTBridge alloc] initWithBundleURL:[bundle URLForResource:@"TestBundle" withExtension:@"js"]
|
||||
moduleProvider:^{ return @[self, self->_unregisteredTestModule]; }
|
||||
launchOptions:nil];
|
||||
|
||||
|
||||
@@ -95,7 +95,8 @@ RCT_CUSTOM_VIEW_PROPERTY(customProp, NSString, RCTPropsTestView)
|
||||
{
|
||||
[super setUp];
|
||||
|
||||
_bridge = [[RCTBridge alloc] initWithBundleURL:nil
|
||||
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
|
||||
_bridge = [[RCTBridge alloc] initWithBundleURL:[bundle URLForResource:@"TestBundle" withExtension:@"js"]
|
||||
moduleProvider:nil
|
||||
launchOptions:nil];
|
||||
}
|
||||
|
||||
@@ -33,7 +33,15 @@ RCTDefineImageDecoder(RCTImageLoaderTestsDecoder2)
|
||||
|
||||
@end
|
||||
|
||||
@implementation RCTImageLoaderTests
|
||||
@implementation RCTImageLoaderTests {
|
||||
NSURL *_bundleURL;
|
||||
}
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
|
||||
_bundleURL = [bundle URLForResource:@"TestBundle" withExtension:@"js"];
|
||||
}
|
||||
|
||||
- (void)testImageLoading
|
||||
{
|
||||
@@ -47,7 +55,7 @@ RCTDefineImageDecoder(RCTImageLoaderTestsDecoder2)
|
||||
return nil;
|
||||
}];
|
||||
|
||||
NS_VALID_UNTIL_END_OF_SCOPE RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:nil moduleProvider:^{ return @[loader]; } launchOptions:nil];
|
||||
NS_VALID_UNTIL_END_OF_SCOPE RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:_bundleURL moduleProvider:^{ return @[loader]; } launchOptions:nil];
|
||||
|
||||
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://facebook.github.io/react/img/logo_og.png"]];
|
||||
[bridge.imageLoader loadImageWithURLRequest:urlRequest size:CGSizeMake(100, 100) scale:1.0 clipped:YES resizeMode:RCTResizeModeContain progressBlock:^(int64_t progress, int64_t total) {
|
||||
@@ -78,7 +86,7 @@ RCTDefineImageDecoder(RCTImageLoaderTestsDecoder2)
|
||||
return nil;
|
||||
}];
|
||||
|
||||
NS_VALID_UNTIL_END_OF_SCOPE RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:nil moduleProvider:^{ return @[loader1, loader2]; } launchOptions:nil];
|
||||
NS_VALID_UNTIL_END_OF_SCOPE RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:_bundleURL moduleProvider:^{ return @[loader1, loader2]; } launchOptions:nil];
|
||||
|
||||
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://facebook.github.io/react/img/logo_og.png"]];
|
||||
[bridge.imageLoader loadImageWithURLRequest:urlRequest size:CGSizeMake(100, 100) scale:1.0 clipped:YES resizeMode:RCTResizeModeContain progressBlock:^(int64_t progress, int64_t total) {
|
||||
@@ -103,7 +111,7 @@ RCTDefineImageDecoder(RCTImageLoaderTestsDecoder2)
|
||||
return nil;
|
||||
}];
|
||||
|
||||
NS_VALID_UNTIL_END_OF_SCOPE RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:nil moduleProvider:^{ return @[decoder]; } launchOptions:nil];
|
||||
NS_VALID_UNTIL_END_OF_SCOPE RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:_bundleURL moduleProvider:^{ return @[decoder]; } launchOptions:nil];
|
||||
|
||||
RCTImageLoaderCancellationBlock cancelBlock = [bridge.imageLoader decodeImageData:data size:CGSizeMake(1, 1) scale:1.0 clipped:NO resizeMode:RCTResizeModeStretch completionBlock:^(NSError *decodeError, id decodedImage) {
|
||||
XCTAssertEqualObjects(decodedImage, image);
|
||||
@@ -132,7 +140,7 @@ RCTDefineImageDecoder(RCTImageLoaderTestsDecoder2)
|
||||
return nil;
|
||||
}];
|
||||
|
||||
NS_VALID_UNTIL_END_OF_SCOPE RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:nil moduleProvider:^{ return @[decoder1, decoder2]; } launchOptions:nil];
|
||||
NS_VALID_UNTIL_END_OF_SCOPE RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:_bundleURL moduleProvider:^{ return @[decoder1, decoder2]; } launchOptions:nil];
|
||||
|
||||
RCTImageLoaderCancellationBlock cancelBlock = [bridge.imageLoader decodeImageData:data size:CGSizeMake(1, 1) scale:1.0 clipped:NO resizeMode:RCTResizeModeStretch completionBlock:^(NSError *decodeError, id decodedImage) {
|
||||
XCTAssertEqualObjects(decodedImage, image);
|
||||
|
||||
@@ -99,7 +99,8 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (NSURL *)sourceURLForBridge:(__unused RCTBridge *)bridge
|
||||
{
|
||||
return nil;
|
||||
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
|
||||
return [bundle URLForResource:@"TestBundle" withExtension:@"js"];
|
||||
}
|
||||
|
||||
- (NSArray *)extraModulesForBridge:(__unused RCTBridge *)bridge
|
||||
|
||||
@@ -147,7 +147,8 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (NSURL *)sourceURLForBridge:(__unused RCTBridge *)bridge
|
||||
{
|
||||
return nil;
|
||||
NSBundle *bundle = [NSBundle bundleForClass:[self class]];
|
||||
return [bundle URLForResource:@"TestBundle" withExtension:@"js"];
|
||||
}
|
||||
|
||||
- (NSArray *)extraModulesForBridge:(__unused RCTBridge *)bridge
|
||||
|
||||
Reference in New Issue
Block a user