70 lines
2.1 KiB
C#
70 lines
2.1 KiB
C#
using System.Numerics;
|
|
using Aquarium.Engine;
|
|
using Aquarium.Engine.Input;
|
|
using Aquarium.LocalCast;
|
|
|
|
namespace Aquarium.LocalCast.Tests;
|
|
|
|
public sealed class LocalCastRuntimeSourceTests
|
|
{
|
|
[Fact]
|
|
public void RuntimeConsumesInjectedFrameSource()
|
|
{
|
|
var source = new FakeFrameSource();
|
|
var runtime = new LocalCastRuntime(new AquariumRuntimeOptions(true, null), source);
|
|
|
|
runtime.Update(0.016f, new InputState());
|
|
var frame = runtime.Frame;
|
|
|
|
Assert.Equal(1, source.ReadCount);
|
|
Assert.True(frame.Scene.GpuFusionField.Seeds.Count > 0);
|
|
}
|
|
|
|
private sealed class FakeFrameSource : ILocalCastVisualFrameSource
|
|
{
|
|
public int ReadCount { get; private set; }
|
|
|
|
public string Description => "fake-native-source";
|
|
|
|
public bool TryReadLatest(out LocalCastVisualFrame frame)
|
|
{
|
|
ReadCount++;
|
|
frame = new LocalCastVisualFrame
|
|
{
|
|
SchemaVersion = LocalCastVisualStateReader.RenderFrameSchemaId,
|
|
FrameId = 10,
|
|
CreatedMonotonicNs = 100,
|
|
SourceTimeMinNs = 100,
|
|
SourceTimeMaxNs = 120,
|
|
PresentTimeNs = 160,
|
|
AudioAlignmentTimeNs = 160,
|
|
SpoutSenderName = "LocalCastBridge Point Cloud",
|
|
TargetWidth = 1920,
|
|
TargetHeight = 1080,
|
|
Points =
|
|
[
|
|
new LocalCastVisualPoint(
|
|
"fake:point",
|
|
new Vector3(0.1f, 0.2f, 1.2f),
|
|
0.03f,
|
|
new Vector4(0.7f, 0.6f, 0.5f, 0.9f),
|
|
0.8f,
|
|
120),
|
|
],
|
|
};
|
|
return true;
|
|
}
|
|
|
|
public bool TryReadLatestClapEvents(out LocalCastClapCalibrationFrame frame)
|
|
{
|
|
frame = new LocalCastClapCalibrationFrame
|
|
{
|
|
SchemaVersion = LocalCastVisualStateReader.ClapEventsSchemaId,
|
|
FrameId = -1,
|
|
CreatedMonotonicNs = 0,
|
|
Events = [],
|
|
};
|
|
return false;
|
|
}
|
|
}
|
|
}
|