Files
suixinkan_uikit/suixinkanTests/AMapBootstrapTests.swift
汉秋 cfcd3eee6f Integrate Amap SDK to replace CoreLocation and MapKit for all location features.
Unify GPS, reverse geocoding, and map display behind LocationProvider with privacy-gated bootstrap after login, aligned with Android.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-07 11:49:22 +08:00

52 lines
1.5 KiB
Swift

//
// 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)
}
}
}