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

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

Issue 11275088: Remove implicit scoped_refptr operator T* Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 8 years, 1 month 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
« no previous file with comments | « media/audio/audio_device_thread.cc ('k') | media/audio/audio_output_controller_unittest.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.h" 7 #include "base/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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 AudioParameters params(AudioParameters::AUDIO_FAKE, kChannelLayout, 83 AudioParameters params(AudioParameters::AUDIO_FAKE, kChannelLayout,
84 kSampleRate, kBitsPerSample, kSamplesPerPacket); 84 kSampleRate, kBitsPerSample, kSamplesPerPacket);
85 scoped_refptr<AudioInputController> controller = 85 scoped_refptr<AudioInputController> controller =
86 AudioInputController::Create(audio_manager.get(), &event_handler, params); 86 AudioInputController::Create(audio_manager.get(), &event_handler, params);
87 ASSERT_TRUE(controller.get()); 87 ASSERT_TRUE(controller.get());
88 88
89 // Wait for OnCreated() to fire. 89 // Wait for OnCreated() to fire.
90 message_loop_.Run(); 90 message_loop_.Run();
91 91
92 // Close the AudioInputController synchronously. 92 // Close the AudioInputController synchronously.
93 CloseAudioController(controller); 93 CloseAudioController(controller.get());
94 } 94 }
95 95
96 // Test a normal call sequence of create, record and close. 96 // Test a normal call sequence of create, record and close.
97 TEST_F(AudioInputControllerTest, RecordAndClose) { 97 TEST_F(AudioInputControllerTest, RecordAndClose) {
98 MockAudioInputControllerEventHandler event_handler; 98 MockAudioInputControllerEventHandler event_handler;
99 int count = 0; 99 int count = 0;
100 100
101 // OnCreated() will be called once. 101 // OnCreated() will be called once.
102 EXPECT_CALL(event_handler, OnCreated(NotNull())) 102 EXPECT_CALL(event_handler, OnCreated(NotNull()))
103 .Times(Exactly(1)); 103 .Times(Exactly(1));
(...skipping 17 matching lines...) Expand all
121 AudioInputController::Create(audio_manager.get(), &event_handler, params); 121 AudioInputController::Create(audio_manager.get(), &event_handler, params);
122 ASSERT_TRUE(controller.get()); 122 ASSERT_TRUE(controller.get());
123 123
124 // Start recording and trigger one OnRecording() call. 124 // Start recording and trigger one OnRecording() call.
125 controller->Record(); 125 controller->Record();
126 126
127 // Record and wait until ten OnData() callbacks are received. 127 // Record and wait until ten OnData() callbacks are received.
128 message_loop_.Run(); 128 message_loop_.Run();
129 129
130 // Close the AudioInputController synchronously. 130 // Close the AudioInputController synchronously.
131 CloseAudioController(controller); 131 CloseAudioController(controller.get());
132 } 132 }
133 133
134 // Test that the AudioInputController reports an error when the input stream 134 // Test that the AudioInputController reports an error when the input stream
135 // stops without an OnClose() callback. This can happen when the underlying 135 // stops without an OnClose() callback. This can happen when the underlying
136 // audio layer stops feeding data as a result of a removed microphone device. 136 // audio layer stops feeding data as a result of a removed microphone device.
137 TEST_F(AudioInputControllerTest, RecordAndError) { 137 TEST_F(AudioInputControllerTest, RecordAndError) {
138 MockAudioInputControllerEventHandler event_handler; 138 MockAudioInputControllerEventHandler event_handler;
139 int count = 0; 139 int count = 0;
140 140
141 // OnCreated() will be called once. 141 // OnCreated() will be called once.
(...skipping 30 matching lines...) Expand all
172 172
173 // Record and wait until ten OnData() callbacks are received. 173 // Record and wait until ten OnData() callbacks are received.
174 message_loop_.Run(); 174 message_loop_.Run();
175 175
176 // Stop the stream and verify that OnError() is posted. 176 // Stop the stream and verify that OnError() is posted.
177 AudioInputStream* stream = controller->stream_for_testing(); 177 AudioInputStream* stream = controller->stream_for_testing();
178 stream->Stop(); 178 stream->Stop();
179 message_loop_.Run(); 179 message_loop_.Run();
180 180
181 // Close the AudioInputController synchronously. 181 // Close the AudioInputController synchronously.
182 CloseAudioController(controller); 182 CloseAudioController(controller.get());
183 } 183 }
184 184
185 // Test that AudioInputController rejects insanely large packet sizes. 185 // Test that AudioInputController rejects insanely large packet sizes.
186 TEST_F(AudioInputControllerTest, SamplesPerPacketTooLarge) { 186 TEST_F(AudioInputControllerTest, SamplesPerPacketTooLarge) {
187 // Create an audio device with a very large packet size. 187 // Create an audio device with a very large packet size.
188 MockAudioInputControllerEventHandler event_handler; 188 MockAudioInputControllerEventHandler event_handler;
189 189
190 // OnCreated() shall not be called in this test. 190 // OnCreated() shall not be called in this test.
191 EXPECT_CALL(event_handler, OnCreated(NotNull())) 191 EXPECT_CALL(event_handler, OnCreated(NotNull()))
192 .Times(Exactly(0)); 192 .Times(Exactly(0));
(...skipping 27 matching lines...) Expand all
220 controller->Record(); 220 controller->Record();
221 221
222 controller->Close(MessageLoop::QuitClosure()); 222 controller->Close(MessageLoop::QuitClosure());
223 MessageLoop::current()->Run(); 223 MessageLoop::current()->Run();
224 224
225 controller->Close(MessageLoop::QuitClosure()); 225 controller->Close(MessageLoop::QuitClosure());
226 MessageLoop::current()->Run(); 226 MessageLoop::current()->Run();
227 } 227 }
228 228
229 } // namespace media 229 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_device_thread.cc ('k') | media/audio/audio_output_controller_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698