-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
72 additions
and
7 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
12 changes: 5 additions & 7 deletions
12
DatadogSessionReplay/Sources/Recorder/Utilities/PrivacyLevel+SessionReplay.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
63 changes: 63 additions & 0 deletions
63
DatadogSessionReplay/Tests/SessionReplayOverrideTests.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,63 @@ | ||
/* | ||
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
* This product includes software developed at Datadog (https://www.datadoghq.com/). | ||
* Copyright 2019-Present Datadog, Inc. | ||
*/ | ||
|
||
#if os(iOS) | ||
import XCTest | ||
import UIKit | ||
@testable import DatadogSessionReplay | ||
|
||
class SessionReplayOverrideTests: XCTestCase { | ||
func testWhenNoOverrideIsSet_itDefaultsToNil() { | ||
// Given | ||
let view = UIView() | ||
|
||
// Then | ||
XCTAssertNil(view.dd.sessionReplayOverride.textAndInputPrivacy) | ||
XCTAssertNil(view.dd.sessionReplayOverride.imagePrivacy) | ||
XCTAssertNil(view.dd.sessionReplayOverride.touchPrivacy) | ||
XCTAssertNil(view.dd.sessionReplayOverride.hiddenPrivacy) | ||
} | ||
|
||
func testWithOverrides() { | ||
// Given | ||
var view = UIView() | ||
|
||
// When | ||
view.dd.sessionReplayOverride.textAndInputPrivacy = .maskAllInputs | ||
view.dd.sessionReplayOverride.imagePrivacy = .maskAll | ||
view.dd.sessionReplayOverride.touchPrivacy = .hide | ||
view.dd.sessionReplayOverride.hiddenPrivacy = .hide | ||
|
||
// Then | ||
XCTAssertEqual(view.dd.sessionReplayOverride.textAndInputPrivacy, .maskAllInputs) | ||
XCTAssertEqual(view.dd.sessionReplayOverride.imagePrivacy, .maskAll) | ||
XCTAssertEqual(view.dd.sessionReplayOverride.touchPrivacy, .hide) | ||
XCTAssertEqual(view.dd.sessionReplayOverride.hiddenPrivacy, .hide) | ||
} | ||
|
||
// Test that removing an override sets the property back to nil | ||
func testRemovingOverrides() { | ||
// Given | ||
var view = UIView() | ||
view.dd.sessionReplayOverride.textAndInputPrivacy = .maskAllInputs | ||
view.dd.sessionReplayOverride.imagePrivacy = .maskAll | ||
view.dd.sessionReplayOverride.touchPrivacy = .hide | ||
view.dd.sessionReplayOverride.hiddenPrivacy = .hide | ||
|
||
// When | ||
view.dd.sessionReplayOverride.textAndInputPrivacy = nil | ||
view.dd.sessionReplayOverride.imagePrivacy = nil | ||
view.dd.sessionReplayOverride.touchPrivacy = nil | ||
view.dd.sessionReplayOverride.hiddenPrivacy = nil | ||
|
||
// Then | ||
XCTAssertNil(view.dd.sessionReplayOverride.textAndInputPrivacy) | ||
XCTAssertNil(view.dd.sessionReplayOverride.imagePrivacy) | ||
XCTAssertNil(view.dd.sessionReplayOverride.touchPrivacy) | ||
XCTAssertNil(view.dd.sessionReplayOverride.hiddenPrivacy) | ||
} | ||
} | ||
#endif |