summaryrefslogtreecommitdiff
path: root/platform/darwin
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-04-20 17:10:33 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-05-02 08:45:09 -0700
commit197751bace6181f2c2dbe4c890f277a0dc7e58b1 (patch)
tree55e57a6a1d86d1db26f24d3d58694f69518cbd97 /platform/darwin
parentc2b00378b78b55d50968a9b11ed75bb4edf62ec9 (diff)
downloadqtlocation-mapboxgl-197751bace6181f2c2dbe4c890f277a0dc7e58b1.tar.gz
[core] Load source TileJSON immediately
This reverses #3095. Rationale: * We're now exposing source attributes as a public API. Making those attributes unavailable at certain times complicates that API. * We're preparing to split RenderSource out of Source. Removing this removes a point of coupling between the two.
Diffstat (limited to 'platform/darwin')
-rw-r--r--platform/darwin/test/MGLSourceQueryTests.m60
-rw-r--r--platform/darwin/test/query-style.json98
2 files changed, 6 insertions, 152 deletions
diff --git a/platform/darwin/test/MGLSourceQueryTests.m b/platform/darwin/test/MGLSourceQueryTests.m
index 28e968146b..d1ef180a52 100644
--- a/platform/darwin/test/MGLSourceQueryTests.m
+++ b/platform/darwin/test/MGLSourceQueryTests.m
@@ -1,73 +1,25 @@
#import <Mapbox/Mapbox.h>
-
-#import "NSBundle+MGLAdditions.h"
-
#import <XCTest/XCTest.h>
-#if TARGET_OS_IPHONE
- #import <UIKit/UIKit.h>
-#else
- #import <Cocoa/Cocoa.h>
-#endif
@interface MGLSourceQueryTests : XCTestCase <MGLMapViewDelegate>
-@property (nonatomic) MGLMapView *mapView;
-@property (nonatomic) MGLStyle *style;
-
@end
-@implementation MGLSourceQueryTests {
- XCTestExpectation *_styleLoadingExpectation;
-}
-
-- (void)setUp {
- [super setUp];
-
- [MGLAccountManager setAccessToken:@"pk.feedcafedeadbeefbadebede"];
- NSURL *styleURL = [[NSBundle bundleForClass:[self class]] URLForResource:@"query-style" withExtension:@"json"];
- self.mapView = [[MGLMapView alloc] initWithFrame:CGRectMake(0, 0, 100, 100) styleURL:styleURL];
- self.mapView.delegate = self;
- if (!self.mapView.style) {
- _styleLoadingExpectation = [self expectationWithDescription:@"Map view should finish loading style."];
- [self waitForExpectationsWithTimeout:1 handler:nil];
- }
-}
-
-- (void)mapView:(MGLMapView *)mapView didFinishLoadingStyle:(MGLStyle *)style {
- XCTAssertNotNil(mapView.style);
- XCTAssertEqual(mapView.style, style);
-
- [_styleLoadingExpectation fulfill];
-}
-
-- (void)tearDown {
- _styleLoadingExpectation = nil;
- self.mapView = nil;
-
- [super tearDown];
-}
-
-- (MGLStyle *)style {
- return self.mapView.style;
-}
+@implementation MGLSourceQueryTests
- (void) testQueryVectorSource {
- MGLVectorSource *source = (MGLVectorSource *)[self.style sourceWithIdentifier:@"source5"];
-
+ MGLVectorSource *source = [[MGLVectorSource alloc] initWithIdentifier:@"vector" tileURLTemplates:@[@"fake"] options:nil];
NSSet *sourceLayers = [NSSet setWithObjects:@"buildings", @"water", nil];
NSArray* features = [source featuresInSourceLayersWithIdentifiers:sourceLayers predicate:nil];
- // Source won't be loaded yet, so features is 0
+ // Source not added yet, so features is 0
XCTAssertEqual([features count], 0);
}
- (void) testQueryShapeSource {
- MGLShapeSource *source = (MGLShapeSource *)[self.style sourceWithIdentifier:@"source4"];
-
- NSPredicate *eqPredicate = [NSPredicate predicateWithFormat:@"key1 == 'value1'"];
- NSArray* features = [source featuresMatchingPredicate:eqPredicate];
- // Source won't be loaded yet, so features is 0
+ MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"shape" shape:[MGLShapeCollection shapeCollectionWithShapes:@[]] options:nil];
+ NSArray* features = [source featuresMatchingPredicate:nil];
+ // Source not added yet, so features is 0
XCTAssertEqual([features count], 0);
-
}
@end
diff --git a/platform/darwin/test/query-style.json b/platform/darwin/test/query-style.json
deleted file mode 100644
index 97f1d04432..0000000000
--- a/platform/darwin/test/query-style.json
+++ /dev/null
@@ -1,98 +0,0 @@
-{
- "version": 8,
- "sources": {
- "source1": {
- "type": "geojson",
- "data": {
- "type": "Point",
- "coordinates": [
- 0,
- 0
- ]
- }
- },
- "source2": {
- "type": "geojson",
- "data": {
- "type": "Point",
- "coordinates": [
- 0,
- 0
- ]
- }
- },
- "source3": {
- "type": "geojson",
- "data": {
- "type": "Point",
- "coordinates": [
- 0,
- 0
- ]
- }
- },
- "source4": {
- "type": "geojson",
- "data": {
- "type": "Feature",
- "id": "feature1",
- "geometry": {
- "type": "Point",
- "coordinates": [
- 0.0,
- 0.0
- ]
- },
- "properties": {
- "key1": "value1",
- "key2": 1.5,
- "key3": false,
- "key4": 0.5
- }
- }
- },
- "source5": {
- "type": "vector",
- "url": "mapbox://mapbox.mapbox-streets-v6"
- },
- "source6": {
- "type": "raster",
- "url": "mapbox://mapbox.satellite",
- "tileSize": 256
- }
- },
- "layers": [
- {
- "id": "layer1",
- "type": "symbol",
- "source": "source1",
- "layout": {
- "icon-image": "test-icon"
- }
- },
- {
- "id": "layer2",
- "type": "symbol",
- "source": "source2",
- "layout": {
- "icon-image": "test-icon"
- }
- },
- {
- "id": "layer3",
- "type": "symbol",
- "source": "source3",
- "layout": {
- "icon-image": "test-icon"
- }
- },
- {
- "id": "layer4",
- "type": "symbol",
- "source": "source4",
- "layout": {
- "icon-image": "test-icon"
- }
- }
- ]
-}