Skip to content

Commit 421a896

Browse files
nguyenhuyAdlai Holler
authored andcommitted
Clean up snapshot test cases (facebookarchive#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
1 parent dc23aca commit 421a896

35 files changed

Lines changed: 17 additions & 46 deletions

File tree

AsyncDisplayKit.xcodeproj/project.pbxproj

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,6 @@
313313
CC0F88601E4280B800576FED /* _ASCollectionViewCell.h in Headers */ = {isa = PBXBuildFile; fileRef = CC0F885E1E4280B800576FED /* _ASCollectionViewCell.h */; settings = {ATTRIBUTES = (Private, ); }; };
314314
CC0F88621E4281E200576FED /* ASSectionController.h in Headers */ = {isa = PBXBuildFile; fileRef = CCE04B1E1E313EA7006AEBBB /* ASSectionController.h */; settings = {ATTRIBUTES = (Public, ); }; };
315315
CC0F88631E4281E700576FED /* ASSupplementaryNodeSource.h in Headers */ = {isa = PBXBuildFile; fileRef = CCE04B2B1E314A32006AEBBB /* ASSupplementaryNodeSource.h */; settings = {ATTRIBUTES = (Public, ); }; };
316-
CC0F886B1E4286FA00576FED /* ReferenceImages_32 in Resources */ = {isa = PBXBuildFile; fileRef = CC0F88681E4286FA00576FED /* ReferenceImages_32 */; };
317316
CC0F886C1E4286FA00576FED /* ReferenceImages_64 in Resources */ = {isa = PBXBuildFile; fileRef = CC0F88691E4286FA00576FED /* ReferenceImages_64 */; };
318317
CC0F886D1E4286FA00576FED /* ReferenceImages_iOS_10 in Resources */ = {isa = PBXBuildFile; fileRef = CC0F886A1E4286FA00576FED /* ReferenceImages_iOS_10 */; };
319318
CC11F97A1DB181180024D77B /* ASNetworkImageNodeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = CC11F9791DB181180024D77B /* ASNetworkImageNodeTests.m */; };
@@ -700,7 +699,6 @@
700699
CC0F885A1E42807F00576FED /* ASCollectionViewFlowLayoutInspector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ASCollectionViewFlowLayoutInspector.h; sourceTree = "<group>"; };
701700
CC0F885D1E4280B800576FED /* _ASCollectionViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = _ASCollectionViewCell.m; sourceTree = "<group>"; };
702701
CC0F885E1E4280B800576FED /* _ASCollectionViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = _ASCollectionViewCell.h; sourceTree = "<group>"; };
703-
CC0F88681E4286FA00576FED /* ReferenceImages_32 */ = {isa = PBXFileReference; lastKnownFileType = folder; path = ReferenceImages_32; sourceTree = "<group>"; };
704702
CC0F88691E4286FA00576FED /* ReferenceImages_64 */ = {isa = PBXFileReference; lastKnownFileType = folder; path = ReferenceImages_64; sourceTree = "<group>"; };
705703
CC0F886A1E4286FA00576FED /* ReferenceImages_iOS_10 */ = {isa = PBXFileReference; lastKnownFileType = folder; path = ReferenceImages_iOS_10; sourceTree = "<group>"; };
706704
CC11F9791DB181180024D77B /* ASNetworkImageNodeTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ASNetworkImageNodeTests.m; sourceTree = "<group>"; };
@@ -1036,7 +1034,6 @@
10361034
058D09C6195D04C000B7D73C /* Supporting Files */ = {
10371035
isa = PBXGroup;
10381036
children = (
1039-
CC0F88681E4286FA00576FED /* ReferenceImages_32 */,
10401037
CC0F88691E4286FA00576FED /* ReferenceImages_64 */,
10411038
CC0F886A1E4286FA00576FED /* ReferenceImages_iOS_10 */,
10421039
058D09C7195D04C000B7D73C /* AsyncDisplayKitTests-Info.plist */,
@@ -1671,7 +1668,6 @@
16711668
isa = PBXResourcesBuildPhase;
16721669
buildActionMask = 2147483647;
16731670
files = (
1674-
CC0F886B1E4286FA00576FED /* ReferenceImages_32 in Resources */,
16751671
CC0F886C1E4286FA00576FED /* ReferenceImages_64 in Resources */,
16761672
CC0F886D1E4286FA00576FED /* ReferenceImages_iOS_10 in Resources */,
16771673
052EE06B1A15A0D8002C6279 /* TestResources in Resources */,

BUCK

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def asyncdisplaykit_library(
4343
apple_library(
4444
name = name,
4545
prefix_header = 'Source/AsyncDisplayKit-Prefix.pch',
46-
header_path_prefix = 'Source',
46+
header_path_prefix = 'AsyncDisplayKit',
4747
exported_headers = ASYNCDISPLAYKIT_EXPORTED_HEADERS,
4848
headers = ASYNCDISPLAYKIT_PRIVATE_HEADERS,
4949
srcs = glob([
@@ -58,8 +58,6 @@ def asyncdisplaykit_library(
5858
'Photos',
5959
'-weak_framework',
6060
'MapKit',
61-
'-weak_framework',
62-
'AssetsLibrary',
6361
],
6462
deps = deps,
6563
frameworks = [
@@ -72,6 +70,9 @@ def asyncdisplaykit_library(
7270
'$SDKROOT/System/Library/Frameworks/CoreGraphics.framework',
7371
'$SDKROOT/System/Library/Frameworks/CoreLocation.framework',
7472
'$SDKROOT/System/Library/Frameworks/AVFoundation.framework',
73+
74+
# TODO somehow AssetsLibrary can't be weak_framework
75+
'$SDKROOT/System/Library/Frameworks/AssetsLibrary.framework',
7576
] + additional_frameworks,
7677
visibility = ['PUBLIC'],
7778
)
@@ -100,12 +101,6 @@ for name in ['AsyncDisplayKit', 'AsyncDisplayKit-PINRemoteImage']:
100101
# Test Host
101102
# TODO: Split to smaller BUCK files and parse in parallel
102103
#####################################
103-
apple_resource(
104-
name = 'TestHostResources',
105-
files = ['Default-568h@2x.png'],
106-
dirs = [],
107-
)
108-
109104
apple_bundle(
110105
name = 'TestHost',
111106
binary = ':TestHostBinary',
@@ -120,14 +115,10 @@ apple_bundle(
120115
apple_binary(
121116
name = 'TestHostBinary',
122117
headers = glob(['Tests/TestHost/*.h']),
123-
srcs = glob([
124-
'Tests/TestHost/*.m',
125-
'Tests/TestHost/*.mm',
126-
]),
118+
srcs = glob(['Tests/TestHost/*.m']),
127119
lang_preprocessor_flags = COMMON_LANG_PREPROCESSOR_FLAGS,
128120
linker_flags = COMMON_LINKER_FLAGS,
129121
deps = [
130-
':TestHostResources',
131122
':AsyncDisplayKit-Core',
132123
],
133124
frameworks = [
@@ -158,10 +149,9 @@ apple_test(
158149
'PRODUCT_BUNDLE_IDENTIFIER': 'com.facebook.AsyncDisplayKitTests',
159150
},
160151
prefix_header = 'Tests/AsyncDisplayKitTests-Prefix.pch',
152+
header_path_prefix = 'AsyncDisplayKit',
161153
# Expose all ASDK headers to tests
162-
headers = ASYNCDISPLAYKIT_EXPORTED_HEADERS + ASYNCDISPLAYKIT_PRIVATE_HEADERS + glob([
163-
'Tests/*.h',
164-
]),
154+
headers = ASYNCDISPLAYKIT_EXPORTED_HEADERS + ASYNCDISPLAYKIT_PRIVATE_HEADERS + glob(['Tests/*.h']),
165155
srcs = glob([
166156
'Tests/*.m',
167157
'Tests/*.mm'
@@ -172,6 +162,7 @@ apple_test(
172162
snapshot_reference_images_path='Tests/ReferenceImages',
173163
preprocessor_flags = COMMON_PREPROCESSOR_FLAGS + [
174164
'-Wno-implicit-function-declaration',
165+
'-Wno-deprecated-declarations',
175166
],
176167
lang_preprocessor_flags = COMMON_LANG_PREPROCESSOR_FLAGS,
177168
linker_flags = COMMON_LINKER_FLAGS,

Tests/ASDisplayNodeTests.mm

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,12 +2149,9 @@ - (void)testThatOnDidLoadThrowsIfCalledOnLoadedOffMain
21492149
{
21502150
ASTestDisplayNode *node = [[ASTestDisplayNode alloc] init];
21512151
[node view];
2152-
dispatch_semaphore_t sem = dispatch_semaphore_create(0);
2153-
[NSThread detachNewThreadWithBlock:^{
2152+
[self executeOffThread:^{
21542153
XCTAssertThrows([node onDidLoad:^(ASDisplayNode * _Nonnull node) { }]);
2155-
dispatch_semaphore_signal(sem);
21562154
}];
2157-
dispatch_semaphore_wait(sem, DISPATCH_TIME_FOREVER);
21582155
}
21592156

21602157
- (void)testThatOnDidLoadWorks

Tests/ASImageNodeSnapshotTests.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ @interface ASImageNodeSnapshotTests : ASSnapshotTestCase
1717

1818
@implementation ASImageNodeSnapshotTests
1919

20+
- (void)setUp
21+
{
22+
[super setUp];
23+
24+
self.recordMode = NO;
25+
}
26+
2027
- (UIImage *)testImage
2128
{
2229
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"logo-square"

Tests/ASRelativeLayoutSpecSnapshotTests.mm

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@ @implementation ASRelativeLayoutSpecSnapshotTests
2323

2424
#pragma mark - XCTestCase
2525

26-
- (void)setUp
27-
{
28-
[super setUp];
29-
30-
self.recordMode = NO;
31-
}
32-
33-
3426
- (void)testWithOptions
3527
{
3628
[self testAllVerticalPositionsForHorizontalPosition:ASRelativeLayoutSpecPositionStart];

Tests/ASSnapshotTestCase.m

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,11 @@
2121
// or on iOS 10 (text rasterization). If the test folders find any image that exactly matches,
2222
// they pass; if an image is not present at all, or it fails, it moves on to check the others.
2323
// This means the order doesn't matter besides reducing logging / performance.
24-
[suffixesSet addObject:@"_32"];
25-
[suffixesSet addObject:@"_64"];
2624
if (AS_AT_LEAST_IOS10) {
2725
[suffixesSet addObject:@"_iOS_10"];
2826
}
29-
#if __LP64__
30-
return [suffixesSet reversedOrderedSet];
31-
#else
27+
[suffixesSet addObject:@"_64"];
3228
return [suffixesSet copy];
33-
#endif
3429
}
3530

3631
@implementation ASSnapshotTestCase

Tests/ASWrapperSpecSnapshotTests.mm

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,6 @@ @interface ASWrapperSpecSnapshotTests : ASLayoutSpecSnapshotTestCase
1717

1818
@implementation ASWrapperSpecSnapshotTests
1919

20-
- (void)setUp
21-
{
22-
[super setUp];
23-
24-
self.recordMode = NO;
25-
}
26-
2720
- (void)testWrapperSpecWithOneElementShouldSizeToElement
2821
{
2922
ASDisplayNode *child = ASDisplayNodeWithBackgroundColor([UIColor redColor], {50, 50});
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)