Fix snapshottests under iOS10
Reviewed By: dinhviethoa Differential Revision: D3722988 fbshipit-source-id: 4345b757e28700ac61e1de38b61430e78948e58a
After Width: | Height: | Size: 153 KiB |
After Width: | Height: | Size: 182 KiB |
Before Width: | Height: | Size: 67 KiB After Width: | Height: | Size: 182 KiB |
After Width: | Height: | Size: 147 KiB |
After Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 78 KiB |
After Width: | Height: | Size: 364 KiB |
After Width: | Height: | Size: 175 KiB |
|
@ -33,6 +33,9 @@
|
|||
- (void)setUp
|
||||
{
|
||||
_runner = RCTInitRunnerForApp(@"Examples/UIExplorer/js/UIExplorerApp.ios", nil);
|
||||
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 10) {
|
||||
_runner.testSuffix = @"-iOS10";
|
||||
}
|
||||
_runner.recordMode = NO;
|
||||
}
|
||||
|
||||
|
@ -46,8 +49,8 @@ RCT_TEST(ViewExample)
|
|||
RCT_TEST(LayoutExample)
|
||||
RCT_TEST(TextExample)
|
||||
RCT_TEST(SwitchExample)
|
||||
//RCT_TEST(SliderExample) // Disabled: #8985988
|
||||
//RCT_TEST(TabBarExample) // Disabled: #8985988
|
||||
RCT_TEST(SliderExample)
|
||||
RCT_TEST(TabBarExample)
|
||||
|
||||
- (void)testZZZNotInRecordMode
|
||||
{
|
||||
|
|
|
@ -7,3 +7,8 @@
|
|||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
var __fbBatchedBridge = {
|
||||
flushedQueue: function() {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -42,4 +42,6 @@ typedef NS_ENUM(NSInteger, RCTTestStatus) {
|
|||
*/
|
||||
@property (nonatomic, readonly) RCTTestStatus status;
|
||||
|
||||
@property (nonatomic, copy) NSString *testSuffix;
|
||||
|
||||
@end
|
||||
|
|
|
@ -15,9 +15,8 @@
|
|||
#import "RCTLog.h"
|
||||
#import "RCTUIManager.h"
|
||||
|
||||
@implementation RCTTestModule
|
||||
{
|
||||
NSMutableDictionary<NSString *, NSString *> *_snapshotCounter;
|
||||
@implementation RCTTestModule {
|
||||
NSMutableDictionary<NSString *, NSNumber *> *_snapshotCounter;
|
||||
}
|
||||
|
||||
@synthesize bridge = _bridge;
|
||||
|
@ -34,18 +33,23 @@ RCT_EXPORT_METHOD(verifySnapshot:(RCTResponseSenderBlock)callback)
|
|||
RCTAssert(_controller != nil, @"No snapshot controller configured.");
|
||||
|
||||
[_bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
|
||||
NSString *testName = NSStringFromSelector(self->_testSelector);
|
||||
if (!self->_snapshotCounter) {
|
||||
self->_snapshotCounter = [NSMutableDictionary new];
|
||||
}
|
||||
self->_snapshotCounter[testName] = (@([self->_snapshotCounter[testName] integerValue] + 1)).stringValue;
|
||||
|
||||
NSNumber *counter = @([self->_snapshotCounter[testName] integerValue] + 1);
|
||||
self->_snapshotCounter[testName] = counter;
|
||||
|
||||
NSError *error = nil;
|
||||
NSString *identifier = [counter stringValue];
|
||||
if (self->_testSuffix) {
|
||||
identifier = [identifier stringByAppendingString:self->_testSuffix];
|
||||
}
|
||||
BOOL success = [self->_controller compareSnapshotOfView:self->_view
|
||||
selector:self->_testSelector
|
||||
identifier:self->_snapshotCounter[testName]
|
||||
error:&error];
|
||||
selector:self->_testSelector
|
||||
identifier:identifier
|
||||
error:&error];
|
||||
callback(@[@(success)]);
|
||||
}];
|
||||
}
|
||||
|
|
|
@ -35,6 +35,8 @@
|
|||
*/
|
||||
@property (nonatomic, assign) BOOL recordMode;
|
||||
|
||||
@property (nonatomic, copy) NSString *testSuffix;
|
||||
|
||||
@property (nonatomic, readonly) NSURL *scriptURL;
|
||||
|
||||
/**
|
||||
|
|
|
@ -117,6 +117,7 @@ expectErrorBlock:(BOOL(^)(NSString *error))expectErrorBlock
|
|||
RCTAssert(_testController != nil, @"_testController should not be nil");
|
||||
testModule.controller = _testController;
|
||||
testModule.testSelector = test;
|
||||
testModule.testSuffix = _testSuffix;
|
||||
testModule.view = rootView;
|
||||
|
||||
UIViewController *vc = [UIApplication sharedApplication].delegate.window.rootViewController;
|
||||
|
|