|
1 | 1 | #import <Mapbox/Mapbox.h> |
2 | 2 | #import <XCTest/XCTest.h> |
3 | | -#import "MGLRendererConfiguration.h" |
| 3 | +#import "MGLRendererConfiguration_Private.h" |
4 | 4 |
|
5 | 5 | static NSString * const MGLRendererConfigurationTests_collisionBehaviorKey = @"MGLCollisionBehaviorPre4_0"; |
6 | 6 |
|
@@ -159,4 +159,95 @@ - (void)testSettingMGLIdeographicFontFamilyNameWithPlistValue { |
159 | 159 | } |
160 | 160 | } |
161 | 161 |
|
| 162 | +- (void)testMGLGlyphsRasterizationModeWithPlistValue { |
| 163 | + MGLRendererConfiguration *config = [[MGLRendererConfiguration alloc] init]; |
| 164 | + |
| 165 | + // `MGLGlyphsRasterizationMode` set to nil or not set. |
| 166 | + { |
| 167 | + MGLGlyphsRasterizationMode mode = [config glyphsRasterizationModeWithInfoDictionaryObject:nil]; |
| 168 | + |
| 169 | + XCTAssertEqual(mode, MGLGlyphsRasterizationModeNone, @"Glyphs rasterization mode should be `MGLGlyphsRasterizationModeNone` when it setting to nil or not set"); |
| 170 | + } |
| 171 | + |
| 172 | + // `MGLGlyphsRasterizationMode` set to invalid value. |
| 173 | + { |
| 174 | + MGLGlyphsRasterizationMode mode = [config glyphsRasterizationModeWithInfoDictionaryObject:@"invalide option value"]; |
| 175 | + |
| 176 | + XCTAssertEqual(mode, MGLGlyphsRasterizationModeNone, @"Glyphs rasterization mode should be `MGLGlyphsRasterizationModeNone` when it setting to invalid value."); |
| 177 | + } |
| 178 | + |
| 179 | + // `MGLGlyphsRasterizationMode` set to "MGLNoGlyphsRasterizedLocally". |
| 180 | + { |
| 181 | + MGLGlyphsRasterizationMode mode = [config glyphsRasterizationModeWithInfoDictionaryObject:@"MGLNoGlyphsRasterizedLocally"]; |
| 182 | + |
| 183 | + XCTAssertEqual(mode, MGLGlyphsRasterizationModeNoGlyphsRasterizedLocally, @"Glyphs rasterization mode should be `MGLGlyphsRasterizationModeNoGlyphsRasterizedLocally`."); |
| 184 | + } |
| 185 | + |
| 186 | + // `MGLGlyphsRasterizationMode` set to "MGLGlyphsRasterizationModeIdeographsRasterizedLocally". |
| 187 | + { |
| 188 | + MGLGlyphsRasterizationMode mode = [config glyphsRasterizationModeWithInfoDictionaryObject:@"MGLIdeographsRasterizedLocally"]; |
| 189 | + |
| 190 | + XCTAssertEqual(mode, MGLGlyphsRasterizationModeIdeographsRasterizedLocally, @"Glyphs rasterization mode should be `MGLGlyphsRasterizationModeIdeographsRasterizedLocally`."); |
| 191 | + } |
| 192 | + |
| 193 | + // `MGLGlyphsRasterizationMode` set to "MGLAllGlyphsRasterizedLocally". |
| 194 | + { |
| 195 | + MGLGlyphsRasterizationMode mode = [config glyphsRasterizationModeWithInfoDictionaryObject:@"MGLAllGlyphsRasterizedLocally"]; |
| 196 | + |
| 197 | + XCTAssertEqual(mode, MGLGlyphsRasterizationModeAllGlyphsRasterizedLocally, @"Glyphs rasterization mode should be `MGLAllGlyphsRasterizedLocally`."); |
| 198 | + } |
| 199 | +} |
| 200 | + |
| 201 | +- (void)testGlyphsRasterizationOptions { |
| 202 | + MGLRendererConfiguration *config = [[MGLRendererConfiguration alloc] init]; |
| 203 | + |
| 204 | + // `MGLIdeographicFontFamilyName` unset, MGLGlyphsRasterizationMode set to AllGlyphsRasterizedLocally. |
| 205 | + { |
| 206 | + mbgl::GlyphsRasterizationOptions options = [config glyphsRasterizationOptionsWithLocalFontFamilyName:nil rasterizationMode:MGLGlyphsRasterizationModeAllGlyphsRasterizedLocally]; |
| 207 | + |
| 208 | + XCTAssertEqual(options.fontFamily, mbgl::nullopt, @"Font family name should be `nullptr`"); |
| 209 | + XCTAssertEqual(options.rasterizationMode, mbgl::GlyphsRasterizationMode::NoGlyphsRasterizedLocally, @"Glyphs rasterization mode should be `NoGlyphsRasterizedLocally`"); |
| 210 | + } |
| 211 | + |
| 212 | + // `MGLIdeographicFontFamilyName` unset, MGLGlyphsRasterizationMode set to NoGlyphsRasterizedLocally. |
| 213 | + { |
| 214 | + mbgl::GlyphsRasterizationOptions options = [config glyphsRasterizationOptionsWithLocalFontFamilyName:nil rasterizationMode:MGLGlyphsRasterizationModeNoGlyphsRasterizedLocally]; |
| 215 | + |
| 216 | + XCTAssertEqual(options.fontFamily, mbgl::nullopt, @"Font family name should be `nullptr`"); |
| 217 | + XCTAssertEqual(options.rasterizationMode, mbgl::GlyphsRasterizationMode::NoGlyphsRasterizedLocally, @"Glyphs rasterization mode should be `NoGlyphsRasterizedLocally`"); |
| 218 | + } |
| 219 | + |
| 220 | + // `MGLIdeographicFontFamilyName` set to "Ping Fang", MGLGlyphsRasterizationMode set to IdeographsRasterizedLocally. |
| 221 | + { |
| 222 | + mbgl::GlyphsRasterizationOptions options = [config glyphsRasterizationOptionsWithLocalFontFamilyName:@"Ping Fang" rasterizationMode:MGLGlyphsRasterizationModeIdeographsRasterizedLocally]; |
| 223 | + |
| 224 | + XCTAssertEqual(options.fontFamily, std::string(@"Ping Fang".UTF8String), @"Font family name should be `Ping Fang`"); |
| 225 | + XCTAssertEqual(options.rasterizationMode, mbgl::GlyphsRasterizationMode::IdeographsRasterizedLocally, @"Glyphs rasterization mode should be `IdeographsRasterizedLocally`"); |
| 226 | + } |
| 227 | + |
| 228 | + // `MGLIdeographicFontFamilyName` set to "Ping Fang", MGLGlyphsRasterizationMode set to NoGlyphsRasterizedLocally. |
| 229 | + { |
| 230 | + mbgl::GlyphsRasterizationOptions options = [config glyphsRasterizationOptionsWithLocalFontFamilyName:@"Ping Fang" rasterizationMode:MGLGlyphsRasterizationModeNoGlyphsRasterizedLocally]; |
| 231 | + |
| 232 | + XCTAssertEqual(options.fontFamily, std::string(@"Ping Fang".UTF8String), @"Font family name should be `Ping Fang`"); |
| 233 | + XCTAssertEqual(options.rasterizationMode, mbgl::GlyphsRasterizationMode::NoGlyphsRasterizedLocally, @"Glyphs rasterization mode should be `NoGlyphsRasterizedLocally`"); |
| 234 | + } |
| 235 | + |
| 236 | + // `MGLIdeographicFontFamilyName` set to "Ping Fang", MGLGlyphsRasterizationMode set to AllGlyphsRasterizedLocally. |
| 237 | + { |
| 238 | + mbgl::GlyphsRasterizationOptions options = [config glyphsRasterizationOptionsWithLocalFontFamilyName:@"Ping Fang" rasterizationMode:MGLGlyphsRasterizationModeAllGlyphsRasterizedLocally]; |
| 239 | + |
| 240 | + XCTAssertEqual(options.fontFamily, std::string(@"Ping Fang".UTF8String), @"Font family name should be `Ping Fang`"); |
| 241 | + XCTAssertEqual(options.rasterizationMode, mbgl::GlyphsRasterizationMode::AllGlyphsRasterizedLocally, @"Glyphs rasterization mode should be `AllGlyphsRasterizedLocally`"); |
| 242 | + } |
| 243 | + |
| 244 | + // `MGLIdeographicFontFamilyName` set to "Ping Fang", MGLGlyphsRasterizationMode unset. |
| 245 | + { |
| 246 | + mbgl::GlyphsRasterizationOptions options = [config glyphsRasterizationOptionsWithLocalFontFamilyName:@"Ping Fang" rasterizationMode:MGLGlyphsRasterizationModeNone]; |
| 247 | + |
| 248 | + XCTAssertEqual(options.fontFamily, std::string(@"Ping Fang".UTF8String), @"Font family name should be `Ping Fang`"); |
| 249 | + XCTAssertEqual(options.rasterizationMode, mbgl::GlyphsRasterizationMode::NoGlyphsRasterizedLocally, @"Glyphs rasterization mode should be `NoGlyphsRasterizedLocally`"); |
| 250 | + } |
| 251 | +} |
| 252 | + |
162 | 253 | @end |
0 commit comments