Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  ViewModelTests.swift   Sprache: JAVA

 

import Foundation
import ThreemaEssentials
import XCTest

@testable import GroupCalls

final class GroupCallViewModelTests: XCTestCase {
    fileprivate let lock = NSLock()
    fileprivate var navigationContentUpdates = [GroupCallNavigationBarContentUpdate]()
    fileprivate var navigationContentUpdateExpectation: XCTestExpectation?

    fileprivate var closed = false
    fileprivate lazy var creatorIdentity = ThreemaIdentity("ECHOECHO")
    fileprivate lazy var groupIdentity = GroupIdentity(id: Data(repeating: 0x00, count: 8), creator: creatorIdentity)
    fileprivate lazy var localContactModel = ContactModel(identity: creatorIdentity, nickname: "ECHOECHO")
    fileprivate lazy var groupModel = GroupCallThreemaGroupModel(groupIdentity: groupIdentity, groupName: "TESTGROUP")
    fileprivate lazy var sfuBaseURL = URL(string: "sfu.threema.test")!

    /// A `connected` event is handled by the view model and updates the navigation bar
    func testConnectedEventUpdatesNavigationBar() async throws {
        let dependencies = MockDependencies().create()
        let groupCallActor = try GroupCallActor(
            localContactModel: localContactModel,
            groupModel: groupModel,
            sfuBaseURL: sfuBaseURL,
            gck: Data(repeating: 0x01, count: 32),
            dependencies: dependencies
        )

        // We use the view model of the actor. Creating a second one is not allowed, see the `didSet` of `viewModel`.
        let viewModel = await groupCallActor.viewModel
        viewModel.setViewDelegate(self)

        let expectation = XCTestExpectation(description: "Navigation content was updated")
        lock.withLock {
            navigationContentUpdateExpectation = expectation
        }

        await groupCallActor.uiContinuation.yield(.connected)

        await fulfillment(of: [expectation], timeout: 10)

        let lastUpdate = try XCTUnwrap(lock.withLock { navigationContentUpdates.last })
        XCTAssertEqual(lastUpdate.title, "group_call_navbar_state_connected")
    }
}

// MARK: - GroupCallViewModelDelegate

extension GroupCallViewModelTests: GroupCallViewModelDelegate {
    func showRecordAudioPermissionAlert() { }
    
    func showRecordVideoPermissionAlert() { }
    
    func updateCollectionViewLayout() { }
    
    func dismissGroupCallView(animated: Bool) async {
        closed = true
    }

    func updateNavigationContent(_ contentUpdate: GroupCalls.GroupCallNavigationBarContentUpdate) async {
        let expectation = lock.withLock {
            navigationContentUpdates.append(contentUpdate)
            return navigationContentUpdateExpectation
        }

        expectation?.fulfill()
    }
}

Messung
CHZG
829710093

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover


Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=1104845
#Domains=499266