Swiftgram/Tests/ASTraitCollectionTests.m
Yevgen Pogribnyi a3136b0225 [ASTraitCollection] Add missing properties to ASTraitCollection (#625)
* [ASTraitCollection] Add missing properties to ASTraitCollection

* ASTraitCollection now completely reflects UITraitCollection

* Add ASContentSizeCategory enum that corresponds to
  UIContentSizeCategory and can be used inside a struct.

* * Remove enum ASContentSizeCategory.
* Use __unsafe_unretained UIContentSizeCategory instead of the enum.

* Added ASPrimitiveTraitCollection lifetime test

* Changes requested at code review:
* Restore one of the ASTraitCollection constructors with a deprecation notice.
* Clean up API by the separation of tvOS-specific interfaces.
* Use [NSString -isEqualToString:] for ASPrimitiveContentSizeCategory equality tests for better readability.
* Encapsulate fallback logic for UIContentSizeCategoryUnspecified.

* Fix failing test
2018-01-16 18:08:29 +00:00

35 lines
1004 B
Objective-C

//
// ASTraitCollectionTests.m
// Texture
//
// Copyright (c) 2017-present, Pinterest, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
#import <XCTest/XCTest.h>
#import <AsyncDisplayKit/ASTraitCollection.h>
@interface ASTraitCollectionTests : XCTestCase
@end
@implementation ASTraitCollectionTests
- (void)testPrimitiveContentSizeCategoryLifetime
{
ASPrimitiveContentSizeCategory primitiveContentSize;
@autoreleasepool {
// Make sure the compiler won't optimize string alloc/dealloc
NSString *contentSizeCategory = [NSString stringWithCString:"UICTContentSizeCategoryL" encoding:NSUTF8StringEncoding];
primitiveContentSize = ASPrimitiveContentSizeCategoryMake(contentSizeCategory);
}
XCTAssertEqual(primitiveContentSize, UIContentSizeCategoryLarge);
}
@end