Clean up snapshot test cases (#3091)

* Clean up snapshot test cases:
- Drop 32bit snapshots
- Update iOS 9 snapshots and move some others to the correct directory
- Remove `setUp` overrides in subclasses of `ASLayoutSpecSnapshotTestCase` that set `recordMode` flag. Doing so in multiple places make it difficult to enable/dis
able the flag for all layout spec test cases. It can always be overridden locally if need
to.
- Fix BUCK build

* Fix testThatOnDidLoadThrowsIfCalledOnLoadedOffMain of ASDisplayNodeTests
This commit is contained in:
Huy Nguyen 2017-02-27 17:14:40 +00:00 committed by Adlai Holler
parent dc23aca30d
commit 421a896713
35 changed files with 17 additions and 46 deletions

View File

@ -313,7 +313,6 @@
CC0F88601E4280B800576FED /* _ASCollectionViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = CC0F885E1E4280B800576FED /* _ASCollectionViewCell.h */; settings = {ATTRIBUTES = (Private, ); }; };
CC0F88621E4281E200576FED /* ASSectionController.h in Headers */ = {isa = PBXBuildFile; fileRef = CCE04B1E1E313EA7006AEBBB /* ASSectionController.h */; settings = {ATTRIBUTES = (Public, ); }; };
CC0F88631E4281E700576FED /* ASSupplementaryNodeSource.h in Headers */ = {isa = PBXBuildFile; fileRef = CCE04B2B1E314A32006AEBBB /* ASSupplementaryNodeSource.h */; settings = {ATTRIBUTES = (Public, ); }; };
CC0F886B1E4286FA00576FED /* ReferenceImages_32 in Resources */ = {isa = PBXBuildFile; fileRef = CC0F88681E4286FA00576FED /* ReferenceImages_32 */; };
CC0F886C1E4286FA00576FED /* ReferenceImages_64 in Resources */ = {isa = PBXBuildFile; fileRef = CC0F88691E4286FA00576FED /* ReferenceImages_64 */; };
CC0F886D1E4286FA00576FED /* ReferenceImages_iOS_10 in Resources */ = {isa = PBXBuildFile; fileRef = CC0F886A1E4286FA00576FED /* ReferenceImages_iOS_10 */; };
CC11F97A1DB181180024D77B /* ASNetworkImageNodeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CC11F9791DB181180024D77B /* ASNetworkImageNodeTests.m */; };
@ -700,7 +699,6 @@
CC0F885A1E42807F00576FED /* ASCollectionViewFlowLayoutInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASCollectionViewFlowLayoutInspector.h; sourceTree = "<group>"; };
CC0F885D1E4280B800576FED /* _ASCollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _ASCollectionViewCell.m; sourceTree = "<group>"; };
CC0F885E1E4280B800576FED /* _ASCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _ASCollectionViewCell.h; sourceTree = "<group>"; };
CC0F88681E4286FA00576FED /* ReferenceImages_32 */ = {isa = PBXFileReference; lastKnownFileType = folder; path = ReferenceImages_32; sourceTree = "<group>"; };
CC0F88691E4286FA00576FED /* ReferenceImages_64 */ = {isa = PBXFileReference; lastKnownFileType = folder; path = ReferenceImages_64; sourceTree = "<group>"; };
CC0F886A1E4286FA00576FED /* ReferenceImages_iOS_10 */ = {isa = PBXFileReference; lastKnownFileType = folder; path = ReferenceImages_iOS_10; sourceTree = "<group>"; };
CC11F9791DB181180024D77B /* ASNetworkImageNodeTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASNetworkImageNodeTests.m; sourceTree = "<group>"; };
@ -1036,7 +1034,6 @@
058D09C6195D04C000B7D73C /* Supporting Files */ = {
isa = PBXGroup;
children = (
CC0F88681E4286FA00576FED /* ReferenceImages_32 */,
CC0F88691E4286FA00576FED /* ReferenceImages_64 */,
CC0F886A1E4286FA00576FED /* ReferenceImages_iOS_10 */,
058D09C7195D04C000B7D73C /* AsyncDisplayKitTests-Info.plist */,
@ -1671,7 +1668,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
CC0F886B1E4286FA00576FED /* ReferenceImages_32 in Resources */,
CC0F886C1E4286FA00576FED /* ReferenceImages_64 in Resources */,
CC0F886D1E4286FA00576FED /* ReferenceImages_iOS_10 in Resources */,
052EE06B1A15A0D8002C6279 /* TestResources in Resources */,

25
BUCK
View File

@ -43,7 +43,7 @@ def asyncdisplaykit_library(
apple_library(
name = name,
prefix_header = 'Source/AsyncDisplayKit-Prefix.pch',
header_path_prefix = 'Source',
header_path_prefix = 'AsyncDisplayKit',
exported_headers = ASYNCDISPLAYKIT_EXPORTED_HEADERS,
headers = ASYNCDISPLAYKIT_PRIVATE_HEADERS,
srcs = glob([
@ -58,8 +58,6 @@ def asyncdisplaykit_library(
'Photos',
'-weak_framework',
'MapKit',
'-weak_framework',
'AssetsLibrary',
],
deps = deps,
frameworks = [
@ -72,6 +70,9 @@ def asyncdisplaykit_library(
'$SDKROOT/System/Library/Frameworks/CoreGraphics.framework',
'$SDKROOT/System/Library/Frameworks/CoreLocation.framework',
'$SDKROOT/System/Library/Frameworks/AVFoundation.framework',
# TODO somehow AssetsLibrary can't be weak_framework
'$SDKROOT/System/Library/Frameworks/AssetsLibrary.framework',
] + additional_frameworks,
visibility = ['PUBLIC'],
)
@ -100,12 +101,6 @@ for name in ['AsyncDisplayKit', 'AsyncDisplayKit-PINRemoteImage']:
# Test Host
# TODO: Split to smaller BUCK files and parse in parallel
#####################################
apple_resource(
name = 'TestHostResources',
files = ['Default-568h@2x.png'],
dirs = [],
)
apple_bundle(
name = 'TestHost',
binary = ':TestHostBinary',
@ -120,14 +115,10 @@ apple_bundle(
apple_binary(
name = 'TestHostBinary',
headers = glob(['Tests/TestHost/*.h']),
srcs = glob([
'Tests/TestHost/*.m',
'Tests/TestHost/*.mm',
]),
srcs = glob(['Tests/TestHost/*.m']),
lang_preprocessor_flags = COMMON_LANG_PREPROCESSOR_FLAGS,
linker_flags = COMMON_LINKER_FLAGS,
deps = [
':TestHostResources',
':AsyncDisplayKit-Core',
],
frameworks = [
@ -158,10 +149,9 @@ apple_test(
'PRODUCT_BUNDLE_IDENTIFIER': 'com.facebook.AsyncDisplayKitTests',
},
prefix_header = 'Tests/AsyncDisplayKitTests-Prefix.pch',
header_path_prefix = 'AsyncDisplayKit',
# Expose all ASDK headers to tests
headers = ASYNCDISPLAYKIT_EXPORTED_HEADERS + ASYNCDISPLAYKIT_PRIVATE_HEADERS + glob([
'Tests/*.h',
]),
headers = ASYNCDISPLAYKIT_EXPORTED_HEADERS + ASYNCDISPLAYKIT_PRIVATE_HEADERS + glob(['Tests/*.h']),
srcs = glob([
'Tests/*.m',
'Tests/*.mm'
@ -172,6 +162,7 @@ apple_test(
snapshot_reference_images_path='Tests/ReferenceImages',
preprocessor_flags = COMMON_PREPROCESSOR_FLAGS + [
'-Wno-implicit-function-declaration',
'-Wno-deprecated-declarations',
],
lang_preprocessor_flags = COMMON_LANG_PREPROCESSOR_FLAGS,
linker_flags = COMMON_LINKER_FLAGS,

View File

@ -2149,12 +2149,9 @@ static bool stringContainsPointer(NSString *description, id p) {
{
ASTestDisplayNode *node = [[ASTestDisplayNode alloc] init];
[node view];
dispatch_semaphore_t sem = dispatch_semaphore_create(0);
[NSThread detachNewThreadWithBlock:^{
[self executeOffThread:^{
XCTAssertThrows([node onDidLoad:^(ASDisplayNode * _Nonnull node) { }]);
dispatch_semaphore_signal(sem);
}];
dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
}
- (void)testThatOnDidLoadWorks

View File

@ -17,6 +17,13 @@
@implementation ASImageNodeSnapshotTests
- (void)setUp
{
[super setUp];
self.recordMode = NO;
}
- (UIImage *)testImage
{
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"logo-square"

View File

@ -23,14 +23,6 @@ static const ASSizeRange kSize = {{100, 120}, {320, 160}};
#pragma mark - XCTestCase
- (void)setUp
{
[super setUp];
self.recordMode = NO;
}
- (void)testWithOptions
{
[self testAllVerticalPositionsForHorizontalPosition:ASRelativeLayoutSpecPositionStart];

View File

@ -21,16 +21,11 @@ NSOrderedSet *ASSnapshotTestCaseDefaultSuffixes(void)
// or on iOS 10 (text rasterization). If the test folders find any image that exactly matches,
// they pass; if an image is not present at all, or it fails, it moves on to check the others.
// This means the order doesn't matter besides reducing logging / performance.
[suffixesSet addObject:@"_32"];
[suffixesSet addObject:@"_64"];
if (AS_AT_LEAST_IOS10) {
[suffixesSet addObject:@"_iOS_10"];
}
#if __LP64__
return [suffixesSet reversedOrderedSet];
#else
[suffixesSet addObject:@"_64"];
return [suffixesSet copy];
#endif
}
@implementation ASSnapshotTestCase

View File

@ -17,13 +17,6 @@
@implementation ASWrapperSpecSnapshotTests
- (void)setUp
{
[super setUp];
self.recordMode = NO;
}
- (void)testWrapperSpecWithOneElementShouldSizeToElement
{
ASDisplayNode *child = ASDisplayNodeWithBackgroundColor([UIColor redColor], {50, 50});

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB