mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Refactor the MapTiler configuration into a single place. (#3944)
* Refactor the MapTiler configuration into a single place. * Merge the MapAssets catalog into the normal one.
This commit is contained in:
+14
-8
@@ -9,38 +9,44 @@ import CoreLocation
|
||||
@testable import ElementX
|
||||
import XCTest
|
||||
|
||||
final class MapTilerURLBuildersTests: XCTestCase {
|
||||
final class MapTilerURLBuilderTests: XCTestCase {
|
||||
private static let baseURL: URL = "http://www.foo.com"
|
||||
private static let apiKey = "some_key"
|
||||
private static let lightStyleID = "9bc819c8-e627-474a-a348-ec144fe3d810"
|
||||
private static let darkStyleID = "dea61faf-292b-4774-9660-58fcef89a7f3"
|
||||
|
||||
var builder: MapTilerURLBuilderProtocol!
|
||||
|
||||
override func setUp() {
|
||||
builder = MapTilerConfiguration(baseURL: Self.baseURL,
|
||||
apiKey: Self.apiKey,
|
||||
lightStyleID: Self.lightStyleID,
|
||||
darkStyleID: Self.darkStyleID)
|
||||
}
|
||||
|
||||
func testStaticMapBuilder() {
|
||||
let builder = MapTilerStaticMap(baseURL: Self.baseURL, key: Self.apiKey)
|
||||
|
||||
let url = builder.staticMapURL(for: .light,
|
||||
coordinates: .init(latitude: 1, longitude: 2),
|
||||
zoomLevel: 5,
|
||||
size: .init(width: 300, height: 200),
|
||||
attribution: .hidden)
|
||||
|
||||
let expectedURL: URL = "http://www.foo.com/9bc819c8-e627-474a-a348-ec144fe3d810/static/2.000000,1.000000,5.000000/300x200@2x.png?attribution=false&key=some_key"
|
||||
let expectedURL: URL = "http://www.foo.com/9bc819c8-e627-474a-a348-ec144fe3d810/static/2.000000,1.000000,5.000000/300x200@2x.png?key=some_key&attribution=false"
|
||||
XCTAssertEqual(url, expectedURL)
|
||||
}
|
||||
|
||||
func testStaticMapBuilderWithAttribution() {
|
||||
let builder = MapTilerStaticMap(baseURL: Self.baseURL, key: Self.apiKey)
|
||||
|
||||
let url = builder.staticMapURL(for: .dark,
|
||||
coordinates: .init(latitude: 1, longitude: 2),
|
||||
zoomLevel: 5,
|
||||
size: .init(width: 300, height: 200),
|
||||
attribution: .topLeft)
|
||||
|
||||
let expectedURL: URL = "http://www.foo.com/dea61faf-292b-4774-9660-58fcef89a7f3/static/2.000000,1.000000,5.000000/300x200@2x.png?attribution=topleft&key=some_key"
|
||||
let expectedURL: URL = "http://www.foo.com/dea61faf-292b-4774-9660-58fcef89a7f3/static/2.000000,1.000000,5.000000/300x200@2x.png?key=some_key&attribution=topleft"
|
||||
XCTAssertEqual(url, expectedURL)
|
||||
}
|
||||
|
||||
func testDynamicMapBuilder() {
|
||||
let builder = MapTilerStyleBuilder(baseURL: Self.baseURL, key: Self.apiKey)
|
||||
let url = builder.dynamicMapURL(for: .dark)
|
||||
let expectedURL: URL = "http://www.foo.com/dea61faf-292b-4774-9660-58fcef89a7f3/style.json?key=some_key"
|
||||
XCTAssertEqual(url, expectedURL)
|
||||
@@ -22,7 +22,8 @@ class StaticLocationScreenViewModelTests: XCTestCase {
|
||||
|
||||
override func setUpWithError() throws {
|
||||
cancellables.removeAll()
|
||||
let viewModel = StaticLocationScreenViewModel(interactionMode: .picker)
|
||||
let viewModel = StaticLocationScreenViewModel(interactionMode: .picker,
|
||||
mapURLBuilder: ServiceLocator.shared.settings.mapTilerConfiguration)
|
||||
viewModel.state.bindings.isLocationAuthorized = true
|
||||
self.viewModel = viewModel
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user