Update web-platform-tests to revision b'b728032f59a396243864b0f8584e7211e3632005'

This commit is contained in:
WPT Sync Bot 2022-11-10 01:22:36 +00:00
parent ace9b32b1c
commit df68c4e5d1
15632 changed files with 514865 additions and 155000 deletions

View file

@ -404,3 +404,71 @@ promise_test(async t => {
assert_not_equals(decoder_config.description, null);
encoder.close();
}, "Emit decoder config and extra data.");
promise_test(async t => {
let sample_rate = 48000;
let total_duration_s = 1;
let data_count = 100;
let init = getDefaultCodecInit(t);
init.output = (chunk, metadata) => {}
let encoder = new AudioEncoder(init);
// No encodes yet.
assert_equals(encoder.encodeQueueSize, 0);
let config = {
codec: 'opus',
sampleRate: sample_rate,
numberOfChannels: 2,
bitrate: 256000 //256kbit
};
encoder.configure(config);
// Still no encodes.
assert_equals(encoder.encodeQueueSize, 0);
let datas = [];
let timestamp_us = 0;
let data_duration_s = total_duration_s / data_count;
let data_length = data_duration_s * config.sampleRate;
for (let i = 0; i < data_count; i++) {
let data = make_audio_data(timestamp_us, config.numberOfChannels,
config.sampleRate, data_length);
datas.push(data);
timestamp_us += data_duration_s * 1_000_000;
}
let lastDequeueSize = Infinity;
encoder.ondequeue = () => {
assert_greater_than(lastDequeueSize, 0, "Dequeue event after queue empty");
assert_greater_than(lastDequeueSize, encoder.encodeQueueSize,
"Dequeue event without decreased queue size");
lastDequeueSize = encoder.encodeQueueSize;
};
for (let data of datas)
encoder.encode(data);
assert_greater_than_equal(encoder.encodeQueueSize, 0);
assert_less_than_equal(encoder.encodeQueueSize, data_count);
await encoder.flush();
// We can guarantee that all encodes are processed after a flush.
assert_equals(encoder.encodeQueueSize, 0);
// Last dequeue event should fire when the queue is empty.
assert_equals(lastDequeueSize, 0);
// Reset this to Infinity to track the decline of queue size for this next
// batch of encodes.
lastDequeueSize = Infinity;
for (let data of datas) {
encoder.encode(data);
data.close();
}
assert_greater_than_equal(encoder.encodeQueueSize, 0);
encoder.reset();
assert_equals(encoder.encodeQueueSize, 0);
}, 'encodeQueueSize test');