-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduction of
ASGraphicsCreateImageWithTraitCollectionAndOptions
- Loading branch information
Showing
8 changed files
with
152 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// | ||
// ASGraphicsContextTests.mm | ||
// Texture | ||
// | ||
// Copyright (c) Facebook, Inc. and its affiliates. All rights reserved. | ||
// Changes after 4/13/2017 are: Copyright (c) Pinterest, Inc. All rights reserved. | ||
// Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
|
||
|
||
#import <XCTest/XCTest.h> | ||
#import <AsyncDisplayKit/ASGraphicsContext.h> | ||
#import <AsyncDisplayKit/ASBaseDefines.h> | ||
#import <AsyncDisplayKit/ASAvailability.h> | ||
#import <AsyncDisplayKit/ASConfigurationInternal.h> | ||
|
||
@interface ASGraphicsContextTests : XCTestCase | ||
@end | ||
|
||
@implementation ASGraphicsContextTests | ||
|
||
- (void)setUp | ||
{ | ||
[super setUp]; | ||
ASConfiguration *config = [ASConfiguration new]; | ||
config.experimentalFeatures = ASExperimentalDrawingGlobal; | ||
[ASConfigurationManager test_resetWithConfiguration:config]; | ||
} | ||
|
||
|
||
#if AS_BUILD_UIUSERINTERFACESTYLE | ||
- (void)testTraitCollectionPassedToWork | ||
{ | ||
if (AS_AVAILABLE_IOS_TVOS(13, 13)) { | ||
CGSize size = CGSize{.width=100, .height=100}; | ||
|
||
XCTestExpectation *expectationDark = [self expectationWithDescription:@"trait collection dark"]; | ||
ASPrimitiveTraitCollection traitCollectionDark = ASPrimitiveTraitCollectionMakeDefault(); | ||
traitCollectionDark.userInterfaceStyle = UIUserInterfaceStyleDark; | ||
[traitCollectionDark performAsCurrentTraitCollection:^{ | ||
ASGraphicsCreateImageWithTraitCollectionAndOptions(traitCollectionDark, size, false, 0, nil, nil, ^{ | ||
UITraitCollection *currentTraitCollection = [UITraitCollection currentTraitCollection]; | ||
XCTAssertEqual(currentTraitCollection.userInterfaceStyle, UIUserInterfaceStyleDark); | ||
[expectationDark fulfill]; | ||
}); | ||
}]; | ||
|
||
XCTestExpectation *expectationLight = [self expectationWithDescription:@"trait collection light"]; | ||
UITraitCollection *traitCollectionLight = [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleLight]; | ||
[traitCollectionLight performAsCurrentTraitCollection:^{ | ||
ASGraphicsCreateImageWithOptions(size, false, 0, nil, nil, ^{ | ||
UITraitCollection *currentTraitCollection = [UITraitCollection currentTraitCollection]; | ||
XCTAssertEqual(currentTraitCollection.userInterfaceStyle, UIUserInterfaceStyleLight); | ||
[expectationLight fulfill]; | ||
}); | ||
}]; | ||
|
||
[self waitForExpectations:@[expectationDark, expectationLight] timeout:1]; | ||
} | ||
} | ||
#endif | ||
@end |