Fix snapshottests under iOS10

Reviewed By: dinhviethoa

Differential Revision: D3722988

fbshipit-source-id: 4345b757e28700ac61e1de38b61430e78948e58a
This commit is contained in:
Pieter De Baets 2016-08-17 10:37:01 -07:00 committed by Facebook Github Bot 7
parent 0da5fd21c7
commit a0b3565847
14 changed files with 27 additions and 10 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB

After

Width:  |  Height:  |  Size: 182 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 78 KiB

View File

@ -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
{

View File

@ -7,3 +7,8 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
var __fbBatchedBridge = {
flushedQueue: function() {
return null;
}
};

View File

@ -42,4 +42,6 @@ typedef NS_ENUM(NSInteger, RCTTestStatus) {
*/
@property (nonatomic, readonly) RCTTestStatus status;
@property (nonatomic, copy) NSString *testSuffix;
@end

View File

@ -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)]);
}];
}

View File

@ -35,6 +35,8 @@
*/
@property (nonatomic, assign) BOOL recordMode;
@property (nonatomic, copy) NSString *testSuffix;
@property (nonatomic, readonly) NSURL *scriptURL;
/**

View File

@ -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;