Skip to content

Commit

Permalink
Remove RCTImageLoader diff
Browse files Browse the repository at this point in the history
  • Loading branch information
Saadnajmi committed Aug 21, 2024
1 parent 0b0c12f commit 1096580
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 17 deletions.
1 change: 0 additions & 1 deletion packages/react-native/Libraries/Image/RCTImageLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
- (instancetype)initWithRedirectDelegate:(id<RCTImageRedirectProtocol>)redirectDelegate
loadersProvider:(NSArray<id<RCTImageURLLoader>> * (^)(RCTModuleRegistry *))getLoaders
decodersProvider:(NSArray<id<RCTImageDataDecoder>> * (^)(RCTModuleRegistry *))getDecoders;
- (NSInteger)activeTasks; // [macOS]
@end

/**
Expand Down
6 changes: 0 additions & 6 deletions packages/react-native/Libraries/Image/RCTImageLoader.mm
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,6 @@ - (void)dequeueTasks
});
}

// [macOS
- (NSInteger)activeTasks {
return _activeTasks;
}
// macOS]

/**
* This returns either an image, or raw image data, depending on the loading
* path taken. This is useful if you want to skip decoding, e.g. when preloading
Expand Down
21 changes: 11 additions & 10 deletions packages/rn-tester/RCTTest/RCTTestRunner.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
#import <React/RCTBridge+Private.h>
#import <React/RCTConstants.h>
#import <React/RCTDevSettings.h>
#import <React/RCTImageLoader.h> // [macOS]
#import <React/RCTLog.h>
#import <React/RCTRootView.h>
#import <React/RCTUIManager.h>
#import <React/RCTUtils.h>
#import <React/RCTUIKit.h> // [macOS]

#import "FBSnapshotTestController.h"
#import "RCTTestModule.h"
Expand Down Expand Up @@ -192,7 +192,9 @@ - (void)runTest:(SEL)test
#if !TARGET_OS_OSX // [macOS]
UIViewController *vc = RCTSharedApplication().delegate.window.rootViewController;
vc.view = [UIView new];
#endif // [macOS]
#else // [macOS
NSViewController *vc = RCTSharedApplication().mainWindow.contentViewController;
#endif // macOS]

RCTTestModule *testModule = [bridge moduleForClass:[RCTTestModule class]];
RCTAssert(_testController != nil, @"_testController should not be nil");
Expand All @@ -210,20 +212,15 @@ - (void)runTest:(SEL)test
rootTag = rootView.reactTag;
testModule.view = rootView;

#if !TARGET_OS_OSX // [macOS]
[vc.view addSubview:rootView]; // Add as subview so it doesn't get resized
#endif // [macOS]

if (configurationBlock) {
configurationBlock(rootView);
}

RCTImageLoader *imageLoader = [bridge moduleForClass:[RCTImageLoader class]]; // [macOS]

NSDate *date = [NSDate dateWithTimeIntervalSinceNow:kTestTimeoutSeconds];
while (date.timeIntervalSinceNow > 0 &&
(testModule.status == RCTTestStatusPending || [imageLoader activeTasks] > 0) &&
errors == nil) { // [macOS]
while (date.timeIntervalSinceNow > 0 && testModule.status == RCTTestStatusPending && errors == nil) {
[[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
[[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]];
}
Expand All @@ -244,10 +241,14 @@ - (void)runTest:(SEL)test
}
});

#if RCT_DEV && !TARGET_OS_OSX // [macOS]
NSArray<UIView *> *nonLayoutSubviews = [vc.view.subviews
#if RCT_DEV //&& !TARGET_OS_OSX // [macOS]
NSArray<RCTPlatformView *> *nonLayoutSubviews = [vc.view.subviews // [macOS]
filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id subview, NSDictionary *bindings) {
#if !TARGET_OS_OSX // [macOS]
return ![NSStringFromClass([subview class]) isEqualToString:@"_UILayoutGuide"];
#else // [macOS
return ![NSStringFromClass([subview class]) isEqualToString:@"_NSLayoutGuide"];
#endif // macOS]
}]];

RCTAssert(nonLayoutSubviews.count == 0, @"There shouldn't be any other views: %@", nonLayoutSubviews);
Expand Down

0 comments on commit 1096580

Please sign in to comment.