blob: 11d1187263d6a346fb9e424e0c360392bef6aea0 (
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
|
#import <Mapbox/Mapbox.h>
#import <XCTest/XCTest.h>
@interface MGLMapViewScaleBarTests : XCTestCase
@property (nonatomic) MGLMapView *mapView;
@end
@implementation MGLMapViewScaleBarTests
- (void)setUp {
[super setUp];
[MGLAccountManager setAccessToken:@"pk.feedcafedeadbeefbadebede"];
NSURL *styleURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"one-liner" withExtension:@"json"];
self.mapView = [[MGLMapView alloc] initWithFrame:UIScreen.mainScreen.bounds styleURL:styleURL];
}
- (void)tearDown {
self.mapView = nil;
[super tearDown];
}
- (void)testShowsScale {
UIView *scaleBar = self.mapView.scaleBar;
// Scale bar should not be enabled by default.
XCTAssertFalse(self.mapView.showsScale);
XCTAssertTrue(scaleBar.hidden);
self.mapView.showsScale = YES;
XCTAssertFalse(scaleBar.hidden);
// Scale bar should not be visible at default zoom (~z0), but it should be ready.
XCTAssertFalse(CGRectIsEmpty(scaleBar.frame));
XCTAssertEqual(scaleBar.alpha, 0);
self.mapView.zoomLevel = 15;
XCTAssertGreaterThan(scaleBar.alpha, 0);
}
- (void)testDirectlySettingScaleBarViewHiddenProperty {
UIView *scaleBar = self.mapView.scaleBar;
scaleBar.hidden = NO;
XCTAssertFalse(scaleBar.hidden);
// Directly setting `.hidden` after the map has finished initializing will not update the scale bar.
XCTAssertTrue(CGRectIsEmpty(scaleBar.frame));
// ... but triggering any camera event will update it.
self.mapView.zoomLevel = 1;
XCTAssertFalse(CGRectIsEmpty(scaleBar.frame));
XCTAssertEqual(scaleBar.alpha, 0);
self.mapView.zoomLevel = 15;
XCTAssertGreaterThan(scaleBar.alpha, 0);
}
@end
|