blob: a0c630ebb5932e6acc1dd630a2f7f0542968356d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
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
|