Files
Texture/Tests/ASGraphicsContextTests.mm
Andy Finnell e9bd484149 Update to Xcode 15 (#2107)
* Update to Xcode 15

## Summary

We want to make Texture build with recent tools like Xcode 15. Part of this is bumping the minimum supported OS to iOS 14.

I only removed the dead code (i.e. code gated on versions older than iOS 14). There are still some warnings about outdated APIs in use, but they are non-trivial changes to fix.

## Test plan

Run all the examples. Run all the unit tests and make them pass.

* Use Xcode 15.3 so we have 17.4 simulators

* Fixing an asset catalog compiler error when building against iPhone SE

* Fix a couple of file extensions for assets

A couple of PNGs were marked as JPGs
2024-05-21 13:04:39 -04:00

88 lines
3.0 KiB
Plaintext

//
// ASGraphicsContextTests.mm
// Texture
//
// 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];
}
- (void)testCanceled
{
CGSize size = CGSize{.width=100, .height=100};
XCTestExpectation *expectationCancelled = [self expectationWithDescription:@"canceled"];
asdisplaynode_iscancelled_block_t isCancelledBlock =^BOOL{
[expectationCancelled fulfill];
return true;
};
ASPrimitiveTraitCollection traitCollection = ASPrimitiveTraitCollectionMakeDefault();
UIImage *canceledImage = ASGraphicsCreateImage(traitCollection, size, false, 0, nil, isCancelledBlock, ^{});
XCTAssertNil(canceledImage);
[self waitForExpectations:@[expectationCancelled] timeout:1];
}
- (void)testCanceledNil
{
CGSize size = CGSize{.width=100, .height=100};
ASPrimitiveTraitCollection traitCollection = ASPrimitiveTraitCollectionMakeDefault();
XCTestExpectation *expectation = [self expectationWithDescription:@"normal"];
UIImage *image = ASGraphicsCreateImage(traitCollection, size, false, 0, nil, nil, ^{
[expectation fulfill];
});
XCTAssert(image);
[self waitForExpectations:@[expectation] timeout:1];
}
- (void)testTraitCollectionPassedToWork
{
CGSize size = CGSize{.width=100, .height=100};
XCTestExpectation *expectationDark = [self expectationWithDescription:@"trait collection dark"];
ASPrimitiveTraitCollection traitCollectionDark = ASPrimitiveTraitCollectionMakeDefault();
traitCollectionDark.userInterfaceStyle = UIUserInterfaceStyleDark;
ASGraphicsCreateImage(traitCollectionDark, size, false, 0, nil, nil, ^{
UITraitCollection *currentTraitCollection = [UITraitCollection currentTraitCollection];
XCTAssertEqual(currentTraitCollection.userInterfaceStyle, UIUserInterfaceStyleDark);
[expectationDark fulfill];
});
XCTestExpectation *expectationLight = [self expectationWithDescription:@"trait collection light"];
ASPrimitiveTraitCollection traitCollectionLight = ASPrimitiveTraitCollectionMakeDefault();
traitCollectionLight.userInterfaceStyle = UIUserInterfaceStyleLight;
ASGraphicsCreateImage(traitCollectionLight, size, false, 0, nil, nil, ^{
UITraitCollection *currentTraitCollection = [UITraitCollection currentTraitCollection];
XCTAssertEqual(currentTraitCollection.userInterfaceStyle, UIUserInterfaceStyleLight);
[expectationLight fulfill];
});
[self waitForExpectations:@[expectationDark, expectationLight] timeout:1];
}
@end