集成高德 SDK 并替换所有定位相关的 CoreLocation 与 MapKit
This commit is contained in:
51
suixinkanTests/AMapBootstrapTests.swift
Normal file
51
suixinkanTests/AMapBootstrapTests.swift
Normal file
@ -0,0 +1,51 @@
|
||||
//
|
||||
// AMapBootstrapTests.swift
|
||||
// suixinkanTests
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import suixinkan
|
||||
|
||||
/// 高德 SDK 初始化 gate 测试。
|
||||
final class AMapBootstrapTests: XCTestCase {
|
||||
|
||||
private var defaults: UserDefaults!
|
||||
private var appStore: AppStore!
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
AMapBootstrap.resetForTesting()
|
||||
defaults = UserDefaults(suiteName: "AMapBootstrapTests")!
|
||||
defaults.removePersistentDomain(forName: "AMapBootstrapTests")
|
||||
appStore = AppStore(defaults: defaults)
|
||||
}
|
||||
|
||||
override func tearDown() {
|
||||
AMapBootstrap.resetForTesting()
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
func testConfigureReturnsFalseWhenPrivacyNotAccepted() {
|
||||
appStore.privacyAgreementAccepted = false
|
||||
|
||||
XCTAssertFalse(AMapBootstrap.configureIfNeeded(appStore: appStore))
|
||||
XCTAssertFalse(AMapBootstrap.isConfigured)
|
||||
}
|
||||
|
||||
func testConfigureIsIdempotentWhenPrivacyAccepted() {
|
||||
appStore.privacyAgreementAccepted = true
|
||||
|
||||
XCTAssertTrue(AMapBootstrap.configureIfNeeded(appStore: appStore))
|
||||
XCTAssertTrue(AMapBootstrap.isConfigured)
|
||||
XCTAssertTrue(AMapBootstrap.configureIfNeeded(appStore: appStore))
|
||||
XCTAssertTrue(AMapBootstrap.isConfigured)
|
||||
}
|
||||
|
||||
func testRequireConfiguredThrowsWhenPrivacyNotAccepted() {
|
||||
appStore.privacyAgreementAccepted = false
|
||||
|
||||
XCTAssertThrowsError(try AMapBootstrap.requireConfigured(appStore: appStore)) { error in
|
||||
XCTAssertEqual(error as? LocationProviderError, .privacyNotAccepted)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user