public IEnumerator CreateChannel(TestMode mode) { MockSignaling.Reset(mode == TestMode.PrivateMode); var dependencies = CreateDependencies(); var target = new RenderStreamingInternal(ref dependencies); bool isStarted = false; target.onStart += () => { isStarted = true; }; yield return(new WaitUntil(() => isStarted)); var connectionId = "12345"; target.CreateConnection(connectionId); bool isCreatedConnection = false; target.onCreatedConnection += _ => { isCreatedConnection = true; }; yield return(new WaitUntil(() => isCreatedConnection)); string channelName = "test"; var channel = target.CreateChannel(connectionId, channelName); Assert.That(channel.Label, Is.EqualTo(channelName)); target.DeleteConnection(connectionId); bool isDeletedConnection = false; target.onDeletedConnection += _ => { isDeletedConnection = true; }; yield return(new WaitUntil(() => isDeletedConnection)); target.Dispose(); channel.Dispose(); }
public IEnumerator OnAddChannelPrivateMode() { MockSignaling.Reset(true); var dependencies1 = CreateDependencies(); var dependencies2 = CreateDependencies(); var target1 = new RenderStreamingInternal(ref dependencies1); var target2 = new RenderStreamingInternal(ref dependencies2); bool isStarted1 = false; bool isStarted2 = false; target1.onStart += () => { isStarted1 = true; }; target2.onStart += () => { isStarted2 = true; }; yield return(new WaitUntil(() => isStarted1 && isStarted2)); bool isCreatedConnection1 = false; bool isCreatedConnection2 = false; target1.onCreatedConnection += _ => { isCreatedConnection1 = true; }; target2.onFoundConnection += _ => { isCreatedConnection2 = true; }; var connectionId = "12345"; // target1 is Receiver in private mode target1.CreateConnection(connectionId); yield return(new WaitUntil(() => isCreatedConnection1)); // target2 is sender in private mode target2.CreateConnection(connectionId); yield return(new WaitUntil(() => isCreatedConnection2)); bool isAddChannel1 = false; bool isGotAnswer2 = false; target1.onAddChannel += (_, channel) => { isAddChannel1 = true; }; target1.onGotOffer += (_, sdp) => { target1.SendAnswer(connectionId); }; target2.onGotAnswer += (_, sdp) => { isGotAnswer2 = true; }; // send offer automatically after creating channel target2.CreateChannel(connectionId, "test"); // send offer manually target2.SendOffer(connectionId); yield return(new WaitUntil(() => isAddChannel1 && isGotAnswer2)); target1.DeleteConnection(connectionId); target2.DeleteConnection(connectionId); bool isDeletedConnection1 = false; bool isDeletedConnection2 = false; target1.onDeletedConnection += _ => { isDeletedConnection1 = true; }; target2.onDeletedConnection += _ => { isDeletedConnection2 = true; }; yield return(new WaitUntil(() => isDeletedConnection1 && isDeletedConnection2)); target1.Dispose(); target2.Dispose(); }
public IEnumerator UnitySetUp() { MockSignaling.Reset(true); _test = new MonoBehaviourTest <MyMonoBehaviourTest>(); var dependencies1 = CreateDependencies(); var dependencies2 = CreateDependencies(); _target1 = new RenderStreamingInternal(ref dependencies1); _target2 = new RenderStreamingInternal(ref dependencies2); bool isStarted1 = false; bool isStarted2 = false; _target1.onStart += () => { isStarted1 = true; }; _target2.onStart += () => { isStarted2 = true; }; yield return(new WaitUntil(() => isStarted1 && isStarted2)); bool isCreatedConnection1 = false; bool isCreatedConnection2 = false; _target1.onCreatedConnection += _ => { isCreatedConnection1 = true; }; _target2.onCreatedConnection += _ => { isCreatedConnection2 = true; }; // _target1 is Receiver in private mode _target1.CreateConnection(connectionId); yield return(new WaitUntil(() => isCreatedConnection1)); // _target2 is sender in private mode _target2.CreateConnection(connectionId); yield return(new WaitUntil(() => isCreatedConnection2)); _target1.onAddChannel += (_, channel) => { _channel1 = channel; }; // send offer automatically after creating channel _channel2 = _target2.CreateChannel(connectionId, "_test"); bool isGotOffer1 = false; bool isGotAnswer2 = false; _target1.onGotOffer += (_, sdp) => { isGotOffer1 = true; }; _target2.onGotAnswer += (_, sdp) => { isGotAnswer2 = true; }; // each peer are not stable, signaling process not complete. yield return(new WaitUntil(() => isGotOffer1)); _target1.SendAnswer(connectionId); yield return(new WaitUntil(() => isGotAnswer2)); Assert.That(isGotAnswer2, Is.True); // If target1 processes resent Offer from target2, target1 is not stable. Assert.That(_target2.IsStable(connectionId), Is.True); yield return(new WaitUntil(() => _channel1 != null)); Assert.That(_channel1.ReadyState, Is.EqualTo(RTCDataChannelState.Open)); }
public IEnumerator UnitySetUp() { MockSignaling.Reset(true); _test = new MonoBehaviourTest <MyMonoBehaviourTest>(); var dependencies1 = CreateDependencies(); var dependencies2 = CreateDependencies(); _target1 = new RenderStreamingInternal(ref dependencies1); _target2 = new RenderStreamingInternal(ref dependencies2); bool isStarted1 = false; bool isStarted2 = false; _target1.onStart += () => { isStarted1 = true; }; _target2.onStart += () => { isStarted2 = true; }; yield return(new WaitUntil(() => isStarted1 && isStarted2)); bool isCreatedConnection1 = false; bool isCreatedConnection2 = false; _target1.onCreatedConnection += _ => { isCreatedConnection1 = true; }; _target2.onFoundConnection += _ => { isCreatedConnection2 = true; }; // _target1 is Receiver in private mode _target1.CreateConnection(connectionId); yield return(new WaitUntil(() => isCreatedConnection1)); // _target2 is sender in private mode _target2.CreateConnection(connectionId); yield return(new WaitUntil(() => isCreatedConnection2)); bool isAddChannel1 = false; bool isGotAnswer2 = false; _target1.onAddChannel += (_, channel) => { isAddChannel1 = true; _channel1 = channel; }; _target1.onGotOffer += (_, sdp) => { _target1.SendAnswer(connectionId); }; _target2.onGotAnswer += (_, sdp) => { isGotAnswer2 = true; }; // send offer automatically after creating channel _channel2 = _target2.CreateChannel(connectionId, "_test"); // send offer manually _target2.SendOffer(connectionId); yield return(new WaitUntil(() => isAddChannel1 && isGotAnswer2)); }