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

Side by Side Diff: media/audio/audio_input_controller_unittest.cc

Issue 344583002: Modifies AudioInputCallback::OnData and use media::AudioBus instead of plain byte vector (Relanding) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added extra non-pure OnData API Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « media/audio/audio_input_controller.cc ('k') | media/audio/audio_input_device.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/synchronization/waitable_event.h" 8 #include "base/synchronization/waitable_event.h"
9 #include "base/test/test_timeouts.h" 9 #include "base/test/test_timeouts.h"
10 #include "media/audio/audio_input_controller.h" 10 #include "media/audio/audio_input_controller.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 class MockAudioInputControllerEventHandler 47 class MockAudioInputControllerEventHandler
48 : public AudioInputController::EventHandler { 48 : public AudioInputController::EventHandler {
49 public: 49 public:
50 MockAudioInputControllerEventHandler() {} 50 MockAudioInputControllerEventHandler() {}
51 51
52 MOCK_METHOD1(OnCreated, void(AudioInputController* controller)); 52 MOCK_METHOD1(OnCreated, void(AudioInputController* controller));
53 MOCK_METHOD1(OnRecording, void(AudioInputController* controller)); 53 MOCK_METHOD1(OnRecording, void(AudioInputController* controller));
54 MOCK_METHOD2(OnError, void(AudioInputController* controller, 54 MOCK_METHOD2(OnError, void(AudioInputController* controller,
55 AudioInputController::ErrorCode error_code)); 55 AudioInputController::ErrorCode error_code));
56 MOCK_METHOD3(OnData, void(AudioInputController* controller, 56 MOCK_METHOD2(OnData,
57 const uint8* data, uint32 size)); 57 void(AudioInputController* controller, const AudioBus* data));
58 MOCK_METHOD2(OnLog, 58 MOCK_METHOD2(OnLog,
59 void(AudioInputController* controller, 59 void(AudioInputController* controller,
60 const std::string& message)); 60 const std::string& message));
61 61
62 private: 62 private:
63 DISALLOW_COPY_AND_ASSIGN(MockAudioInputControllerEventHandler); 63 DISALLOW_COPY_AND_ASSIGN(MockAudioInputControllerEventHandler);
64 }; 64 };
65 65
66 // Test fixture. 66 // Test fixture.
67 class AudioInputControllerTest : public testing::Test { 67 class AudioInputControllerTest : public testing::Test {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 110
111 // OnCreated() will be called once. 111 // OnCreated() will be called once.
112 EXPECT_CALL(event_handler, OnCreated(NotNull())) 112 EXPECT_CALL(event_handler, OnCreated(NotNull()))
113 .Times(Exactly(1)); 113 .Times(Exactly(1));
114 114
115 // OnRecording() will be called only once. 115 // OnRecording() will be called only once.
116 EXPECT_CALL(event_handler, OnRecording(NotNull())) 116 EXPECT_CALL(event_handler, OnRecording(NotNull()))
117 .Times(Exactly(1)); 117 .Times(Exactly(1));
118 118
119 // OnData() shall be called ten times. 119 // OnData() shall be called ten times.
120 EXPECT_CALL(event_handler, OnData(NotNull(), NotNull(), _)) 120 EXPECT_CALL(event_handler, OnData(NotNull(), NotNull()))
121 .Times(AtLeast(10)) 121 .Times(AtLeast(10))
122 .WillRepeatedly(CheckCountAndPostQuitTask(&count, 10, 122 .WillRepeatedly(CheckCountAndPostQuitTask(
123 message_loop_.message_loop_proxy())); 123 &count, 10, message_loop_.message_loop_proxy()));
124 124
125 scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting()); 125 scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting());
126 AudioParameters params(AudioParameters::AUDIO_FAKE, kChannelLayout, 126 AudioParameters params(AudioParameters::AUDIO_FAKE, kChannelLayout,
127 kSampleRate, kBitsPerSample, kSamplesPerPacket); 127 kSampleRate, kBitsPerSample, kSamplesPerPacket);
128 128
129 // Creating the AudioInputController should render an OnCreated() call. 129 // Creating the AudioInputController should render an OnCreated() call.
130 scoped_refptr<AudioInputController> controller = 130 scoped_refptr<AudioInputController> controller =
131 AudioInputController::Create(audio_manager.get(), 131 AudioInputController::Create(audio_manager.get(),
132 &event_handler, 132 &event_handler,
133 params, 133 params,
(...skipping 22 matching lines...) Expand all
156 156
157 // OnCreated() will be called once. 157 // OnCreated() will be called once.
158 EXPECT_CALL(event_handler, OnCreated(NotNull())) 158 EXPECT_CALL(event_handler, OnCreated(NotNull()))
159 .Times(Exactly(1)); 159 .Times(Exactly(1));
160 160
161 // OnRecording() will be called only once. 161 // OnRecording() will be called only once.
162 EXPECT_CALL(event_handler, OnRecording(NotNull())) 162 EXPECT_CALL(event_handler, OnRecording(NotNull()))
163 .Times(Exactly(1)); 163 .Times(Exactly(1));
164 164
165 // OnData() shall be called ten times. 165 // OnData() shall be called ten times.
166 EXPECT_CALL(event_handler, OnData(NotNull(), NotNull(), _)) 166 EXPECT_CALL(event_handler, OnData(NotNull(), NotNull()))
167 .Times(AtLeast(10)) 167 .Times(AtLeast(10))
168 .WillRepeatedly(CheckCountAndPostQuitTask(&count, 10, 168 .WillRepeatedly(CheckCountAndPostQuitTask(
169 message_loop_.message_loop_proxy())); 169 &count, 10, message_loop_.message_loop_proxy()));
170 170
171 // OnError() will be called after the data stream stops while the 171 // OnError() will be called after the data stream stops while the
172 // controller is in a recording state. 172 // controller is in a recording state.
173 EXPECT_CALL(event_handler, OnError(NotNull(), 173 EXPECT_CALL(event_handler, OnError(NotNull(),
174 AudioInputController::NO_DATA_ERROR)) 174 AudioInputController::NO_DATA_ERROR))
175 .Times(Exactly(1)) 175 .Times(Exactly(1))
176 .WillOnce(QuitMessageLoop(&message_loop_)); 176 .WillOnce(QuitMessageLoop(&message_loop_));
177 177
178 scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting()); 178 scoped_ptr<AudioManager> audio_manager(AudioManager::CreateForTesting());
179 AudioParameters params(AudioParameters::AUDIO_FAKE, kChannelLayout, 179 AudioParameters params(AudioParameters::AUDIO_FAKE, kChannelLayout,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 controller->Record(); 255 controller->Record();
256 256
257 controller->Close(base::MessageLoop::QuitClosure()); 257 controller->Close(base::MessageLoop::QuitClosure());
258 base::MessageLoop::current()->Run(); 258 base::MessageLoop::current()->Run();
259 259
260 controller->Close(base::MessageLoop::QuitClosure()); 260 controller->Close(base::MessageLoop::QuitClosure());
261 base::MessageLoop::current()->Run(); 261 base::MessageLoop::current()->Run();
262 } 262 }
263 263
264 } // namespace media 264 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_input_controller.cc ('k') | media/audio/audio_input_device.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698