Merged branch 'master' into AVPlayerItem-construction
@@ -13,7 +13,6 @@
|
||||
#import "ASBackgroundLayoutSpec.h"
|
||||
#import "ASCenterLayoutSpec.h"
|
||||
#import "ASStackLayoutSpec.h"
|
||||
#import "ASLayoutOptions.h"
|
||||
|
||||
static const ASSizeRange kSize = {{100, 120}, {320, 160}};
|
||||
|
||||
@@ -38,10 +37,14 @@ static const ASSizeRange kSize = {{100, 120}, {320, 160}};
|
||||
|
||||
- (void)testWithSizingOptions
|
||||
{
|
||||
[self testWithCenteringOptions:ASCenterLayoutSpecCenteringNone sizingOptions:ASCenterLayoutSpecSizingOptionDefault];
|
||||
[self testWithCenteringOptions:ASCenterLayoutSpecCenteringNone sizingOptions:ASCenterLayoutSpecSizingOptionMinimumX];
|
||||
[self testWithCenteringOptions:ASCenterLayoutSpecCenteringNone sizingOptions:ASCenterLayoutSpecSizingOptionMinimumY];
|
||||
[self testWithCenteringOptions:ASCenterLayoutSpecCenteringNone sizingOptions:ASCenterLayoutSpecSizingOptionMinimumXY];
|
||||
[self testWithCenteringOptions:ASCenterLayoutSpecCenteringNone
|
||||
sizingOptions:ASCenterLayoutSpecSizingOptionDefault];
|
||||
[self testWithCenteringOptions:ASCenterLayoutSpecCenteringNone
|
||||
sizingOptions:ASCenterLayoutSpecSizingOptionMinimumX];
|
||||
[self testWithCenteringOptions:ASCenterLayoutSpecCenteringNone
|
||||
sizingOptions:ASCenterLayoutSpecSizingOptionMinimumY];
|
||||
[self testWithCenteringOptions:ASCenterLayoutSpecCenteringNone
|
||||
sizingOptions:ASCenterLayoutSpecSizingOptionMinimumXY];
|
||||
}
|
||||
|
||||
- (void)testWithCenteringOptions:(ASCenterLayoutSpecCenteringOptions)options
|
||||
@@ -51,14 +54,7 @@ static const ASSizeRange kSize = {{100, 120}, {320, 160}};
|
||||
ASStaticSizeDisplayNode *foregroundNode = ASDisplayNodeWithBackgroundColor([UIColor greenColor]);
|
||||
foregroundNode.staticSize = {70, 100};
|
||||
|
||||
ASLayoutSpec *layoutSpec =
|
||||
[ASBackgroundLayoutSpec
|
||||
backgroundLayoutSpecWithChild:
|
||||
[ASCenterLayoutSpec
|
||||
centerLayoutSpecWithCenteringOptions:options
|
||||
sizingOptions:sizingOptions
|
||||
child:foregroundNode]
|
||||
background:backgroundNode];
|
||||
ASLayoutSpec *layoutSpec = [ASBackgroundLayoutSpec backgroundLayoutSpecWithChild:[ASCenterLayoutSpec centerLayoutSpecWithCenteringOptions:options sizingOptions:sizingOptions child:foregroundNode]background:backgroundNode];
|
||||
|
||||
[self testLayoutSpec:layoutSpec
|
||||
sizeRange:kSize
|
||||
@@ -97,14 +93,7 @@ static NSString *suffixForCenteringOptions(ASCenterLayoutSpecCenteringOptions ce
|
||||
foregroundNode.staticSize = {10, 10};
|
||||
foregroundNode.flexGrow = YES;
|
||||
|
||||
ASCenterLayoutSpec *layoutSpec =
|
||||
[ASCenterLayoutSpec
|
||||
centerLayoutSpecWithCenteringOptions:ASCenterLayoutSpecCenteringNone
|
||||
sizingOptions:{}
|
||||
child:
|
||||
[ASBackgroundLayoutSpec
|
||||
backgroundLayoutSpecWithChild:[ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionVertical spacing:0 justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsStart children:@[foregroundNode]]
|
||||
background:backgroundNode]];
|
||||
ASCenterLayoutSpec *layoutSpec = [ASCenterLayoutSpec centerLayoutSpecWithCenteringOptions:ASCenterLayoutSpecCenteringNone sizingOptions:{} child:[ASBackgroundLayoutSpec backgroundLayoutSpecWithChild:[ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionVertical spacing:0 justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsStart children:@[foregroundNode]] background:backgroundNode]];
|
||||
|
||||
[self testLayoutSpec:layoutSpec sizeRange:kSize subnodes:@[backgroundNode, foregroundNode] identifier:nil];
|
||||
}
|
||||
|
||||
@@ -106,6 +106,76 @@
|
||||
XCTAssert(controller.hits == 1, @"Controller did not receive the action event");
|
||||
}
|
||||
|
||||
- (void)testRemoveWithoutTargetRemovesTargetlessAction {
|
||||
ASActionSenderEventController *controller = [[ASActionSenderEventController alloc] init];
|
||||
ASControlNode *node = [[ASControlNode alloc] init];
|
||||
[node addTarget:nil action:ACTION_SENDER_EVENT forControlEvents:EVENT];
|
||||
[node removeTarget:nil action:ACTION_SENDER_EVENT forControlEvents:EVENT];
|
||||
[controller.view addSubview:node.view];
|
||||
[node sendActionsForControlEvents:EVENT withEvent:nil];
|
||||
XCTAssertEqual(controller.hits, 0, @"Controller did not receive exactly zero action events");
|
||||
}
|
||||
|
||||
- (void)testRemoveWithTarget {
|
||||
ASActionSenderEventController *controller = [[ASActionSenderEventController alloc] init];
|
||||
ASControlNode *node = [[ASControlNode alloc] init];
|
||||
[node addTarget:controller action:ACTION_SENDER_EVENT forControlEvents:EVENT];
|
||||
[node removeTarget:controller action:ACTION_SENDER_EVENT forControlEvents:EVENT];
|
||||
[controller.view addSubview:node.view];
|
||||
[node sendActionsForControlEvents:EVENT withEvent:nil];
|
||||
XCTAssertEqual(controller.hits, 0, @"Controller did not receive exactly zero action events");
|
||||
}
|
||||
|
||||
- (void)testRemoveWithTargetRemovesAction {
|
||||
ASActionSenderEventController *controller = [[ASActionSenderEventController alloc] init];
|
||||
ASControlNode *node = [[ASControlNode alloc] init];
|
||||
[node addTarget:controller action:ACTION_SENDER_EVENT forControlEvents:EVENT];
|
||||
[node removeTarget:controller action:ACTION_SENDER_EVENT forControlEvents:EVENT];
|
||||
[controller.view addSubview:node.view];
|
||||
[node sendActionsForControlEvents:EVENT withEvent:nil];
|
||||
XCTAssertEqual(controller.hits, 0, @"Controller did not receive exactly zero action events");
|
||||
}
|
||||
|
||||
- (void)testRemoveWithoutTargetRemovesTargetedAction {
|
||||
ASActionSenderEventController *controller = [[ASActionSenderEventController alloc] init];
|
||||
ASControlNode *node = [[ASControlNode alloc] init];
|
||||
[node addTarget:controller action:ACTION_SENDER_EVENT forControlEvents:EVENT];
|
||||
[node removeTarget:nil action:ACTION_SENDER_EVENT forControlEvents:EVENT];
|
||||
[controller.view addSubview:node.view];
|
||||
[node sendActionsForControlEvents:EVENT withEvent:nil];
|
||||
XCTAssertEqual(controller.hits, 0, @"Controller did not receive exactly zero action events");
|
||||
}
|
||||
|
||||
- (void)testDuplicateEntriesWithoutTarget {
|
||||
ASActionSenderEventController *controller = [[ASActionSenderEventController alloc] init];
|
||||
ASControlNode *node = [[ASControlNode alloc] init];
|
||||
[node addTarget:nil action:ACTION_SENDER_EVENT forControlEvents:EVENT];
|
||||
[node addTarget:nil action:ACTION_SENDER_EVENT forControlEvents:EVENT];
|
||||
[controller.view addSubview:node.view];
|
||||
[node sendActionsForControlEvents:EVENT withEvent:nil];
|
||||
XCTAssertEqual(controller.hits, 1, @"Controller did not receive exactly one action event");
|
||||
}
|
||||
|
||||
- (void)testDuplicateEntriesWithTarget {
|
||||
ASActionSenderEventController *controller = [[ASActionSenderEventController alloc] init];
|
||||
ASControlNode *node = [[ASControlNode alloc] init];
|
||||
[node addTarget:controller action:ACTION_SENDER_EVENT forControlEvents:EVENT];
|
||||
[node addTarget:controller action:ACTION_SENDER_EVENT forControlEvents:EVENT];
|
||||
[controller.view addSubview:node.view];
|
||||
[node sendActionsForControlEvents:EVENT withEvent:nil];
|
||||
XCTAssertEqual(controller.hits, 1, @"Controller did not receive exactly one action event");
|
||||
}
|
||||
|
||||
- (void)testDuplicateEntriesWithAndWithoutTarget {
|
||||
ASActionSenderEventController *controller = [[ASActionSenderEventController alloc] init];
|
||||
ASControlNode *node = [[ASControlNode alloc] init];
|
||||
[node addTarget:controller action:ACTION_SENDER_EVENT forControlEvents:EVENT];
|
||||
[node addTarget:nil action:ACTION_SENDER_EVENT forControlEvents:EVENT];
|
||||
[controller.view addSubview:node.view];
|
||||
[node sendActionsForControlEvents:EVENT withEvent:nil];
|
||||
XCTAssertEqual(controller.hits, 2, @"Controller did not receive exactly two action events");
|
||||
}
|
||||
|
||||
- (void)testDeeperHierarchyWithoutTarget {
|
||||
ASActionController *controller = [[ASActionController alloc] init];
|
||||
UIView *view = [[UIView alloc] init];
|
||||
|
||||
129
AsyncDisplayKitTests/ASRelativeLayoutSpecSnapshotTests.mm
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
* 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 "ASLayoutSpecSnapshotTestsHelper.h"
|
||||
|
||||
#import "ASBackgroundLayoutSpec.h"
|
||||
#import "ASRelativeLayoutSpec.h"
|
||||
#import "ASStackLayoutSpec.h"
|
||||
|
||||
static const ASSizeRange kSize = {{100, 120}, {320, 160}};
|
||||
|
||||
@interface ASRelativeLayoutSpecSnapshotTests : ASLayoutSpecSnapshotTestCase
|
||||
@end
|
||||
|
||||
@implementation ASRelativeLayoutSpecSnapshotTests
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
[super setUp];
|
||||
self.recordMode = NO;
|
||||
}
|
||||
|
||||
- (void)testWithOptions
|
||||
{
|
||||
|
||||
[self testAllVerticalPositionsForHorizontalPosition:ASRelativeLayoutSpecPositionStart];
|
||||
[self testAllVerticalPositionsForHorizontalPosition:ASRelativeLayoutSpecPositionCenter];
|
||||
[self testAllVerticalPositionsForHorizontalPosition:ASRelativeLayoutSpecPositionEnd];
|
||||
|
||||
}
|
||||
|
||||
- (void)testAllVerticalPositionsForHorizontalPosition:(ASRelativeLayoutSpecPosition)horizontalPosition {
|
||||
[self testWithHorizontalPosition:horizontalPosition verticalPosition:ASRelativeLayoutSpecPositionStart sizingOptions:{}];
|
||||
[self testWithHorizontalPosition:horizontalPosition verticalPosition:ASRelativeLayoutSpecPositionCenter sizingOptions:{}];
|
||||
[self testWithHorizontalPosition:horizontalPosition verticalPosition:ASRelativeLayoutSpecPositionEnd sizingOptions:{}];
|
||||
}
|
||||
|
||||
- (void)testWithSizingOptions
|
||||
{
|
||||
[self testWithHorizontalPosition:ASRelativeLayoutSpecPositionStart
|
||||
verticalPosition:ASRelativeLayoutSpecPositionStart
|
||||
sizingOptions:ASRelativeLayoutSpecSizingOptionDefault];
|
||||
[self testWithHorizontalPosition:ASRelativeLayoutSpecPositionStart
|
||||
verticalPosition:ASRelativeLayoutSpecPositionStart
|
||||
sizingOptions:ASRelativeLayoutSpecSizingOptionMinimumWidth];
|
||||
[self testWithHorizontalPosition:ASRelativeLayoutSpecPositionStart
|
||||
verticalPosition:ASRelativeLayoutSpecPositionStart
|
||||
sizingOptions:ASRelativeLayoutSpecSizingOptionMinimumHeight];
|
||||
[self testWithHorizontalPosition:ASRelativeLayoutSpecPositionStart
|
||||
verticalPosition:ASRelativeLayoutSpecPositionStart
|
||||
sizingOptions:ASRelativeLayoutSpecSizingOptionMinimumSize];
|
||||
}
|
||||
|
||||
- (void)testWithHorizontalPosition:(ASRelativeLayoutSpecPosition)horizontalPosition
|
||||
verticalPosition:(ASRelativeLayoutSpecPosition)verticalPosition
|
||||
sizingOptions:(ASRelativeLayoutSpecSizingOption)sizingOptions
|
||||
{
|
||||
ASDisplayNode *backgroundNode = ASDisplayNodeWithBackgroundColor([UIColor redColor]);
|
||||
ASStaticSizeDisplayNode *foregroundNode = ASDisplayNodeWithBackgroundColor([UIColor greenColor]);
|
||||
foregroundNode.staticSize = {70, 100};
|
||||
|
||||
ASLayoutSpec *layoutSpec =
|
||||
[ASBackgroundLayoutSpec
|
||||
backgroundLayoutSpecWithChild:
|
||||
[ASRelativeLayoutSpec
|
||||
relativePositionLayoutSpecWithHorizontalPosition:horizontalPosition verticalPosition:verticalPosition sizingOption:sizingOptions child:foregroundNode]
|
||||
background:backgroundNode];
|
||||
|
||||
[self testLayoutSpec:layoutSpec
|
||||
sizeRange:kSize
|
||||
subnodes:@[backgroundNode, foregroundNode]
|
||||
identifier:suffixForPositionOptions(horizontalPosition, verticalPosition, sizingOptions)];
|
||||
}
|
||||
|
||||
static NSString *suffixForPositionOptions(ASRelativeLayoutSpecPosition horizontalPosition,
|
||||
ASRelativeLayoutSpecPosition verticalPosition,
|
||||
ASRelativeLayoutSpecSizingOption sizingOptions)
|
||||
{
|
||||
NSMutableString *suffix = [NSMutableString string];
|
||||
|
||||
if ((horizontalPosition & ASRelativeLayoutSpecPositionCenter) != 0) {
|
||||
[suffix appendString:@"CenterX"];
|
||||
} else if ((horizontalPosition & ASRelativeLayoutSpecPositionEnd) != 0) {
|
||||
[suffix appendString:@"EndX"];
|
||||
}
|
||||
|
||||
if ((verticalPosition & ASRelativeLayoutSpecPositionCenter) != 0) {
|
||||
[suffix appendString:@"CenterY"];
|
||||
} else if ((verticalPosition & ASRelativeLayoutSpecPositionEnd) != 0) {
|
||||
[suffix appendString:@"EndY"];
|
||||
}
|
||||
|
||||
if ((sizingOptions & ASRelativeLayoutSpecSizingOptionMinimumWidth) != 0) {
|
||||
[suffix appendString:@"SizingMinimumWidth"];
|
||||
}
|
||||
|
||||
if ((sizingOptions & ASRelativeLayoutSpecSizingOptionMinimumHeight) != 0) {
|
||||
[suffix appendString:@"SizingMinimumHeight"];
|
||||
}
|
||||
|
||||
return suffix;
|
||||
}
|
||||
|
||||
- (void)testMinimumSizeRangeIsGivenToChildWhenNotPositioning
|
||||
{
|
||||
ASDisplayNode *backgroundNode = ASDisplayNodeWithBackgroundColor([UIColor redColor]);
|
||||
ASStaticSizeDisplayNode *foregroundNode = ASDisplayNodeWithBackgroundColor([UIColor redColor]);
|
||||
foregroundNode.staticSize = {10, 10};
|
||||
foregroundNode.flexGrow = YES;
|
||||
|
||||
ASLayoutSpec *childSpec = [ASBackgroundLayoutSpec
|
||||
backgroundLayoutSpecWithChild:[ASStackLayoutSpec stackLayoutSpecWithDirection:ASStackLayoutDirectionVertical spacing:0 justifyContent:ASStackLayoutJustifyContentStart alignItems:ASStackLayoutAlignItemsStart children:@[foregroundNode]]
|
||||
background:backgroundNode];
|
||||
|
||||
ASRelativeLayoutSpec *layoutSpec = [ASRelativeLayoutSpec
|
||||
relativePositionLayoutSpecWithHorizontalPosition:ASRelativeLayoutSpecPositionStart verticalPosition:ASRelativeLayoutSpecPositionStart sizingOption:{} child:childSpec];
|
||||
|
||||
|
||||
[self testLayoutSpec:layoutSpec sizeRange:kSize subnodes:@[backgroundNode, foregroundNode] identifier:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -15,7 +15,6 @@
|
||||
#import "ASBackgroundLayoutSpec.h"
|
||||
#import "ASRatioLayoutSpec.h"
|
||||
#import "ASInsetLayoutSpec.h"
|
||||
#import "ASLayoutOptions.h"
|
||||
|
||||
@interface ASStackLayoutSpecSnapshotTests : ASLayoutSpecSnapshotTestCase
|
||||
@end
|
||||
@@ -606,19 +605,19 @@ static NSArray *defaultSubnodesWithSameSize(CGSize subnodeSize, BOOL flex)
|
||||
|
||||
- (void)testHorizontalAndVerticalAlignments
|
||||
{
|
||||
[self testStackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal itemsHorizontalAlignment:ASAlignmentLeft itemsVerticalAlignment:ASAlignmentTop identifier:@"horizontalTopLeft"];
|
||||
[self testStackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal itemsHorizontalAlignment:ASAlignmentMiddle itemsVerticalAlignment:ASAlignmentCenter identifier:@"horizontalCenter"];
|
||||
[self testStackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal itemsHorizontalAlignment:ASAlignmentRight itemsVerticalAlignment:ASAlignmentBottom identifier:@"horizontalBottomRight"];
|
||||
[self testStackLayoutSpecWithDirection:ASStackLayoutDirectionVertical itemsHorizontalAlignment:ASAlignmentLeft itemsVerticalAlignment:ASAlignmentTop identifier:@"verticalTopLeft"];
|
||||
[self testStackLayoutSpecWithDirection:ASStackLayoutDirectionVertical itemsHorizontalAlignment:ASAlignmentMiddle itemsVerticalAlignment:ASAlignmentCenter identifier:@"verticalCenter"];
|
||||
[self testStackLayoutSpecWithDirection:ASStackLayoutDirectionVertical itemsHorizontalAlignment:ASAlignmentRight itemsVerticalAlignment:ASAlignmentBottom identifier:@"verticalBottomRight"];
|
||||
[self testStackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal itemsHorizontalAlignment:ASHorizontalAlignmentLeft itemsVerticalAlignment:ASVerticalAlignmentTop identifier:@"horizontalTopLeft"];
|
||||
[self testStackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal itemsHorizontalAlignment:ASHorizontalAlignmentMiddle itemsVerticalAlignment:ASVerticalAlignmentCenter identifier:@"horizontalCenter"];
|
||||
[self testStackLayoutSpecWithDirection:ASStackLayoutDirectionHorizontal itemsHorizontalAlignment:ASHorizontalAlignmentRight itemsVerticalAlignment:ASVerticalAlignmentBottom identifier:@"horizontalBottomRight"];
|
||||
[self testStackLayoutSpecWithDirection:ASStackLayoutDirectionVertical itemsHorizontalAlignment:ASHorizontalAlignmentLeft itemsVerticalAlignment:ASVerticalAlignmentTop identifier:@"verticalTopLeft"];
|
||||
[self testStackLayoutSpecWithDirection:ASStackLayoutDirectionVertical itemsHorizontalAlignment:ASHorizontalAlignmentMiddle itemsVerticalAlignment:ASVerticalAlignmentCenter identifier:@"verticalCenter"];
|
||||
[self testStackLayoutSpecWithDirection:ASStackLayoutDirectionVertical itemsHorizontalAlignment:ASHorizontalAlignmentRight itemsVerticalAlignment:ASVerticalAlignmentBottom identifier:@"verticalBottomRight"];
|
||||
}
|
||||
|
||||
- (void)testDirectionChangeAfterSettingHorizontalAndVerticalAlignments
|
||||
{
|
||||
ASStackLayoutSpec *stackLayoutSpec = [[ASStackLayoutSpec alloc] init]; // Default direction is horizontal
|
||||
stackLayoutSpec.horizontalAlignment = ASAlignmentRight;
|
||||
stackLayoutSpec.verticalAlignment = ASAlignmentCenter;
|
||||
stackLayoutSpec.horizontalAlignment = ASHorizontalAlignmentRight;
|
||||
stackLayoutSpec.verticalAlignment = ASVerticalAlignmentCenter;
|
||||
XCTAssertEqual(stackLayoutSpec.alignItems, ASStackLayoutAlignItemsCenter);
|
||||
XCTAssertEqual(stackLayoutSpec.justifyContent, ASStackLayoutJustifyContentEnd);
|
||||
|
||||
@@ -636,8 +635,8 @@ static NSArray *defaultSubnodesWithSameSize(CGSize subnodeSize, BOOL flex)
|
||||
stackLayoutSpec.justifyContent = ASStackLayoutJustifyContentEnd;
|
||||
|
||||
// Set alignments and assert that assertions are thrown
|
||||
stackLayoutSpec.horizontalAlignment = ASAlignmentMiddle;
|
||||
stackLayoutSpec.verticalAlignment = ASAlignmentCenter;
|
||||
stackLayoutSpec.horizontalAlignment = ASHorizontalAlignmentMiddle;
|
||||
stackLayoutSpec.verticalAlignment = ASVerticalAlignmentCenter;
|
||||
XCTAssertThrows(stackLayoutSpec.alignItems = ASStackLayoutAlignItemsEnd);
|
||||
XCTAssertThrows(stackLayoutSpec.justifyContent = ASStackLayoutJustifyContentEnd);
|
||||
|
||||
|
||||
@@ -144,18 +144,6 @@
|
||||
|
||||
@implementation ASTableViewTests
|
||||
|
||||
- (void)setUp
|
||||
{
|
||||
/// Load a display node before the first test.
|
||||
/// Without this, running this suite specifically
|
||||
/// (as opposed to all tests) will cause a deadlock
|
||||
/// because of the dispatch_sync in `ASScreenScale()`.
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
[ASDisplayNode new];
|
||||
});
|
||||
}
|
||||
|
||||
// TODO: Convert this to ARC.
|
||||
- (void)DISABLED_testTableViewDoesNotRetainItselfAndDelegate
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#import <XCTest/XCTest.h>
|
||||
|
||||
#import "ASTextKitHelpers.h"
|
||||
#import "ASTextKitComponents.h"
|
||||
#import "ASTextNodeTypes.h"
|
||||
#import "ASTextNodeWordKerner.h"
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <XCTest/XCTest.h>
|
||||
#import "ASVideoNode.h"
|
||||
#import <AVFoundation/AVFoundation.h>
|
||||
#import <AsyncDisplayKit/AsyncDisplayKit.h>
|
||||
|
||||
@interface ASVideoNodeTests : XCTestCase
|
||||
{
|
||||
@@ -21,6 +22,7 @@
|
||||
|
||||
@interface ASVideoNode () {
|
||||
ASDisplayNode *_playerNode;
|
||||
AVPlayer *_player;
|
||||
}
|
||||
@property (atomic) ASInterfaceState interfaceState;
|
||||
@property (atomic) ASDisplayNode *spinner;
|
||||
@@ -37,6 +39,11 @@
|
||||
_playerNode = playerNode;
|
||||
}
|
||||
|
||||
- (void)setPlayer:(AVPlayer *)player
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation ASVideoNodeTests
|
||||
@@ -189,7 +196,7 @@
|
||||
- (void)doPlayerLayerNodeIsNotAddedIfVisibleButShouldNotBePlaying
|
||||
{
|
||||
[_videoNode pause];
|
||||
[_videoNode setInterfaceState:ASInterfaceStateVisible];
|
||||
[_videoNode setInterfaceState:ASInterfaceStateVisible | ASInterfaceStateDisplay];
|
||||
[_videoNode didLoad];
|
||||
|
||||
XCTAssert(![_videoNode.subnodes containsObject:_videoNode.playerNode]);
|
||||
@@ -268,4 +275,23 @@
|
||||
XCTAssertTrue(_videoNode.shouldBePlaying);
|
||||
}
|
||||
|
||||
- (void)testMutingShouldMutePlayer
|
||||
{
|
||||
[_videoNode setPlayer:[[AVPlayer alloc] init]];
|
||||
|
||||
_videoNode.muted = YES;
|
||||
|
||||
XCTAssertTrue(_videoNode.player.muted);
|
||||
}
|
||||
|
||||
- (void)testUnMutingShouldUnMutePlayer
|
||||
{
|
||||
[_videoNode setPlayer:[[AVPlayer alloc] init]];
|
||||
|
||||
_videoNode.muted = YES;
|
||||
_videoNode.muted = NO;
|
||||
|
||||
XCTAssertFalse(_videoNode.player.muted);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
After Width: | Height: | Size: 4.8 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 6.8 KiB |
|
After Width: | Height: | Size: 6.5 KiB |
|
After Width: | Height: | Size: 6.3 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 5.6 KiB |
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 5.4 KiB |
|
After Width: | Height: | Size: 5.8 KiB |
|
After Width: | Height: | Size: 6.1 KiB |
|
After Width: | Height: | Size: 4.7 KiB |
|
After Width: | Height: | Size: 2.0 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 11 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 9.3 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 2.6 KiB |