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

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

Issue 10832285: Switch OnMoreData() to use AudioBus. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comments. Created 8 years, 4 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
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/bind.h" 5 #include "base/bind.h"
6 #include "base/environment.h" 6 #include "base/environment.h"
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/synchronization/waitable_event.h" 10 #include "base/synchronization/waitable_event.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 private: 45 private:
46 DISALLOW_COPY_AND_ASSIGN(MockAudioOutputControllerEventHandler); 46 DISALLOW_COPY_AND_ASSIGN(MockAudioOutputControllerEventHandler);
47 }; 47 };
48 48
49 class MockAudioOutputControllerSyncReader 49 class MockAudioOutputControllerSyncReader
50 : public AudioOutputController::SyncReader { 50 : public AudioOutputController::SyncReader {
51 public: 51 public:
52 MockAudioOutputControllerSyncReader() {} 52 MockAudioOutputControllerSyncReader() {}
53 53
54 MOCK_METHOD1(UpdatePendingBytes, void(uint32 bytes)); 54 MOCK_METHOD1(UpdatePendingBytes, void(uint32 bytes));
55 MOCK_METHOD2(Read, uint32(void* data, uint32 size)); 55 MOCK_METHOD1(Read, int(AudioBus* audio_bus));
56 MOCK_METHOD0(Close, void()); 56 MOCK_METHOD0(Close, void());
57 MOCK_METHOD0(DataReady, bool()); 57 MOCK_METHOD0(DataReady, bool());
58 58
59 private: 59 private:
60 DISALLOW_COPY_AND_ASSIGN(MockAudioOutputControllerSyncReader); 60 DISALLOW_COPY_AND_ASSIGN(MockAudioOutputControllerSyncReader);
61 }; 61 };
62 62
63 ACTION_P(SignalEvent, event) { 63 ACTION_P(SignalEvent, event) {
64 event->Signal(); 64 event->Signal();
65 } 65 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 // If OnCreated is called then signal the event. 118 // If OnCreated is called then signal the event.
119 EXPECT_CALL(event_handler, OnCreated(NotNull())) 119 EXPECT_CALL(event_handler, OnCreated(NotNull()))
120 .WillOnce(InvokeWithoutArgs(&event, &base::WaitableEvent::Signal)); 120 .WillOnce(InvokeWithoutArgs(&event, &base::WaitableEvent::Signal));
121 121
122 // OnPlaying() will be called only once. 122 // OnPlaying() will be called only once.
123 EXPECT_CALL(event_handler, OnPlaying(NotNull())); 123 EXPECT_CALL(event_handler, OnPlaying(NotNull()));
124 124
125 MockAudioOutputControllerSyncReader sync_reader; 125 MockAudioOutputControllerSyncReader sync_reader;
126 EXPECT_CALL(sync_reader, UpdatePendingBytes(_)) 126 EXPECT_CALL(sync_reader, UpdatePendingBytes(_))
127 .Times(AtLeast(2)); 127 .Times(AtLeast(2));
128 EXPECT_CALL(sync_reader, Read(_, kHardwareBufferSize)) 128 EXPECT_CALL(sync_reader, Read(_))
129 .WillRepeatedly(DoAll(SignalEvent(&event), 129 .WillRepeatedly(DoAll(SignalEvent(&event),
130 Return(4))); 130 Return(4)));
131 EXPECT_CALL(sync_reader, DataReady()) 131 EXPECT_CALL(sync_reader, DataReady())
132 .WillRepeatedly(Return(true)); 132 .WillRepeatedly(Return(true));
133 EXPECT_CALL(event_handler, OnPaused(NotNull())) 133 EXPECT_CALL(event_handler, OnPaused(NotNull()))
134 .WillOnce(InvokeWithoutArgs(&pause_event, &base::WaitableEvent::Signal)); 134 .WillOnce(InvokeWithoutArgs(&pause_event, &base::WaitableEvent::Signal));
135 EXPECT_CALL(sync_reader, Close()); 135 EXPECT_CALL(sync_reader, Close());
136 136
137 AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout, 137 AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout,
138 kSampleRate, kBitsPerSample, kSamplesPerPacket); 138 kSampleRate, kBitsPerSample, kSamplesPerPacket);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 .WillOnce(InvokeWithoutArgs(&play_event, &base::WaitableEvent::Signal)); 190 .WillOnce(InvokeWithoutArgs(&play_event, &base::WaitableEvent::Signal));
191 191
192 // OnPaused() should never be called since the pause during kStarting is 192 // OnPaused() should never be called since the pause during kStarting is
193 // dropped when the second play comes in. 193 // dropped when the second play comes in.
194 EXPECT_CALL(event_handler, OnPaused(NotNull())) 194 EXPECT_CALL(event_handler, OnPaused(NotNull()))
195 .Times(0); 195 .Times(0);
196 196
197 MockAudioOutputControllerSyncReader sync_reader; 197 MockAudioOutputControllerSyncReader sync_reader;
198 EXPECT_CALL(sync_reader, UpdatePendingBytes(_)) 198 EXPECT_CALL(sync_reader, UpdatePendingBytes(_))
199 .Times(AtLeast(1)); 199 .Times(AtLeast(1));
200 EXPECT_CALL(sync_reader, Read(_, kHardwareBufferSize)) 200 EXPECT_CALL(sync_reader, Read(_))
201 .WillRepeatedly(DoAll(SignalEvent(&event), Return(4))); 201 .WillRepeatedly(DoAll(SignalEvent(&event), Return(4)));
202 EXPECT_CALL(sync_reader, DataReady()) 202 EXPECT_CALL(sync_reader, DataReady())
203 .WillRepeatedly(Return(true)); 203 .WillRepeatedly(Return(true));
204 EXPECT_CALL(sync_reader, Close()); 204 EXPECT_CALL(sync_reader, Close());
205 205
206 AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout, 206 AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, kChannelLayout,
207 kSampleRate, kBitsPerSample, kSamplesPerPacket); 207 kSampleRate, kBitsPerSample, kSamplesPerPacket);
208 scoped_refptr<AudioOutputController> controller = 208 scoped_refptr<AudioOutputController> controller =
209 AudioOutputController::Create( 209 AudioOutputController::Create(
210 audio_manager.get(), &event_handler, params, &sync_reader); 210 audio_manager.get(), &event_handler, params, &sync_reader);
211 ASSERT_TRUE(controller.get()); 211 ASSERT_TRUE(controller.get());
212 212
213 // Wait for OnCreated() to be called. 213 // Wait for OnCreated() to be called.
214 event.Wait(); 214 event.Wait();
215 215
216 ASSERT_FALSE(play_event.IsSignaled()); 216 ASSERT_FALSE(play_event.IsSignaled());
217 controller->Play(); 217 controller->Play();
218 controller->Pause(); 218 controller->Pause();
219 controller->Play(); 219 controller->Play();
220 play_event.Wait(); 220 play_event.Wait();
221 221
222 // Now stop the controller. 222 // Now stop the controller.
223 CloseAudioController(controller); 223 CloseAudioController(controller);
224 } 224 }
225 225
226 } // namespace media 226 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698