42 lines
1.9 KiB
C#
42 lines
1.9 KiB
C#
using VoiceCat.Core;
|
|||
|
|
|
||
|
|
namespace VoiceCat.Tests;
|
||
|
|
|
||
|
|
public class AudioRouteWatcherTests
|
||
|
|
{
|
||
|
|
// Reconfiguring a session moves the route, and moving the route is reported back as a change.
|
||
|
|
// Acting on that echo rebuilds the graph that caused it, which is the audio flipping between
|
||
|
|
// two routes without end rather than one reconfiguration.
|
||
|
|
[Fact]
|
||
|
|
public void ARouteThatMatchesTheLiveGraphIsNotRebuiltFor()
|
||
|
|
{
|
||
|
|
var watcher = new AudioRouteWatcher();
|
||
|
|
|
||
|
|
// Nothing is known about a graph built before anything was recorded.
|
||
|
|
Assert.True(watcher.ShouldRebuild("builtInMic|builtInSpeaker"));
|
||
|
|
|
||
|
|
watcher.Built("builtInMic|builtInSpeaker");
|
||
|
|
// The echo of the Apply that produced this route, however often it is reported.
|
||
|
|
Assert.False(watcher.ShouldRebuild("builtInMic|builtInSpeaker"));
|
||
|
|
Assert.False(watcher.ShouldRebuild("builtInMic|builtInSpeaker"));
|
||
|
|
|
||
|
|
// A headset arriving is hardware the graph is not built on: rebuild, then settle again.
|
||
|
|
Assert.True(watcher.ShouldRebuild("headsetMic|headset"));
|
||
|
|
watcher.Built("headsetMic|headset");
|
||
|
|
Assert.False(watcher.ShouldRebuild("headsetMic|headset"));
|
||
|
|
|
||
|
|
// Forcing the speaker takes the headset out of the route. The rebuild that does it records
|
||
|
|
// the result, so the change it is reported as does not drive a second rebuild.
|
||
|
|
watcher.Built("builtInMic|builtInSpeaker");
|
||
|
|
Assert.False(watcher.ShouldRebuild("builtInMic|builtInSpeaker"));
|
||
|
|
// And releasing it, which brings the headset back, is one rebuild and no more.
|
||
|
|
Assert.True(watcher.ShouldRebuild("headsetMic|headset"));
|
||
|
|
watcher.Built("headsetMic|headset");
|
||
|
|
Assert.False(watcher.ShouldRebuild("headsetMic|headset"));
|
||
|
|
|
||
|
|
// A released session has no route left to compare against.
|
||
|
|
watcher.Reset();
|
||
|
|
Assert.True(watcher.ShouldRebuild("headsetMic|headset"));
|
||
|
|
}
|
||
|
|
}
|