-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix telemetry opt-out through attribution dialog (better fix)
- Loading branch information
Vadim Yeshkunov
committed
Oct 14, 2021
1 parent
d84adc3
commit be5976e
Showing
7 changed files
with
71 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
Tests/MapboxMapsTests/Foundation/Events/EventsManagerTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import XCTest | ||
@testable import MapboxMaps | ||
|
||
final class EventsManagerTests: XCTestCase { | ||
|
||
var eventsManager: EventsManager! | ||
|
||
override func setUp() { | ||
eventsManager = EventsManager(accessToken: "empty") | ||
} | ||
|
||
override func tearDown() { | ||
eventsManager = nil | ||
} | ||
|
||
func testUserDefaultsDynamicProperty() { | ||
UserDefaults.standard.MGLMapboxMetricsEnabled = false | ||
|
||
UserDefaults.standard.MGLMapboxMetricsEnabled = true | ||
XCTAssertEqual(UserDefaults.standard.bool(forKey: "MGLMapboxMetricsEnabled"), true) | ||
|
||
UserDefaults.standard.MGLMapboxMetricsEnabled = false | ||
XCTAssertEqual(UserDefaults.standard.bool(forKey: "MGLMapboxMetricsEnabled"), false) | ||
|
||
UserDefaults.standard.set(true, forKey: "MGLMapboxMetricsEnabled") | ||
XCTAssertEqual(UserDefaults.standard.MGLMapboxMetricsEnabled, true) | ||
|
||
UserDefaults.standard.set(false, forKey: "MGLMapboxMetricsEnabled") | ||
XCTAssertEqual(UserDefaults.standard.MGLMapboxMetricsEnabled, false) | ||
} | ||
|
||
func testMGLMapboxMetricsModifiesMMECollectionDisabled() { | ||
UserDefaults.standard.MGLMapboxMetricsEnabled = false | ||
|
||
let trueExpectation = keyValueObservingExpectation(for: UserDefaults.mme_configuration(), keyPath: "MMECollectionDisabled", expectedValue: false) | ||
UserDefaults.standard.MGLMapboxMetricsEnabled = true | ||
wait(for: [trueExpectation], timeout: 1) | ||
|
||
let falseExpectation = keyValueObservingExpectation(for: UserDefaults.mme_configuration(), keyPath: "MMECollectionDisabled", expectedValue: true) | ||
UserDefaults.standard.MGLMapboxMetricsEnabled = false | ||
wait(for: [falseExpectation], timeout: 1) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters