Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(761)

Side by Side Diff: content/renderer/media/audio_renderer_sink_cache_unittest.cc

Issue 2120273004: Getting rid of AudioHardwareConfig and its synchronous IPC. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: frame id fix Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <array> 5 #include <array>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/test/test_simple_task_runner.h" 10 #include "base/test/test_simple_task_runner.h"
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 base::Thread thread("timeout_thread"); 277 base::Thread thread("timeout_thread");
278 thread.Start(); 278 thread.Start();
279 279
280 // 100 ms more than garbage collection timeout. 280 // 100 ms more than garbage collection timeout.
281 WaitOnAnotherThread(thread, kDeleteTimeoutMs + 100); 281 WaitOnAnotherThread(thread, kDeleteTimeoutMs + 100);
282 282
283 // Nothing crashed and the second sink deleted on schedule. 283 // Nothing crashed and the second sink deleted on schedule.
284 EXPECT_EQ(0, sink_count()); 284 EXPECT_EQ(0, sink_count());
285 } 285 }
286 286
287 // Verify that default output devicee information can be retrieved after default
288 // sink deletion without creating another default sink.
289 TEST_F(AudioRendererSinkCacheTest, DefaultOutputDeviceInfoCached) {
290 EXPECT_EQ(0, sink_count());
291
292 media::OutputDeviceInfo device_info =
293 cache_->GetSinkInfo(kRenderFrameId, 0, kDefaultDeviceId, url::Origin());
294 EXPECT_EQ(1, sink_count()); // This sink is scheduled for deletion now.
295
296 base::Thread thread("timeout_thread");
297 thread.Start();
298
299 // 100 ms more than garbage collection timeout.
300 WaitOnAnotherThread(thread, kDeleteTimeoutMs + 100);
301
302 EXPECT_EQ(0, sink_count()); // Default sink is deleted.
303
304 media::OutputDeviceInfo another_device_info =
305 cache_->GetSinkInfo(kRenderFrameId, 0, kDefaultDeviceId, url::Origin());
306
307 EXPECT_EQ(0, sink_count()); // No new default sink is created.
308 }
309
287 // Check that a sink created on one thread in response to GetSinkInfo can be 310 // Check that a sink created on one thread in response to GetSinkInfo can be
288 // used on another thread. 311 // used on another thread.
289 TEST_F(AudioRendererSinkCacheTest, MultithreadedAccess) { 312 TEST_F(AudioRendererSinkCacheTest, MultithreadedAccess) {
290 EXPECT_EQ(0, sink_count()); 313 EXPECT_EQ(0, sink_count());
291 314
292 base::Thread thread1("thread1"); 315 base::Thread thread1("thread1");
293 thread1.Start(); 316 thread1.Start();
294 317
295 base::Thread thread2("thread2"); 318 base::Thread thread2("thread2");
296 thread2.Start(); 319 thread2.Start();
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 // Wait for completion of all the tasks posted to at least one thread. 388 // Wait for completion of all the tasks posted to at least one thread.
366 media::WaitableMessageLoopEvent loop_event( 389 media::WaitableMessageLoopEvent loop_event(
367 TestTimeouts::action_max_timeout()); 390 TestTimeouts::action_max_timeout());
368 threads[kThreadCount - 1]->task_runner()->PostTaskAndReply( 391 threads[kThreadCount - 1]->task_runner()->PostTaskAndReply(
369 FROM_HERE, base::Bind(&base::DoNothing), loop_event.GetClosure()); 392 FROM_HERE, base::Bind(&base::DoNothing), loop_event.GetClosure());
370 // Runs the loop and waits for the thread to call event's closure. 393 // Runs the loop and waits for the thread to call event's closure.
371 loop_event.RunAndWait(); 394 loop_event.RunAndWait();
372 } 395 }
373 396
374 } // namespace content 397 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698