Eine aufbereitete Darstellung der Quelle

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

Benutzer

Impressum CallsignalingProtocolTests.swift   Interaktion und
PortierbarkeitJAVA

 

import ThreemaProtocols
import XCTest

@testable import ThreemaFramework

final class CallsignalingProtocolTests: XCTestCase {
    
    /// Helper class.
    
    struct Pair {
        let a: CallsignalingProtocol.ThreemaVideoCallQualityProfiles
        let b: CallsignalingProtocol.ThreemaVideoCallQualityProfiles
    }
    
    func testSerializeProfile() throws {
        // Create a high quality profile
        let highProfile = CallsignalingProtocol.ThreemaVideoCallQualityProfiles.high
        
        // Serialize to protobuf
        guard let bytes: Data = CallsignalingProtocol.encodeVideoQuality(highProfile) else {
            XCTFail("quality profile bytes are empty")
            return
        }
        
        // Deserialize
        guard let envelop: O2oCall_Envelope = try? O2oCall_Envelope(serializedData: bytes) else {
            XCTFail("envelope is nil")
            return
        }
        
        var hasQualityProfile = false
        if envelop.content == .videoQualityProfile(envelop.videoQualityProfile) {
            hasQualityProfile = true
        }
                        
        XCTAssertTrue(hasQualityProfile)
        
        let profile = envelop.videoQualityProfile
        XCTAssertTrue(profile.hasMaxResolution)
        XCTAssertEqual(O2oCall_VideoQualityProfile.QualityProfile.high, profile.profile)
        XCTAssertEqual(2000, profile.maxBitrateKbps)
        XCTAssertEqual(25, profile.maxFps)
        XCTAssertEqual(1280, profile.maxResolution.width)
        XCTAssertEqual(720, profile.maxResolution.height)
    }
    
    func testFindCommonProfileLow() throws {
        let pairs = [
            Pair(a: .low, b: .low),
            Pair(a: .low, b: .high),
            Pair(a: .low, b: .max),
            Pair(a: .high, b: .low),
            Pair(a: .max, b: .low),
        ]
        
        for pair in pairs {
            let common = CallsignalingProtocol.findCommonProfile(
                remoteProfile: pair.a.qualityProfile(),
                networkIsRelayed: false,
                pair.b.qualityProfile()
            )
            XCTAssertEqual(.low, common.profile)
        }
    }
    
    func testFindCommonProfileHigh() throws {
        let pairs = [
            Pair(a: .high, b: .high),
            Pair(a: .high, b: .max),
            Pair(a: .max, b: .high),
        ]
        for pair in pairs {
            let common = CallsignalingProtocol.findCommonProfile(
                remoteProfile: pair.a.qualityProfile(),
                networkIsRelayed: false,
                pair.b.qualityProfile()
            )
            XCTAssertEqual(.high, common.profile)
        }
    }
    
    func testFindCommonProfileMax() throws {
        let a: CallsignalingProtocol.ThreemaVideoCallQualityProfiles = .max
        let b: CallsignalingProtocol.ThreemaVideoCallQualityProfiles = .max
        
        let commonNonRelayed = CallsignalingProtocol.findCommonProfile(
            remoteProfile: a.qualityProfile(),
            networkIsRelayed: false,
            b.qualityProfile()
        )
        let commonRelayed = CallsignalingProtocol.findCommonProfile(
            remoteProfile: a.qualityProfile(),
            networkIsRelayed: true,
            b.qualityProfile()
        )
        
        XCTAssertEqual(.max, commonNonRelayed.profile)
        XCTAssertEqual(.high, commonRelayed.profile)
    }
    
    func testFindCommonProfileNil() throws {
        let params: [CallsignalingProtocol.ThreemaVideoCallQualityProfiles] = [.low, .high, .max]
        
        for param in params {
            let commonNonRelayed = CallsignalingProtocol.findCommonProfile(
                remoteProfile: nil,
                networkIsRelayed: false,
                param.qualityProfile()
            )
            let commonRelayed = CallsignalingProtocol.findCommonProfile(
                remoteProfile: nil,
                networkIsRelayed: true,
                param.qualityProfile()
            )
            
            XCTAssertEqual(param, commonNonRelayed.profile)
            XCTAssertEqual(param, commonRelayed.profile)
        }
    }
    
    func testFindCommonProfileRawValues() throws {
        let a = CallsignalingProtocol.ThreemaVideoCallQualityProfile(
            bitrate: 600,
            maxResolution: CGSize(width: 2000, height: 700),
            maxFps: 23,
            profile: CallsignalingProtocol.ThreemaVideoCallQualityProfiles(rawValue: 1234) ?? nil
        )
        let b: CallsignalingProtocol.ThreemaVideoCallQualityProfiles = .high

        XCTAssertNotNil(a)

        let common = CallsignalingProtocol.findCommonProfile(
            remoteProfile: a,
            networkIsRelayed: false,
            b.qualityProfile()
        )
        XCTAssertNil(common.profile)
        XCTAssertEqual(600, common.bitrate)
        XCTAssertEqual(23, common.maxFps)
        XCTAssertEqual(1280, common.maxResolution.width)
        XCTAssertEqual(700, common.maxResolution.height)
    }

    func testFindCommonProfileRawValuesWithClamping() throws {
        let a = CallsignalingProtocol.ThreemaVideoCallQualityProfile(
            bitrate: 1,
            maxResolution: CGSize(width: 1, height: 1),
            maxFps: 1,
            profile: CallsignalingProtocol.ThreemaVideoCallQualityProfiles(rawValue: 1234) ?? nil
        )
        let b: CallsignalingProtocol.ThreemaVideoCallQualityProfiles = .high
        
        XCTAssertNotNil(a)

        let common = CallsignalingProtocol.findCommonProfile(
            remoteProfile: a,
            networkIsRelayed: false,
            b.qualityProfile()
        )
        XCTAssertNil(common.profile)
        XCTAssertEqual(CallsignalingProtocol.minBitrate, common.bitrate)
        XCTAssertEqual(CallsignalingProtocol.minFps, common.maxFps)
        XCTAssertEqual(CallsignalingProtocol.minResolutionWidth, common.maxResolution.width)
        XCTAssertEqual(CallsignalingProtocol.minResolutionHeight, common.maxResolution.height)
    }
}

Messung
CHZG
1009610098

¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.1Angebot  (Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-11-04) ¤

*Eine klare Vorstellung vom Zielzustand






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=1104842
#Domains=499078