audio: run TestPlayOnIdleContext on the fake clock of synctest

The test was added after the survey in #3716, and waits on real time in
the same way.

Updates #3716
This commit is contained in:
dualfroz committed 2026-10-03 16:06:04 +02:00
1 parent d22b1a2b09
commit fab8fc22e0
1 file changed
+3 -1
+3 -1
View File
@@ -879,6 +879,7 @@ func TestPlayerErrorDoesNotStopOtherPlayers(t *testing.T) {
} }
func TestPlayOnIdleContext(t *testing.T) { func TestPlayOnIdleContext(t *testing.T) {
synctest.Test(t, func(t *testing.T) {
setup() setup()
defer teardown() defer teardown()
@@ -888,7 +889,7 @@ func TestPlayOnIdleContext(t *testing.T) {
} }
// waitUntil polls cond until it holds or the deadline passes, and reports whether it held. // waitUntil polls cond until it holds or the deadline passes, and reports whether it held.
// The deadline is generous because time.Sleep has a several-millisecond floor on browsers. // The test runs on the fake clock of synctest, so the deadline does not take real time.
waitUntil := func(cond func() bool) bool { waitUntil := func(cond func() bool) bool {
deadline := time.Now().Add(10 * time.Second) deadline := time.Now().Add(10 * time.Second)
for time.Now().Before(deadline) { for time.Now().Before(deadline) {
@@ -925,6 +926,7 @@ func TestPlayOnIdleContext(t *testing.T) {
t.Fatalf("round %d: time out: the player did not finish", i) t.Fatalf("round %d: time out: the player did not finish", i)
} }
} }
})
} }
func callWithTimeout(t *testing.T, name string, f func() error) error { func callWithTimeout(t *testing.T, name string, f func() error) error {