diff --git a/platform/darwin/src/MGLAttributionInfo.h b/platform/darwin/src/MGLAttributionInfo.h index 5c9f0909f29..2544989fb79 100644 --- a/platform/darwin/src/MGLAttributionInfo.h +++ b/platform/darwin/src/MGLAttributionInfo.h @@ -12,7 +12,7 @@ NS_ASSUME_NONNULL_BEGIN */ @interface MGLAttributionInfo : NSObject -- (instancetype)initWithTitle:(NSAttributedString *)title URL:(NSURL *)URL; +- (instancetype)initWithTitle:(NSAttributedString *)title URL:(nullable NSURL *)URL; @property (nonatomic) NSAttributedString *title; @property (nonatomic, nullable) NSURL *URL; diff --git a/platform/macos/macos.xcodeproj/project.pbxproj b/platform/macos/macos.xcodeproj/project.pbxproj index deda02b08ce..92d33c74c48 100644 --- a/platform/macos/macos.xcodeproj/project.pbxproj +++ b/platform/macos/macos.xcodeproj/project.pbxproj @@ -173,6 +173,8 @@ DAED38601D62CED700D7640F /* NSURL+MGLAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = DAED385E1D62CED700D7640F /* NSURL+MGLAdditions.m */; }; DAED38671D62D2EB00D7640F /* amsterdam.geojson in Resources */ = {isa = PBXBuildFile; fileRef = DAED38591D627FF400D7640F /* amsterdam.geojson */; }; DAEDC4321D6033F1000224FF /* MGLAttributionInfoTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = DAEDC4311D6033F1000224FF /* MGLAttributionInfoTests.mm */; }; + DAEDC4351D606247000224FF /* libmbgl-core.a in Frameworks */ = {isa = PBXBuildFile; fileRef = DAE6C3451CC31D1200DB3429 /* libmbgl-core.a */; }; + DAEDC4371D606291000224FF /* MGLAttributionButtonTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = DAEDC4361D606291000224FF /* MGLAttributionButtonTests.mm */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -397,6 +399,7 @@ DAED385D1D62CED700D7640F /* NSURL+MGLAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSURL+MGLAdditions.h"; sourceTree = ""; }; DAED385E1D62CED700D7640F /* NSURL+MGLAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSURL+MGLAdditions.m"; sourceTree = ""; }; DAEDC4311D6033F1000224FF /* MGLAttributionInfoTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLAttributionInfoTests.mm; path = ../../darwin/test/MGLAttributionInfoTests.mm; sourceTree = ""; }; + DAEDC4361D606291000224FF /* MGLAttributionButtonTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLAttributionButtonTests.mm; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -738,6 +741,7 @@ isa = PBXGroup; children = ( DA8F257D1D51C5F40010E6B5 /* Styling */, + DAEDC4361D606291000224FF /* MGLAttributionButtonTests.mm */, DAEDC4311D6033F1000224FF /* MGLAttributionInfoTests.mm */, DA35A2C11CCA9F4A00E826B2 /* MGLClockDirectionFormatterTests.m */, DA35A2B51CCA14D700E826B2 /* MGLCompassDirectionFormatterTests.m */, @@ -1135,6 +1139,7 @@ DA35A2C21CCA9F4A00E826B2 /* MGLClockDirectionFormatterTests.m in Sources */, DAE6C3D41CC34C9900DB3429 /* MGLOfflineRegionTests.m in Sources */, DAE6C3D61CC34C9900DB3429 /* MGLStyleTests.mm in Sources */, + DAEDC4371D606291000224FF /* MGLAttributionButtonTests.mm in Sources */, DA35A2B61CCA14D700E826B2 /* MGLCompassDirectionFormatterTests.m in Sources */, DAE6C3D21CC34C9900DB3429 /* MGLGeometryTests.mm in Sources */, DAE6C3D51CC34C9900DB3429 /* MGLOfflineStorageTests.m in Sources */, diff --git a/platform/macos/test/MGLAttributionButtonTests.mm b/platform/macos/test/MGLAttributionButtonTests.mm new file mode 100644 index 00000000000..f5c0aac8566 --- /dev/null +++ b/platform/macos/test/MGLAttributionButtonTests.mm @@ -0,0 +1,31 @@ +#import +#import + +#import "MGLAttributionButton.h" +#import "MGLAttributionInfo.h" + +@interface MGLAttributionButtonTests : XCTestCase + +@end + +@implementation MGLAttributionButtonTests + +- (void)testPlainSymbol { + NSAttributedString *title = [[NSAttributedString alloc] initWithString:@"® & ™ Mapbox" attributes:@{ + NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle), + }]; + MGLAttributionInfo *info = [[MGLAttributionInfo alloc] initWithTitle:title URL:nil]; + MGLAttributionButton *button = [[MGLAttributionButton alloc] initWithAttributionInfo:info]; + + NSRange symbolUnderlineRange; + NSNumber *symbolUnderline = [button.attributedTitle attribute:NSUnderlineStyleAttributeName atIndex:0 effectiveRange:&symbolUnderlineRange]; + XCTAssertNil(symbolUnderline); + XCTAssertEqual(symbolUnderlineRange.length, 6); + + NSRange wordUnderlineRange; + NSNumber *wordUnderline = [button.attributedTitle attribute:NSUnderlineStyleAttributeName atIndex:6 effectiveRange:&wordUnderlineRange]; + XCTAssertEqualObjects(wordUnderline, @(NSUnderlineStyleSingle)); + XCTAssertEqual(wordUnderlineRange.length, 6); +} + +@end