This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
-
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.
[ios] Adds support for MGLCollisionBehaviorPre4_0 in NSUserDefaults (#…
- Loading branch information
Showing
9 changed files
with
163 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#import <Mapbox/Mapbox.h> | ||
#import <XCTest/XCTest.h> | ||
#import "MGLRendererConfiguration.h" | ||
|
||
static NSString * const MGLRendererConfigurationTests_collisionBehaviorKey = @"MGLCollisionBehaviorPre4_0"; | ||
|
||
@interface MGLRendererConfiguration (Tests) | ||
- (instancetype)initWithPropertyDictionary:(nonnull NSDictionary*)bundle; | ||
@end | ||
|
||
|
||
@interface MGLRendererConfigurationTests : XCTestCase | ||
@end | ||
|
||
@implementation MGLRendererConfigurationTests | ||
- (void)setUp { | ||
[[NSUserDefaults standardUserDefaults] removeObjectForKey:MGLRendererConfigurationTests_collisionBehaviorKey]; | ||
} | ||
|
||
- (void)tearDown { | ||
[[NSUserDefaults standardUserDefaults] removeObjectForKey:MGLRendererConfigurationTests_collisionBehaviorKey]; | ||
} | ||
|
||
// Emulate what would happen with an Info.plist. | ||
- (void)testSettingMGLCollisionBehaviorPre40WithEmptyDictionary | ||
{ | ||
MGLRendererConfiguration *config = [[MGLRendererConfiguration alloc] initWithPropertyDictionary:@{}]; | ||
XCTAssertFalse(config.perSourceCollisions); | ||
} | ||
|
||
- (void)testSettingMGLCollisionBehaviorPre40WithYESDictionary | ||
{ | ||
MGLRendererConfiguration *config = [[MGLRendererConfiguration alloc] initWithPropertyDictionary:@{MGLRendererConfigurationTests_collisionBehaviorKey:@(NO)}]; | ||
XCTAssertFalse(config.perSourceCollisions); | ||
} | ||
|
||
- (void)testSettingMGLCollisionBehaviorPre40WithNODictionary | ||
{ | ||
MGLRendererConfiguration *config = [[MGLRendererConfiguration alloc] initWithPropertyDictionary:@{MGLRendererConfigurationTests_collisionBehaviorKey:@(YES)}]; | ||
XCTAssert(config.perSourceCollisions); | ||
} | ||
|
||
- (void)testSettingMGLCollisionBehaviorPre40InNSUserDefaults { | ||
{ | ||
XCTAssertNil([[NSUserDefaults standardUserDefaults] objectForKey:MGLRendererConfigurationTests_collisionBehaviorKey]); | ||
MGLRendererConfiguration *config = [MGLRendererConfiguration currentConfiguration]; | ||
XCTAssertFalse(config.perSourceCollisions); | ||
} | ||
|
||
[[NSUserDefaults standardUserDefaults] setObject:@(NO) forKey:MGLRendererConfigurationTests_collisionBehaviorKey]; | ||
{ | ||
XCTAssertNotNil([[NSUserDefaults standardUserDefaults] objectForKey:MGLRendererConfigurationTests_collisionBehaviorKey]); | ||
MGLRendererConfiguration *config = [MGLRendererConfiguration currentConfiguration]; | ||
XCTAssertFalse(config.perSourceCollisions); | ||
} | ||
|
||
[[NSUserDefaults standardUserDefaults] setObject:@(YES) forKey:MGLRendererConfigurationTests_collisionBehaviorKey]; | ||
{ | ||
XCTAssertNotNil([[NSUserDefaults standardUserDefaults] objectForKey:MGLRendererConfigurationTests_collisionBehaviorKey]); | ||
MGLRendererConfiguration *config = [MGLRendererConfiguration currentConfiguration]; | ||
XCTAssert(config.perSourceCollisions); | ||
} | ||
} | ||
|
||
- (void)testSettingMGLCollisionBehaviorPre40PListValueUsingString { | ||
// Dictionary = "NO" | ||
{ | ||
MGLRendererConfiguration *config = [[MGLRendererConfiguration alloc] initWithPropertyDictionary:@{MGLRendererConfigurationTests_collisionBehaviorKey:@"NO"}]; | ||
XCTAssertFalse(config.perSourceCollisions); | ||
} | ||
|
||
// Dictionary = "YES" | ||
{ | ||
MGLRendererConfiguration *config = [[MGLRendererConfiguration alloc] initWithPropertyDictionary:@{MGLRendererConfigurationTests_collisionBehaviorKey:@"YES"}]; | ||
XCTAssert(config.perSourceCollisions); | ||
} | ||
} | ||
|
||
- (void)testOverridingMGLCollisionBehaviorPre40 { | ||
|
||
// Dictionary = NO, NSUserDefaults = YES | ||
{ | ||
[[NSUserDefaults standardUserDefaults] setObject:@(YES) forKey:MGLRendererConfigurationTests_collisionBehaviorKey]; | ||
MGLRendererConfiguration *config = [[MGLRendererConfiguration alloc] initWithPropertyDictionary:@{MGLRendererConfigurationTests_collisionBehaviorKey:@(NO)}]; | ||
XCTAssert(config.perSourceCollisions); | ||
} | ||
|
||
// Dictionary = YES, NSUserDefaults = NO | ||
{ | ||
[[NSUserDefaults standardUserDefaults] setObject:@(NO) forKey:MGLRendererConfigurationTests_collisionBehaviorKey]; | ||
MGLRendererConfiguration *config = [[MGLRendererConfiguration alloc] initWithPropertyDictionary:@{MGLRendererConfigurationTests_collisionBehaviorKey:@(YES)}]; | ||
XCTAssertFalse(config.perSourceCollisions); | ||
} | ||
} | ||
|
||
@end |
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