Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/react-native/React/Base/RCTUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ RCT_EXTERN NSURL *RCTDataURL(NSString *mimeType, NSData *data);
// Gzip functionality - compression level in range 0 - 1 (-1 for default)
RCT_EXTERN NSData *__nullable RCTGzipData(NSData *__nullable data, float level);

// Determines whether data is already gzipped. Declared here (rather than only in
// RCTUtils.mm) so it keeps C linkage and can be called from .m unit tests.
RCT_EXTERN BOOL RCTIsGzippedData(NSData *__nullable data);

// Returns the relative path within the main bundle for an absolute URL
// (or nil, if the URL does not specify a path within the main bundle)
RCT_EXTERN NSString *__nullable RCTBundlePathForURL(NSURL *__nullable URL);
Expand Down
1 change: 0 additions & 1 deletion packages/react-native/React/Base/RCTUtils.mm
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,6 @@ BOOL RCTForceTouchAvailable(void)
[data base64EncodedStringWithOptions:(NSDataBase64EncodingOptions)0]]];
}

BOOL RCTIsGzippedData(NSData *__nullable /*data*/); // exposed for unit testing purposes
BOOL RCTIsGzippedData(NSData *__nullable data)
{
UInt8 *bytes = (UInt8 *)data.bytes;
Expand Down
10 changes: 3 additions & 7 deletions packages/rn-tester/RNTester-macOS/RNTester-macOS.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
"configurations" : [
{
"id" : "59C4DFC4-597F-41C6-99FD-32D94C5488D4",
"name" : "Address Sanitizer",
"name" : "Default",
"options" : {
"addressSanitizer" : {
"detectStackUseAfterReturn" : true,
"enabled" : true
}

}
}
],
Expand All @@ -24,8 +21,7 @@
"identifier" : "ACC52F3D299ECB7A002A2B0B",
"name" : "RNTester-macOS"
},
"testRepetitionMode" : "retryOnFailure",
"undefinedBehaviorSanitizerEnabled" : true
"testRepetitionMode" : "retryOnFailure"
},
"testTargets" : [
{
Expand Down
2 changes: 0 additions & 2 deletions packages/rn-tester/RNTesterUnitTests/RCTGzipTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#import <React/RCTNetworking.h>
#import <React/RCTUtils.h>

extern BOOL RCTIsGzippedData(NSData *data);

@interface RCTNetworking (Private)

- (void)buildRequest:(NSDictionary<NSString *, id> *)query completionBlock:(void (^)(NSURLRequest *request))block;
Expand Down
14 changes: 8 additions & 6 deletions packages/rn-tester/RNTesterUnitTests/RCTImageLoaderTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#import <XCTest/XCTest.h>

#import <React/RCTUIKit.h> // [macOS]

#import <React/RCTBridge.h>
#import <React/RCTImageLoader.h>

Expand Down Expand Up @@ -35,7 +37,7 @@ - (void)setUp

- (void)testImageLoading
{
UIImage *image = [UIImage new];
RCTPlatformImage *image = [RCTPlatformImage new]; // [macOS]

id<RCTImageURLLoader> loader = [[RCTImageLoaderTestsURLLoader1 alloc] initWithPriority:1.0
canLoadImageURLHandler:^BOOL(__unused NSURL *requestURL) {
Expand Down Expand Up @@ -70,7 +72,7 @@ - (void)testImageLoading
XCTAssertEqual(progress, 1);
XCTAssertEqual(total, 1);
}
partialLoadBlock:^(UIImage *loadedImage) {
partialLoadBlock:^(RCTPlatformImage *loadedImage) { // [macOS]
}
completionBlock:^(NSError *loadError, id loadedImage) {
XCTAssertEqualObjects(loadedImage, image);
Expand All @@ -80,7 +82,7 @@ - (void)testImageLoading

- (void)testImageLoaderUsesImageURLLoaderWithHighestPriority
{
UIImage *image = [UIImage new];
RCTPlatformImage *image = [RCTPlatformImage new]; // [macOS]

id<RCTImageURLLoader> loader1 = [[RCTImageLoaderTestsURLLoader1 alloc] initWithPriority:1.0
canLoadImageURLHandler:^BOOL(__unused NSURL *requestURL) {
Expand Down Expand Up @@ -130,7 +132,7 @@ - (void)testImageLoaderUsesImageURLLoaderWithHighestPriority
XCTAssertEqual(progress, 1);
XCTAssertEqual(total, 1);
}
partialLoadBlock:^(UIImage *loadedImage) {
partialLoadBlock:^(RCTPlatformImage *loadedImage) { // [macOS]
}
completionBlock:^(NSError *loadError, id loadedImage) {
XCTAssertEqualObjects(loadedImage, image);
Expand All @@ -141,7 +143,7 @@ - (void)testImageLoaderUsesImageURLLoaderWithHighestPriority
- (void)testImageDecoding
{
NSData *data = [NSData dataWithBytesNoCopy:blackGIF length:sizeof(blackGIF) freeWhenDone:NO];
UIImage *image = [[UIImage alloc] initWithData:data];
RCTPlatformImage *image = [[RCTPlatformImage alloc] initWithData:data]; // [macOS]

id<RCTImageDataDecoder> decoder = [[RCTImageLoaderTestsDecoder1 alloc] initWithPriority:1.0
canDecodeImageDataHandler:^BOOL(__unused NSData *imageData) {
Expand Down Expand Up @@ -180,7 +182,7 @@ - (void)testImageDecoding
- (void)testImageLoaderUsesImageDecoderWithHighestPriority
{
NSData *data = [NSData dataWithBytesNoCopy:blackGIF length:sizeof(blackGIF) freeWhenDone:NO];
UIImage *image = [[UIImage alloc] initWithData:data];
RCTPlatformImage *image = [[RCTPlatformImage alloc] initWithData:data]; // [macOS]

id<RCTImageDataDecoder> decoder1 = [[RCTImageLoaderTestsDecoder1 alloc] initWithPriority:1.0
canDecodeImageDataHandler:^BOOL(__unused NSData *imageData) {
Expand Down