Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
157 changes: 157 additions & 0 deletions AsyncDisplayKit.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions AsyncDisplayKitTestHost/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@end
17 changes: 17 additions & 0 deletions AsyncDisplayKitTestHost/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

#import "AppDelegate.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
return YES;
}

@end
36 changes: 36 additions & 0 deletions AsyncDisplayKitTestHost/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>com.facebook.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
16 changes: 16 additions & 0 deletions AsyncDisplayKitTestHost/main.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

#import <UIKit/UIKit.h>
#import "AppDelegate.h"

int main(int argc, char * argv[]) {
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
}
}
35 changes: 35 additions & 0 deletions AsyncDisplayKitTests/ASImageNodeSnapshotTests.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

#import "ASSnapshotTestCase.h"

#import <AsyncDisplayKit/AsyncDisplayKit.h>

@interface ASImageNodeSnapshotTests : ASSnapshotTestCase
@end

@implementation ASImageNodeSnapshotTests

- (UIImage *)testImage
{
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"logo-square"
ofType:@"png" inDirectory:@"TestResources"];
return [UIImage imageWithContentsOfFile:path];
}

- (void)testRenderLogoSquare
{
// trivial test case to ensure ASSnapshotTestCase works
ASImageNode *imageNode = [[ASImageNode alloc] init];
imageNode.image = [self testImage];
imageNode.frame = CGRectMake(0, 0, 100, 100);

ASSnapshotVerifyNode(imageNode, nil);
}

@end
26 changes: 26 additions & 0 deletions AsyncDisplayKitTests/ASSnapshotTestCase.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

#import "FBSnapshotTestCase.h"

#import <AsyncDisplayKit/ASDisplayNode.h>

#define ASSnapshotVerifyNode(node__, identifier__) \
{ \
[ASSnapshotTestCase hackilySynchronouslyRecursivelyRenderNode:node__]; \
FBSnapshotVerifyLayer(node__.layer, identifier__); \
}

@interface ASSnapshotTestCase : FBSnapshotTestCase

/**
* Hack for testing. ASDisplayNode lacks an explicit -render method, so we manually hit its layout & display codepaths.
*/
+ (void)hackilySynchronouslyRecursivelyRenderNode:(ASDisplayNode *)node;

@end
54 changes: 54 additions & 0 deletions AsyncDisplayKitTests/ASSnapshotTestCase.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

#import "ASSnapshotTestCase.h"

#import <AsyncDisplayKit/ASDisplayNodeInternal.h>

@implementation ASSnapshotTestCase

+ (void)_layoutAndDisplayNode:(ASDisplayNode *)node
{
if (![node __shouldLoadViewOrLayer]) {
return;
}

CALayer *layer = node.layer;

[layer setNeedsLayout];
[layer layoutIfNeeded];

[layer setNeedsDisplay];
[layer displayIfNeeded];
}

+ (void)_recursivelyLayoutAndDisplayNode:(ASDisplayNode *)node
{
for (ASDisplayNode *subnode in node.subnodes) {
[self _recursivelyLayoutAndDisplayNode:subnode];
}

[self _layoutAndDisplayNode:node];
}

+ (void)_recursivelySetDisplaysAsynchronously:(BOOL)flag forNode:(ASDisplayNode *)node
{
node.displaysAsynchronously = flag;

for (ASDisplayNode *subnode in node.subnodes) {
subnode.displaysAsynchronously = flag;
}
}

+ (void)hackilySynchronouslyRecursivelyRenderNode:(ASDisplayNode *)node
{
[self _recursivelySetDisplaysAsynchronously:NO forNode:node];
[self _recursivelyLayoutAndDisplayNode:node];
}

@end
2 changes: 1 addition & 1 deletion AsyncDisplayKitTests/ASTableViewTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ @interface ASTableViewTests : XCTestCase

@implementation ASTableViewTests

- (void)testTableViewDoesNotRetainItselfAndDelegate
- (void)DISABLED_testTableViewDoesNotRetainItselfAndDelegate
{
ASTestTableView *tableView = [[ASTestTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ platform :ios, '7.0'

target :'AsyncDisplayKitTests', :exclusive => true do
pod 'OCMock', '~> 2.2'
pod 'FBSnapshotTestCase'
end
3 changes: 3 additions & 0 deletions Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
PODS:
- FBSnapshotTestCase (1.5)
- OCMock (2.2.4)

DEPENDENCIES:
- FBSnapshotTestCase
- OCMock (~> 2.2)

SPEC CHECKSUMS:
FBSnapshotTestCase: e2914fbaabccea1dcc773d6a16b1c24540642488
OCMock: 6db79185520e24f9f299548f2b8b07e41d881bd5

COCOAPODS: 0.35.0