-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix player observability in response to media accessibility updates (#…
…1061) Co-authored-by: Walid Kayhal <[email protected]>
- Loading branch information
Showing
15 changed files
with
116 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Copyright (c) SRG SSR. All rights reserved. | ||
// | ||
// License information is available from the LICENSE file. | ||
// | ||
|
||
import Combine | ||
import XCTest | ||
|
||
public extension XCTestCase { | ||
/// Expects a publisher to emit at least a value. | ||
func expectValue<P>( | ||
from publisher: P, | ||
timeout: DispatchTimeInterval = .seconds(20), | ||
file: StaticString = #file, | ||
line: UInt = #line, | ||
while executing: (() -> Void)? = nil | ||
) where P: Publisher { | ||
expectSuccess(from: publisher.first(), timeout: timeout, file: file, line: line, while: executing) | ||
} | ||
|
||
/// Expects an observable object to publish at least a change. | ||
func expectChange<O>( | ||
from object: O, | ||
timeout: DispatchTimeInterval = .seconds(20), | ||
file: StaticString = #file, | ||
line: UInt = #line, | ||
while executing: (() -> Void)? = nil | ||
) where O: ObservableObject { | ||
expectValue(from: object.objectWillChange, timeout: timeout, file: file, line: line, while: executing) | ||
} | ||
} |
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
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
40 changes: 40 additions & 0 deletions
40
Tests/CircumspectTests/Expectations/ExpectValueTests.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,40 @@ | ||
// | ||
// Copyright (c) SRG SSR. All rights reserved. | ||
// | ||
// License information is available from the LICENSE file. | ||
// | ||
|
||
@testable import PillarboxCircumspect | ||
|
||
import Combine | ||
import XCTest | ||
|
||
private class Object: ObservableObject { | ||
@Published var value = 0 | ||
} | ||
|
||
final class ExpectValueTests: XCTestCase { | ||
func testSingleValue() { | ||
expectValue(from: Just(1)) | ||
} | ||
|
||
func testMultipleValues() { | ||
expectValue(from: [1, 2, 3].publisher) | ||
} | ||
|
||
func testSingleChange() { | ||
let object = Object() | ||
expectChange(from: object) { | ||
object.value = 1 | ||
} | ||
} | ||
|
||
func testMultipleChanges() { | ||
let object = Object() | ||
expectChange(from: object) { | ||
object.value = 1 | ||
object.value = 2 | ||
object.value = 3 | ||
} | ||
} | ||
} |
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