Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[macos] Test removing underline from IP symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
1ec5 committed Aug 16, 2016
1 parent f52e2a8 commit db19063
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion platform/darwin/src/MGLAttributionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions platform/macos/macos.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -397,6 +399,7 @@
DAED385D1D62CED700D7640F /* NSURL+MGLAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSURL+MGLAdditions.h"; sourceTree = "<group>"; };
DAED385E1D62CED700D7640F /* NSURL+MGLAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSURL+MGLAdditions.m"; sourceTree = "<group>"; };
DAEDC4311D6033F1000224FF /* MGLAttributionInfoTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MGLAttributionInfoTests.mm; path = ../../darwin/test/MGLAttributionInfoTests.mm; sourceTree = "<group>"; };
DAEDC4361D606291000224FF /* MGLAttributionButtonTests.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MGLAttributionButtonTests.mm; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -738,6 +741,7 @@
isa = PBXGroup;
children = (
DA8F257D1D51C5F40010E6B5 /* Styling */,
DAEDC4361D606291000224FF /* MGLAttributionButtonTests.mm */,
DAEDC4311D6033F1000224FF /* MGLAttributionInfoTests.mm */,
DA35A2C11CCA9F4A00E826B2 /* MGLClockDirectionFormatterTests.m */,
DA35A2B51CCA14D700E826B2 /* MGLCompassDirectionFormatterTests.m */,
Expand Down Expand Up @@ -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 */,
Expand Down
31 changes: 31 additions & 0 deletions platform/macos/test/MGLAttributionButtonTests.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#import <Mapbox/Mapbox.h>
#import <XCTest/XCTest.h>

#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

0 comments on commit db19063

Please sign in to comment.