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

Side by Side Diff: media/audio/mac/audio_auhal_mac_unittest.cc

Issue 1901583005: Revert of Pass task runners to AudioManager constructor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/macros.h" 5 #include "base/macros.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop/message_loop.h"
7 #include "base/run_loop.h" 8 #include "base/run_loop.h"
8 #include "base/synchronization/waitable_event.h" 9 #include "base/synchronization/waitable_event.h"
9 #include "base/test/test_message_loop.h"
10 #include "base/thread_task_runner_handle.h"
11 #include "media/audio/audio_io.h" 10 #include "media/audio/audio_io.h"
12 #include "media/audio/audio_manager.h" 11 #include "media/audio/audio_manager.h"
13 #include "media/audio/audio_unittest_util.h" 12 #include "media/audio/audio_unittest_util.h"
14 #include "media/audio/mock_audio_source_callback.h" 13 #include "media/audio/mock_audio_source_callback.h"
15 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
17 16
18 using testing::_; 17 using testing::_;
19 using testing::DoAll; 18 using testing::DoAll;
20 using testing::Return; 19 using testing::Return;
21 20
22 // TODO(crogers): Most of these tests can be made platform agnostic. 21 // TODO(crogers): Most of these tests can be made platform agnostic.
23 // http://crbug.com/223242 22 // http://crbug.com/223242
24 23
25 namespace media { 24 namespace media {
26 25
27 ACTION(ZeroBuffer) { 26 ACTION(ZeroBuffer) {
28 arg0->Zero(); 27 arg0->Zero();
29 } 28 }
30 29
31 ACTION_P(SignalEvent, event) { 30 ACTION_P(SignalEvent, event) {
32 event->Signal(); 31 event->Signal();
33 } 32 }
34 33
35 class AUHALStreamTest : public testing::Test { 34 class AUHALStreamTest : public testing::Test {
36 public: 35 public:
37 AUHALStreamTest() 36 AUHALStreamTest()
38 : message_loop_(base::MessageLoop::TYPE_UI), 37 : message_loop_(base::MessageLoop::TYPE_UI),
39 manager_(AudioManager::CreateForTesting( 38 manager_(AudioManager::CreateForTesting()) {
40 base::ThreadTaskRunnerHandle::Get())) {
41 // Wait for the AudioManager to finish any initialization on the audio loop. 39 // Wait for the AudioManager to finish any initialization on the audio loop.
42 base::RunLoop().RunUntilIdle(); 40 base::RunLoop().RunUntilIdle();
43 } 41 }
44 42
45 ~AUHALStreamTest() override {} 43 ~AUHALStreamTest() override { base::RunLoop().RunUntilIdle(); }
46 44
47 AudioOutputStream* Create() { 45 AudioOutputStream* Create() {
48 return manager_->MakeAudioOutputStream( 46 return manager_->MakeAudioOutputStream(
49 manager_->GetDefaultOutputStreamParameters(), ""); 47 manager_->GetDefaultOutputStreamParameters(), "");
50 } 48 }
51 49
52 bool OutputDevicesAvailable() { 50 bool OutputDevicesAvailable() {
53 return manager_->HasAudioOutputDevices(); 51 return manager_->HasAudioOutputDevices();
54 } 52 }
55 53
56 protected: 54 protected:
57 base::TestMessageLoop message_loop_; 55 base::MessageLoop message_loop_;
58 ScopedAudioManagerPtr manager_; 56 scoped_ptr<AudioManager> manager_;
59 MockAudioSourceCallback source_; 57 MockAudioSourceCallback source_;
60 58
61 private: 59 private:
62 DISALLOW_COPY_AND_ASSIGN(AUHALStreamTest); 60 DISALLOW_COPY_AND_ASSIGN(AUHALStreamTest);
63 }; 61 };
64 62
65 TEST_F(AUHALStreamTest, HardwareSampleRate) { 63 TEST_F(AUHALStreamTest, HardwareSampleRate) {
66 ABORT_AUDIO_TEST_IF_NOT(OutputDevicesAvailable()); 64 ABORT_AUDIO_TEST_IF_NOT(OutputDevicesAvailable());
67 const AudioParameters preferred_params = 65 const AudioParameters preferred_params =
68 manager_->GetDefaultOutputStreamParameters(); 66 manager_->GetDefaultOutputStreamParameters();
(...skipping 25 matching lines...) Expand all
94 .WillOnce(DoAll(ZeroBuffer(), SignalEvent(&event), Return(0))); 92 .WillOnce(DoAll(ZeroBuffer(), SignalEvent(&event), Return(0)));
95 EXPECT_CALL(source_, OnError(_)).Times(0); 93 EXPECT_CALL(source_, OnError(_)).Times(0);
96 stream->Start(&source_); 94 stream->Start(&source_);
97 event.Wait(); 95 event.Wait();
98 96
99 stream->Stop(); 97 stream->Stop();
100 stream->Close(); 98 stream->Close();
101 } 99 }
102 100
103 } // namespace media 101 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/linux/audio_manager_linux.cc ('k') | media/audio/mac/audio_low_latency_input_mac_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698