Skip to content

Commit 5c7dfd9

Browse files
Added test for GetFloatTimeDomainDataAsync
1 parent 5181649 commit 5c7dfd9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

tests/IntegrationTests/AudioNodeTests/AnalyserNodeTest.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,26 @@ public async Task GetByteFrequencyDataAsync_ShouldPopulateBuffer()
5252
byte tenthElement = await buffer.AtAsync(10);
5353
_ = tenthElement.Should().NotBe(0);
5454
}
55+
56+
[Test]
57+
public async Task GetFloatTimeDomainDataAsync_ShouldPopulateBuffer()
58+
{
59+
// Arrange
60+
await using AudioContext context = await GetAudioContextAsync();
61+
62+
await using OscillatorNode oscillator = await OscillatorNode.CreateAsync(JSRuntime, context);
63+
await using AnalyserNode node = await AnalyserNode.CreateAsync(JSRuntime, context);
64+
await oscillator.ConnectAsync(node);
65+
await oscillator.StartAsync();
66+
67+
int bufferLength = (int)await node.GetFftSizeAsync();
68+
await using Float32Array buffer = await Float32Array.CreateAsync(JSRuntime, bufferLength);
69+
70+
// Act
71+
await node.GetFloatTimeDomainDataAsync(buffer);
72+
73+
// Assert
74+
float tenthElement = await buffer.AtAsync(bufferLength - 1);
75+
_ = tenthElement.Should().NotBe(0);
76+
}
5577
}

0 commit comments

Comments
 (0)