diff options
author | Julian Rex <julian.rex@mapbox.com> | 2018-05-17 17:29:03 -0400 |
---|---|---|
committer | Julian Rex <julian.rex@mapbox.com> | 2018-05-17 17:29:03 -0400 |
commit | 74730cf3fef9dc16ddfcc9d77debc6c3b7c575ea (patch) | |
tree | be30de52b3f4fadf8c60c8afdcbe4ed482585a80 | |
parent | 1b1ca76070e92ec80d1017a054a6b857864d33b3 (diff) | |
download | qtlocation-mapboxgl-upstream/jrex-addAnnotation-boundary-coords.tar.gz |
Rebase and update wip test.upstream/jrex-addAnnotation-boundary-coords
-rw-r--r-- | platform/ios/ios.xcodeproj/project.pbxproj | 8 | ||||
-rw-r--r-- | platform/ios/test/MGLAnnotationViewTests.mm (renamed from platform/ios/test/MGLAnnotationViewTests.m) | 50 |
2 files changed, 27 insertions, 31 deletions
diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index 78cfff965c..b823efb8a8 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -98,7 +98,7 @@ 353AFA171D65AB17005A69F4 /* NSDate+MGLAdditions.mm in Sources */ = {isa = PBXBuildFile; fileRef = 353AFA131D65AB17005A69F4 /* NSDate+MGLAdditions.mm */; }; 353BAEF61D646370009A8DA9 /* amsterdam.geojson in Resources */ = {isa = PBXBuildFile; fileRef = 353BAEF51D646370009A8DA9 /* amsterdam.geojson */; }; 353BAEF71D646370009A8DA9 /* amsterdam.geojson in Resources */ = {isa = PBXBuildFile; fileRef = 353BAEF51D646370009A8DA9 /* amsterdam.geojson */; }; - 353D23961D0B0DFE002BE09D /* MGLAnnotationViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 353D23951D0B0DFE002BE09D /* MGLAnnotationViewTests.m */; }; + 353D23961D0B0DFE002BE09D /* MGLAnnotationViewTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 353D23951D0B0DFE002BE09D /* MGLAnnotationViewTests.mm */; }; 354B83961D2E873E005D9406 /* MGLUserLocationAnnotationView.h in Headers */ = {isa = PBXBuildFile; fileRef = 354B83941D2E873E005D9406 /* MGLUserLocationAnnotationView.h */; settings = {ATTRIBUTES = (Public, ); }; }; 354B83971D2E873E005D9406 /* MGLUserLocationAnnotationView.h in Headers */ = {isa = PBXBuildFile; fileRef = 354B83941D2E873E005D9406 /* MGLUserLocationAnnotationView.h */; settings = {ATTRIBUTES = (Public, ); }; }; 354B83981D2E873E005D9406 /* MGLUserLocationAnnotationView.m in Sources */ = {isa = PBXBuildFile; fileRef = 354B83951D2E873E005D9406 /* MGLUserLocationAnnotationView.m */; }; @@ -790,7 +790,7 @@ 353AFA121D65AB17005A69F4 /* NSDate+MGLAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+MGLAdditions.h"; sourceTree = "<group>"; }; 353AFA131D65AB17005A69F4 /* NSDate+MGLAdditions.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSDate+MGLAdditions.mm"; sourceTree = "<group>"; }; 353BAEF51D646370009A8DA9 /* amsterdam.geojson */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = amsterdam.geojson; path = ../../darwin/test/amsterdam.geojson; sourceTree = "<group>"; }; - 353D23951D0B0DFE002BE09D /* MGLAnnotationViewTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLAnnotationViewTests.m; sourceTree = "<group>"; }; + 353D23951D0B0DFE002BE09D /* MGLAnnotationViewTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLAnnotationViewTests.mm; sourceTree = "<group>"; }; 354B83941D2E873E005D9406 /* MGLUserLocationAnnotationView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MGLUserLocationAnnotationView.h; sourceTree = "<group>"; }; 354B83951D2E873E005D9406 /* MGLUserLocationAnnotationView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MGLUserLocationAnnotationView.m; sourceTree = "<group>"; }; 354B839A1D2E9B48005D9406 /* MBXUserLocationAnnotationView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MBXUserLocationAnnotationView.h; sourceTree = "<group>"; }; @@ -1812,7 +1812,7 @@ 4031ACFD1E9FD26900A3EA26 /* Test Helpers */, 409F43FB1E9E77D10048729D /* Swift Integration */, 357579811D502AD4000B822E /* Styling */, - 353D23951D0B0DFE002BE09D /* MGLAnnotationViewTests.m */, + 353D23951D0B0DFE002BE09D /* MGLAnnotationViewTests.mm */, DAEDC4331D603417000224FF /* MGLAttributionInfoTests.m */, DA35A2C31CCA9F8300E826B2 /* MGLClockDirectionFormatterTests.m */, 35D9DDE11DA25EEC00DAAD69 /* MGLCodingTests.m */, @@ -2883,7 +2883,7 @@ DA35A2AA1CCA058D00E826B2 /* MGLCoordinateFormatterTests.m in Sources */, 357579831D502AE6000B822E /* MGLRasterStyleLayerTests.mm in Sources */, DAF25720201902BC00367EF5 /* MGLHillshadeStyleLayerTests.mm in Sources */, - 353D23961D0B0DFE002BE09D /* MGLAnnotationViewTests.m in Sources */, + 353D23961D0B0DFE002BE09D /* MGLAnnotationViewTests.mm in Sources */, 35E208A71D24210F00EC9A46 /* MGLNSDataAdditionsTests.m in Sources */, DA0CD5901CF56F6A00A5F5A5 /* MGLFeatureTests.mm in Sources */, 556660D81E1D085500E2C41B /* MGLVersionNumber.m in Sources */, diff --git a/platform/ios/test/MGLAnnotationViewTests.m b/platform/ios/test/MGLAnnotationViewTests.mm index 2aee9950be..b2ce145535 100644 --- a/platform/ios/test/MGLAnnotationViewTests.m +++ b/platform/ios/test/MGLAnnotationViewTests.mm @@ -1,6 +1,8 @@ #import <Mapbox/Mapbox.h> #import <XCTest/XCTest.h> +#import "../../darwin/src/MGLGeometry_Private.h" + static NSString * const MGLTestAnnotationReuseIdentifer = @"MGLTestAnnotationReuseIdentifer"; @@ -237,41 +239,30 @@ static NSString * const MGLTestAnnotationReuseIdentifer = @"MGLTestAnnotationReu XCTAssert(self.mapView.selectedAnnotations.count == 0, @"There should be 0 selected annotations"); } -- (void)testAddAnnotationWithBoundaryCoordinates +- (void)disabled_testAddAnnotationWithBoundaryCoordinatesPENDING { typedef struct { CLLocationDegrees lat; CLLocationDegrees lon; - BOOL expectation; + BOOL expectation; // CLLocationCoordinate2DIsValid + BOOL mglExpectation; // MGLLocationCoordinate2DIsValid } TestParam; TestParam params[] = { - // Lat Lon Valid - { -91.0, 0.0, NO}, - - // The follow coordinate fails, essentially because the following in projection.hpp - // - // util::LONGITUDE_MAX - util::RAD2DEG * std::log(std::tan(M_PI / 4 + latLng.latitude() * M_PI / util::DEGREES_MAX)) - // - // boils down to ln(0) - // - // It makes sense that -90° latitude (south pole) should be invalid from a projection point - // of view, but in that case shouldn't +90° (north pole) also be invalid? - // - // In Obj-C code, perhaps we need to replace usage of CLLocationCoordinate2DIsValid for an - // MGL one... - - { -90.0, 0.0, YES}, // South pole. Should this really be considered an invalid coordinate? + // Lat Lon CL MGL + { -91.0, 0.0, NO, NO }, + + { -90.0, 0.0, YES, YES }, // South pole. Should this really be considered an invalid coordinate? // The rest for completeness - { -89.0, 0.0, YES}, - { 90.0, 0.0, YES}, // North pole. Similarly, should this one be considered invalid? - { 91.0, 0.0, NO}, - - { 0.0, -181.0, NO}, - { 0.0, -180.0, YES}, - { 0.0, 180.0, YES}, - { 0.0, 181.0, NO}, + { -89.0, 0.0, YES, YES }, + { 90.0, 0.0, YES, YES }, // North pole. Similarly, should this one be considered invalid? + { 91.0, 0.0, NO, NO }, + + { 0.0, -181.0, NO, YES }, + { 0.0, -180.0, YES, YES }, + { 0.0, 180.0, YES, YES }, + { 0.0, 181.0, NO, YES }, }; for (int i = 0; i < sizeof(params)/sizeof(params[0]); i++) { @@ -281,13 +272,18 @@ static NSString * const MGLTestAnnotationReuseIdentifer = @"MGLTestAnnotationReu CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(param.lat, param.lon); NSString *coordDesc = [NSString stringWithFormat:@"(%0.1f,%0.1f)", param.lat, param.lon]; - XCTAssert(CLLocationCoordinate2DIsValid(coordinate) == param.expectation, @"Unexpected valid result for coordinate %@", coordDesc); + XCTAssert(CLLocationCoordinate2DIsValid(coordinate) == param.expectation, @"Unexpected CLLocationCoordinate2DIsValid for coordinate %@", coordDesc); + XCTAssert(MGLLocationCoordinate2DIsValid(coordinate) == param.mglExpectation, @"Unexpected MGLLocationCoordinate2DIsValid for coordinate %@", coordDesc); + CGPoint point = [_mapView convertCoordinate:coordinate toPointToView:_mapView]; (void)point; + + // TODO: XCTAssert(isnan(point.x) != param.expectation, @"Unexpected point.x for coordinate %@", coordDesc); XCTAssert(isnan(point.y) != param.expectation, @"Unexpected point.y for coordinate %@", coordDesc); + // TODO: which one if (param.expectation) { // If we expect a valid coordinate, let's finally try to add an annotation |