Skip to content

Commit

Permalink
Mismatch name experimental features (TextureGroup#1159)
Browse files Browse the repository at this point in the history
* fix SIMULATE_WEB_RESPONSE not imported TextureGroup#449

* Fix to make rangeMode update in right time

* remove uncessary assert

* Fix collection cell editing bug for iOS 9 & 10

* Revert "Fix collection cell editing bug for iOS 9 & 10"

This reverts commit 06e18a1.

* fix mismatch of name array and experimental features

* add more tests

* remove nslog

* add change log

* fix tests
  • Loading branch information
wsdwsd0829 authored and mikezucc committed Nov 7, 2018
1 parent 8546cbd commit 3e1d8a9
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## master
* Add your own contributions to the next release on the line below this with your name.
- [ASExperimentalFeatures.m] Fix mismatch name in experimental features. [Max Wang](https://github.com/wsdwsd0829). [#1159](https://github.com/TextureGroup/Texture/pull/1159)
- [ASCollectionViewLayoutController] Set default tuning parameters before view is loaded. [Max Wang](https://github.com/wsdwsd0829). [#1158](https://github.com/TextureGroup/Texture/pull/1158)
- [ASPhotosFrameworkImageRequestTests] Guard photo library with macro for tests. [Max Wang](https://github.com/wsdwsd0829). [#1147](https://github.com/TextureGroup/Texture/pull/1147)
- [ASDisplayNode] Do not cancel display when in exit hierarchy but let interface state changing to handle it. [Max Wang](https://github.com/wsdwsd0829). [#1110](https://github.com/TextureGroup/Texture/pull/1110)
Expand Down
1 change: 0 additions & 1 deletion Source/ASExperimentalFeatures.m
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
@"exp_unfair_lock",
@"exp_infer_layer_defaults",
@"exp_network_image_queue",
@"exp_dealloc_queue_v2",
@"exp_collection_teardown",
@"exp_framesetter_cache",
@"exp_clear_data_during_deallocation"]));
Expand Down
63 changes: 57 additions & 6 deletions Tests/ASConfigurationTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@
#import "ASConfigurationDelegate.h"
#import "ASConfigurationInternal.h"

static ASExperimentalFeatures features[] = {
ASExperimentalGraphicsContexts,
ASExperimentalTextNode,
ASExperimentalInterfaceStateCoalescing,
ASExperimentalUnfairLock,
ASExperimentalLayerDefaults,
ASExperimentalNetworkImageQueue,
ASExperimentalCollectionTeardown,
ASExperimentalFramesetterCache,
ASExperimentalClearDataDuringDeallocation
};

@interface ASConfigurationTests : ASTestCase <ASConfigurationDelegate>

@end
Expand All @@ -20,6 +32,28 @@ @implementation ASConfigurationTests {
void (^onActivate)(ASConfigurationTests *self, ASExperimentalFeatures feature);
}

+ (NSArray *)names {
return @[
@"exp_graphics_contexts",
@"exp_text_node",
@"exp_interface_state_coalesce",
@"exp_unfair_lock",
@"exp_infer_layer_defaults",
@"exp_network_image_queue",
@"exp_collection_teardown",
@"exp_framesetter_cache",
@"exp_clear_data_during_deallocation"
];
}

- (ASExperimentalFeatures)allFeatures {
ASExperimentalFeatures allFeatures = 0;
for (int i = 0; i < sizeof(features)/sizeof(ASExperimentalFeatures); i++) {
allFeatures |= features[i];
}
return allFeatures;
}

- (void)testExperimentalFeatureConfig
{
// Set the config
Expand Down Expand Up @@ -55,17 +89,34 @@ - (void)textureDidActivateExperimentalFeatures:(ASExperimentalFeatures)feature
- (void)testMappingNamesToFlags
{
// Throw in a bad bit.
ASExperimentalFeatures features = ASExperimentalTextNode | ASExperimentalGraphicsContexts | (1 << 22);
NSArray *expectedNames = @[ @"exp_graphics_contexts", @"exp_text_node" ];
XCTAssertEqualObjects(expectedNames, ASExperimentalFeaturesGetNames(features));
ASExperimentalFeatures allFeatures = [self allFeatures];
ASExperimentalFeatures featuresWithBadBit = allFeatures | (1 << 22);
NSArray *expectedNames = [ASConfigurationTests names];
XCTAssertEqualObjects(expectedNames, ASExperimentalFeaturesGetNames(featuresWithBadBit));
}

- (void)testMappingFlagsFromNames
{
// Throw in a bad name.
NSArray *names = @[ @"exp_text_node", @"exp_graphics_contexts", @"__invalid_name" ];
ASExperimentalFeatures expected = ASExperimentalGraphicsContexts | ASExperimentalTextNode;
XCTAssertEqual(expected, ASExperimentalFeaturesFromArray(names));
NSMutableArray *allNames = [[NSMutableArray alloc] initWithArray:[ASConfigurationTests names]];
[allNames addObject:@"__invalid_name"];
ASExperimentalFeatures expected = [self allFeatures];
XCTAssertEqual(expected, ASExperimentalFeaturesFromArray(allNames));
}

- (void)testFlagMatchName
{
NSArray *names = [ASConfigurationTests names];
for (NSInteger i = 0; i < names.count; i++) {
XCTAssertEqual(features[i], ASExperimentalFeaturesFromArray(@[names[i]]));
}
}

- (void)testNameMatchFlag {
NSArray *names = [ASConfigurationTests names];
for (NSInteger i = 0; i < names.count; i++) {
XCTAssertEqualObjects(@[names[i]], ASExperimentalFeaturesGetNames(features[i]));
}
}

@end

0 comments on commit 3e1d8a9

Please sign in to comment.