mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-07 02:08:34 +08:00
Fix snapshottests under iOS10
Reviewed By: dinhviethoa Differential Revision: D3722988 fbshipit-source-id: 4345b757e28700ac61e1de38b61430e78948e58a
This commit is contained in:
committed by
Facebook Github Bot 7
parent
0da5fd21c7
commit
a0b3565847
@@ -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)]);
|
||||
}];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user