mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
SwiftUI NavigationController and UserNotificationControllers (#309)
* Fixes #286 - Adopted the new SwiftUI NavigationStack based NavigationController throughout the application * Fixes #315 - Implemented new user notification components on top of SwiftUI and the new navigation flows * Add home screen fade animation between skeletons and real rooms * Bump the danger-swift version used on the CI and swiftlint with it * Renamed Splash to Onboarding, Empty to Splash
This commit is contained in:
@@ -21,7 +21,7 @@ import XCTest
|
||||
@MainActor
|
||||
class BugReportViewModelTests: XCTestCase {
|
||||
func testInitialState() {
|
||||
let viewModel = BugReportViewModel(bugReportService: MockBugReportService(), screenshot: nil)
|
||||
let viewModel = BugReportViewModel(bugReportService: MockBugReportService(), screenshot: nil, isModallyPresented: false)
|
||||
let context = viewModel.context
|
||||
|
||||
XCTAssertEqual(context.reportText, "")
|
||||
@@ -30,7 +30,7 @@ class BugReportViewModelTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testToggleSendingLogs() async throws {
|
||||
let viewModel = BugReportViewModel(bugReportService: MockBugReportService(), screenshot: nil)
|
||||
let viewModel = BugReportViewModel(bugReportService: MockBugReportService(), screenshot: nil, isModallyPresented: false)
|
||||
let context = viewModel.context
|
||||
|
||||
context.send(viewAction: .toggleSendLogs)
|
||||
@@ -39,7 +39,7 @@ class BugReportViewModelTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testClearScreenshot() async throws {
|
||||
let viewModel = BugReportViewModel(bugReportService: MockBugReportService(), screenshot: UIImage.actions)
|
||||
let viewModel = BugReportViewModel(bugReportService: MockBugReportService(), screenshot: UIImage.actions, isModallyPresented: false)
|
||||
let context = viewModel.context
|
||||
|
||||
context.send(viewAction: .removeScreenshot)
|
||||
|
||||
@@ -0,0 +1,221 @@
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
@testable import ElementX
|
||||
|
||||
@MainActor
|
||||
class NavigationControllerTests: XCTestCase {
|
||||
private var navigationController: NavigationController!
|
||||
|
||||
override func setUp() {
|
||||
navigationController = NavigationController()
|
||||
}
|
||||
|
||||
func testRoot() {
|
||||
let rootCoordinator = SomeTestCoordinator()
|
||||
navigationController.setRootCoordinator(rootCoordinator)
|
||||
|
||||
assertCoordinatorsEqual(rootCoordinator, navigationController.rootCoordinator)
|
||||
}
|
||||
|
||||
func testSingleSheet() {
|
||||
let rootCoordinator = SomeTestCoordinator()
|
||||
navigationController.setRootCoordinator(rootCoordinator)
|
||||
|
||||
let coordinator = SomeTestCoordinator()
|
||||
navigationController.presentSheet(coordinator)
|
||||
|
||||
assertCoordinatorsEqual(rootCoordinator, navigationController.rootCoordinator)
|
||||
assertCoordinatorsEqual(coordinator, navigationController.sheetCoordinator)
|
||||
|
||||
navigationController.dismissSheet()
|
||||
|
||||
assertCoordinatorsEqual(rootCoordinator, navigationController.rootCoordinator)
|
||||
XCTAssertNil(navigationController.sheetCoordinator)
|
||||
}
|
||||
|
||||
func testMultipleSheets() {
|
||||
let rootCoordinator = SomeTestCoordinator()
|
||||
navigationController.setRootCoordinator(rootCoordinator)
|
||||
|
||||
let sheetCoordinator = SomeTestCoordinator()
|
||||
navigationController.presentSheet(sheetCoordinator)
|
||||
|
||||
assertCoordinatorsEqual(rootCoordinator, navigationController.rootCoordinator)
|
||||
XCTAssert(navigationController.coordinators.isEmpty)
|
||||
assertCoordinatorsEqual(sheetCoordinator, navigationController.sheetCoordinator)
|
||||
|
||||
let someOtherSheetCoordinator = SomeTestCoordinator()
|
||||
navigationController.presentSheet(someOtherSheetCoordinator)
|
||||
|
||||
assertCoordinatorsEqual(rootCoordinator, navigationController.rootCoordinator)
|
||||
XCTAssert(navigationController.coordinators.isEmpty)
|
||||
assertCoordinatorsEqual(someOtherSheetCoordinator, navigationController.sheetCoordinator)
|
||||
}
|
||||
|
||||
func testSinglePush() {
|
||||
let rootCoordinator = SomeTestCoordinator()
|
||||
navigationController.setRootCoordinator(rootCoordinator)
|
||||
|
||||
let coordinator = SomeTestCoordinator()
|
||||
navigationController.push(coordinator)
|
||||
|
||||
assertCoordinatorsEqual(rootCoordinator, navigationController.rootCoordinator)
|
||||
assertCoordinatorsEqual(coordinator, navigationController.coordinators.first)
|
||||
|
||||
navigationController.pop()
|
||||
|
||||
assertCoordinatorsEqual(rootCoordinator, navigationController.rootCoordinator)
|
||||
XCTAssert(navigationController.coordinators.isEmpty)
|
||||
}
|
||||
|
||||
func testMultiplePushes() {
|
||||
let rootCoordinator = SomeTestCoordinator()
|
||||
navigationController.setRootCoordinator(rootCoordinator)
|
||||
|
||||
var coordinators = [CoordinatorProtocol]()
|
||||
for _ in 0...10 {
|
||||
let coordinator = SomeTestCoordinator()
|
||||
coordinators.append(coordinator)
|
||||
navigationController.push(coordinator)
|
||||
}
|
||||
|
||||
assertCoordinatorsEqual(rootCoordinator, navigationController.rootCoordinator)
|
||||
XCTAssertEqual(navigationController.coordinators.count, coordinators.count)
|
||||
|
||||
for index in coordinators.indices {
|
||||
assertCoordinatorsEqual(coordinators[index], navigationController.coordinators[index])
|
||||
}
|
||||
|
||||
navigationController.popToRoot()
|
||||
|
||||
assertCoordinatorsEqual(rootCoordinator, navigationController.rootCoordinator)
|
||||
XCTAssert(navigationController.coordinators.isEmpty)
|
||||
}
|
||||
|
||||
func testRootReplacementDimissesTheRest() {
|
||||
let rootCoordinator = SomeTestCoordinator()
|
||||
navigationController.setRootCoordinator(rootCoordinator)
|
||||
|
||||
let sheetCoordinator = SomeTestCoordinator()
|
||||
navigationController.presentSheet(sheetCoordinator)
|
||||
|
||||
let pushedCoordinator = SomeTestCoordinator()
|
||||
navigationController.push(pushedCoordinator)
|
||||
|
||||
assertCoordinatorsEqual(rootCoordinator, navigationController.rootCoordinator)
|
||||
assertCoordinatorsEqual(pushedCoordinator, navigationController.coordinators.first)
|
||||
assertCoordinatorsEqual(sheetCoordinator, navigationController.sheetCoordinator)
|
||||
|
||||
let newRootCoordinator = SomeTestCoordinator()
|
||||
navigationController.setRootCoordinator(newRootCoordinator)
|
||||
|
||||
assertCoordinatorsEqual(newRootCoordinator, navigationController.rootCoordinator)
|
||||
XCTAssert(navigationController.coordinators.isEmpty)
|
||||
XCTAssertNil(navigationController.sheetCoordinator)
|
||||
}
|
||||
|
||||
func testPushesDontReplaceSheet() {
|
||||
let sheetCoordinator = SomeTestCoordinator()
|
||||
navigationController.presentSheet(sheetCoordinator)
|
||||
|
||||
let pushedCoordinator = SomeTestCoordinator()
|
||||
navigationController.push(pushedCoordinator)
|
||||
|
||||
assertCoordinatorsEqual(pushedCoordinator, navigationController.coordinators.first)
|
||||
assertCoordinatorsEqual(sheetCoordinator, navigationController.sheetCoordinator)
|
||||
|
||||
let newlyPushedCoordinator = SomeTestCoordinator()
|
||||
navigationController.push(newlyPushedCoordinator)
|
||||
|
||||
assertCoordinatorsEqual(pushedCoordinator, navigationController.coordinators.first)
|
||||
assertCoordinatorsEqual(newlyPushedCoordinator, navigationController.coordinators.last)
|
||||
assertCoordinatorsEqual(sheetCoordinator, navigationController.sheetCoordinator)
|
||||
}
|
||||
|
||||
func testPopDismissalCallbacks() {
|
||||
let pushedCoordinator = SomeTestCoordinator()
|
||||
|
||||
let expectation = expectation(description: "Wait for callback")
|
||||
navigationController.push(pushedCoordinator) {
|
||||
expectation.fulfill()
|
||||
}
|
||||
|
||||
navigationController.pop()
|
||||
waitForExpectations(timeout: 1.0)
|
||||
}
|
||||
|
||||
func testPopToRootDismissalCallbacks() {
|
||||
navigationController.push(SomeTestCoordinator())
|
||||
navigationController.push(SomeTestCoordinator())
|
||||
|
||||
let coordinator = SomeTestCoordinator()
|
||||
let expectation = expectation(description: "Wait for callback")
|
||||
navigationController.push(coordinator) {
|
||||
expectation.fulfill()
|
||||
}
|
||||
|
||||
navigationController.popToRoot()
|
||||
waitForExpectations(timeout: 1.0)
|
||||
}
|
||||
|
||||
func testSheetDismissalCallbac() {
|
||||
let coordinator = SomeTestCoordinator()
|
||||
let expectation = expectation(description: "Wait for callback")
|
||||
navigationController.presentSheet(coordinator) {
|
||||
expectation.fulfill()
|
||||
}
|
||||
|
||||
navigationController.dismissSheet()
|
||||
waitForExpectations(timeout: 1.0)
|
||||
}
|
||||
|
||||
func testRootReplacmeentCallbacks() {
|
||||
navigationController.setRootCoordinator(SomeTestCoordinator())
|
||||
|
||||
let popExpectation = expectation(description: "Waiting for callback")
|
||||
navigationController.push(SomeTestCoordinator()) {
|
||||
popExpectation.fulfill()
|
||||
}
|
||||
|
||||
let sheetExpectation = expectation(description: "Waiting for callback")
|
||||
navigationController.presentSheet(SomeTestCoordinator()) {
|
||||
sheetExpectation.fulfill()
|
||||
}
|
||||
|
||||
navigationController.setRootCoordinator(SomeTestCoordinator())
|
||||
|
||||
waitForExpectations(timeout: 1.0)
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
|
||||
private func assertCoordinatorsEqual(_ lhs: CoordinatorProtocol?, _ rhs: CoordinatorProtocol?) {
|
||||
guard let lhs = lhs as? SomeTestCoordinator,
|
||||
let rhs = rhs as? SomeTestCoordinator else {
|
||||
XCTFail("Coordinators are not the same")
|
||||
return
|
||||
}
|
||||
|
||||
XCTAssertEqual(lhs.id, rhs.id)
|
||||
}
|
||||
}
|
||||
|
||||
private struct SomeTestCoordinator: CoordinatorProtocol {
|
||||
let id = UUID()
|
||||
}
|
||||
+1
-1
@@ -18,6 +18,6 @@ import XCTest
|
||||
|
||||
@testable import ElementX
|
||||
|
||||
class SplashScreenViewModelTests: XCTestCase {
|
||||
class OnboardingViewModelTests: XCTestCase {
|
||||
// Nothing to test, the view model has no mutable state.
|
||||
}
|
||||
@@ -28,7 +28,7 @@ class ServerSelectionViewModelTests: XCTestCase {
|
||||
var context: ServerSelectionViewModelType.Context!
|
||||
|
||||
@MainActor override func setUp() {
|
||||
viewModel = ServerSelectionViewModel(homeserverAddress: "", hasModalPresentation: true)
|
||||
viewModel = ServerSelectionViewModel(homeserverAddress: "", isModallyPresented: true)
|
||||
context = viewModel.context
|
||||
}
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
@testable import ElementX
|
||||
import Foundation
|
||||
|
||||
class UserIndicatorPresenterSpy: UserIndicatorViewPresentable {
|
||||
var intel = [String]()
|
||||
|
||||
func present() {
|
||||
intel.append(#function)
|
||||
}
|
||||
|
||||
func dismiss() {
|
||||
intel.append(#function)
|
||||
}
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
@testable import ElementX
|
||||
import Foundation
|
||||
import XCTest
|
||||
|
||||
class UserIndicatorQueueTests: XCTestCase {
|
||||
var indicators: [UserIndicator]!
|
||||
var queue: UserIndicatorQueue!
|
||||
|
||||
override func setUp() {
|
||||
indicators = []
|
||||
queue = UserIndicatorQueue()
|
||||
}
|
||||
|
||||
func makeRequest() -> UserIndicatorRequest {
|
||||
UserIndicatorRequest(
|
||||
presenter: UserIndicatorPresenterSpy(),
|
||||
dismissal: .manual
|
||||
)
|
||||
}
|
||||
|
||||
func testStartsIndicatorWhenAdded() {
|
||||
let indicator = queue.add(makeRequest())
|
||||
XCTAssertEqual(indicator.state, .executing)
|
||||
}
|
||||
|
||||
func testSecondIndicatorIsPending() {
|
||||
queue.add(makeRequest()).store(in: &indicators)
|
||||
let indicator = queue.add(makeRequest())
|
||||
XCTAssertEqual(indicator.state, .pending)
|
||||
}
|
||||
|
||||
func testSecondIndicatorIsExecutingWhenFirstCompleted() {
|
||||
let first = queue.add(makeRequest())
|
||||
let second = queue.add(makeRequest())
|
||||
|
||||
first.cancel()
|
||||
|
||||
XCTAssertEqual(second.state, .executing)
|
||||
}
|
||||
}
|
||||
@@ -1,128 +0,0 @@
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
@testable import ElementX
|
||||
import Foundation
|
||||
import XCTest
|
||||
|
||||
class UserIndicatorTests: XCTestCase {
|
||||
var presenter: UserIndicatorPresenterSpy!
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
presenter = UserIndicatorPresenterSpy()
|
||||
}
|
||||
|
||||
func makeIndicator(dismissal: UserIndicatorDismissal = .manual, callback: @escaping () -> Void = { }) -> UserIndicator {
|
||||
let request = UserIndicatorRequest(
|
||||
presenter: presenter,
|
||||
dismissal: dismissal
|
||||
)
|
||||
return UserIndicator(
|
||||
request: request,
|
||||
completion: callback
|
||||
)
|
||||
}
|
||||
|
||||
// MARK: - State
|
||||
|
||||
func testNewIndicatorIsPending() {
|
||||
let indicator = makeIndicator()
|
||||
XCTAssertEqual(indicator.state, .pending)
|
||||
}
|
||||
|
||||
func testStartedIndicatorIsExecuting() {
|
||||
let indicator = makeIndicator()
|
||||
indicator.start()
|
||||
XCTAssertEqual(indicator.state, .executing)
|
||||
}
|
||||
|
||||
func testCancelledIndicatorIsCompleted() {
|
||||
let indicator = makeIndicator()
|
||||
indicator.cancel()
|
||||
XCTAssertEqual(indicator.state, .completed)
|
||||
}
|
||||
|
||||
// MARK: - Presenter
|
||||
|
||||
func testStartingIndicatorPresentsUI() {
|
||||
let indicator = makeIndicator()
|
||||
indicator.start()
|
||||
XCTAssertEqual(presenter.intel, ["present()"])
|
||||
}
|
||||
|
||||
func testAllowStartingOnlyOnce() {
|
||||
let indicator = makeIndicator()
|
||||
indicator.start()
|
||||
presenter.intel = []
|
||||
|
||||
indicator.start()
|
||||
|
||||
XCTAssertEqual(presenter.intel, [])
|
||||
}
|
||||
|
||||
func testCancellingIndicatorDismissesUI() {
|
||||
let indicator = makeIndicator()
|
||||
indicator.start()
|
||||
presenter.intel = []
|
||||
|
||||
indicator.cancel()
|
||||
|
||||
XCTAssertEqual(presenter.intel, ["dismiss()"])
|
||||
}
|
||||
|
||||
func testAllowCancellingOnlyOnce() {
|
||||
let indicator = makeIndicator()
|
||||
indicator.start()
|
||||
indicator.cancel()
|
||||
presenter.intel = []
|
||||
|
||||
indicator.cancel()
|
||||
|
||||
XCTAssertEqual(presenter.intel, [])
|
||||
}
|
||||
|
||||
// MARK: - Dismissal
|
||||
|
||||
func testDismissAfterTimeout() {
|
||||
let interval: TimeInterval = 0.01
|
||||
let indicator = makeIndicator(dismissal: .timeout(interval))
|
||||
|
||||
indicator.start()
|
||||
|
||||
let exp = expectation(description: "")
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + interval) {
|
||||
exp.fulfill()
|
||||
}
|
||||
waitForExpectations(timeout: 1)
|
||||
|
||||
XCTAssertEqual(indicator.state, .completed)
|
||||
}
|
||||
|
||||
// MARK: - Completion callback
|
||||
|
||||
func testTriggersCallbackWhenCompleted() {
|
||||
var didComplete = false
|
||||
let indicator = makeIndicator {
|
||||
didComplete = true
|
||||
}
|
||||
indicator.start()
|
||||
|
||||
indicator.cancel()
|
||||
|
||||
XCTAssertTrue(didComplete)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
//
|
||||
// Copyright 2022 New Vector Ltd
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
import XCTest
|
||||
|
||||
@testable import ElementX
|
||||
|
||||
@MainActor
|
||||
class UserNotificationControllerTests: XCTestCase {
|
||||
private var notificationController: UserNotificationController!
|
||||
|
||||
override func setUp() {
|
||||
notificationController = UserNotificationController(rootCoordinator: SplashScreenCoordinator())
|
||||
}
|
||||
|
||||
func testNotificationQueueing() {
|
||||
notificationController.minimumDisplayDuration = 0.0
|
||||
|
||||
notificationController.submitNotification(.init(id: "First", title: ""))
|
||||
notificationController.submitNotification(.init(id: "Second", title: ""))
|
||||
notificationController.submitNotification(.init(id: "Third", title: ""))
|
||||
|
||||
XCTAssertEqual(notificationController.notificationQueue.count, 3)
|
||||
XCTAssertEqual(notificationController.notificationQueue[2].id, "Third")
|
||||
XCTAssertEqual(notificationController.notificationQueue[1].id, "Second")
|
||||
XCTAssertEqual(notificationController.notificationQueue[0].id, "First")
|
||||
|
||||
notificationController.retractNotificationWithId("Second")
|
||||
|
||||
XCTAssertEqual(notificationController.notificationQueue.count, 2)
|
||||
XCTAssertEqual(notificationController.notificationQueue[1].id, "Third")
|
||||
XCTAssertEqual(notificationController.notificationQueue[0].id, "First")
|
||||
|
||||
notificationController.retractAllNotifications()
|
||||
|
||||
XCTAssertEqual(notificationController.notificationQueue.count, 0)
|
||||
}
|
||||
|
||||
func testChainedPresentation() {
|
||||
notificationController.minimumDisplayDuration = 0.25
|
||||
notificationController.nonPersistentDisplayDuration = 2.5
|
||||
|
||||
notificationController.submitNotification(.init(id: "First", title: ""))
|
||||
notificationController.submitNotification(.init(id: "Second", title: ""))
|
||||
notificationController.submitNotification(.init(id: "Third", title: ""))
|
||||
|
||||
XCTAssertEqual(notificationController.activeNotification?.id, "Third")
|
||||
|
||||
let expectation = expectation(description: "Waiting for last notification to be dismissed")
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + notificationController.nonPersistentDisplayDuration) {
|
||||
expectation.fulfill()
|
||||
}
|
||||
|
||||
waitForExpectations(timeout: 5.0)
|
||||
|
||||
XCTAssertEqual(notificationController.notificationQueue.count, 2)
|
||||
XCTAssertEqual(notificationController.activeNotification?.id, "Second")
|
||||
}
|
||||
|
||||
func testMinimumDisplayDuration() {
|
||||
notificationController.minimumDisplayDuration = 0.25
|
||||
notificationController.nonPersistentDisplayDuration = 2.5
|
||||
|
||||
notificationController.submitNotification(.init(id: "First", title: ""))
|
||||
notificationController.submitNotification(.init(id: "Second", title: ""))
|
||||
notificationController.submitNotification(.init(id: "Third", title: ""))
|
||||
|
||||
notificationController.retractNotificationWithId("Second")
|
||||
|
||||
XCTAssertEqual(notificationController.notificationQueue.count, 3)
|
||||
|
||||
let dismissalExpectation = expectation(description: "Waiting for minimum display duration to pass")
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + notificationController.minimumDisplayDuration) {
|
||||
dismissalExpectation.fulfill()
|
||||
}
|
||||
|
||||
waitForExpectations(timeout: 5.0)
|
||||
|
||||
XCTAssertEqual(notificationController.notificationQueue.count, 2)
|
||||
XCTAssertEqual(notificationController.activeNotification?.id, "Third")
|
||||
|
||||
let dismissalExpectation2 = expectation(description: "Waiting for last notification to be dismissed")
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + notificationController.nonPersistentDisplayDuration) {
|
||||
dismissalExpectation2.fulfill()
|
||||
}
|
||||
|
||||
waitForExpectations(timeout: 5.0)
|
||||
|
||||
XCTAssertEqual(notificationController.notificationQueue.count, 1)
|
||||
XCTAssertEqual(notificationController.activeNotification?.id, "First")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user