Eine aufbereitete Darstellung der Quelle

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


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
959110095

¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.52Angebot  ¤

*Eine klare Vorstellung vom Zielzustand







                                                                                                                                                                                                                                                                                                                                                                                                     

 

Neuigkeiten

Aktuelles
Motto des Tages

letze Version des Elbe Quellennavigators


letze Version des Demonstrationsprogramms Goedel
letze Version des Bille Abgleichprogramms
Version

Jenseits des Üblichen ....

Besucher

Besucher

Statistik
#Sources=1,187,785
#Domains=881,004