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

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

Issue 4661001: Simplified AudioOutputStream interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 10 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 | Annotate | Revision Log
« no previous file with comments | « media/audio/audio_input_controller_unittest.cc ('k') | media/audio/audio_io.h » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/environment.h" 6 #include "base/environment.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/platform_thread.h" 8 #include "base/platform_thread.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "media/audio/audio_io.h" 10 #include "media/audio/audio_io.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 AudioManager* audio_man = AudioManager::GetAudioManager(); 97 AudioManager* audio_man = AudioManager::GetAudioManager();
98 if (NULL == audio_man) 98 if (NULL == audio_man)
99 return false; 99 return false;
100 100
101 return audio_man->HasAudioInputDevices(); 101 return audio_man->HasAudioInputDevices();
102 } 102 }
103 103
104 AudioInputStream* CreateTestAudioInputStream() { 104 AudioInputStream* CreateTestAudioInputStream() {
105 AudioManager* audio_man = AudioManager::GetAudioManager(); 105 AudioManager* audio_man = AudioManager::GetAudioManager();
106 AudioInputStream* ais = audio_man->MakeAudioInputStream( 106 AudioInputStream* ais = audio_man->MakeAudioInputStream(
107 AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 2, kSamplingRate, 16), 107 AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, 2, kSamplingRate,
108 kSamplesPerPacket); 108 16, kSamplesPerPacket));
109 EXPECT_TRUE(NULL != ais); 109 EXPECT_TRUE(NULL != ais);
110 return ais; 110 return ais;
111 } 111 }
112 112
113 } // namespace. 113 } // namespace.
114 114
115 // Test that AudioInputStream rejects out of range parameters. 115 // Test that AudioInputStream rejects out of range parameters.
116 TEST(AudioInputTest, SanityOnMakeParams) { 116 TEST(AudioInputTest, SanityOnMakeParams) {
117 if (!CanRunAudioTests()) 117 if (!CanRunAudioTests())
118 return; 118 return;
119 AudioManager* audio_man = AudioManager::GetAudioManager(); 119 AudioManager* audio_man = AudioManager::GetAudioManager();
120 AudioParameters::Format fmt = AudioParameters::AUDIO_PCM_LINEAR; 120 AudioParameters::Format fmt = AudioParameters::AUDIO_PCM_LINEAR;
121 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream( 121 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream(
122 AudioParameters(fmt, 8, 8000, 16), 0)); 122 AudioParameters(fmt, 8, 8000, 16, kSamplesPerPacket)));
123 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream( 123 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream(
124 AudioParameters(fmt, 1, 1024 * 1024, 16), 0)); 124 AudioParameters(fmt, 1, 1024 * 1024, 16, kSamplesPerPacket)));
125 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream( 125 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream(
126 AudioParameters(fmt, 2, 8000, 80), 0)); 126 AudioParameters(fmt, 2, 8000, 80, kSamplesPerPacket)));
127 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream( 127 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream(
128 AudioParameters(fmt, 2, 8000, 80), 1024 * 4096)); 128 AudioParameters(fmt, 2, 8000, 80, 1000 * kSamplesPerPacket)));
129 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream( 129 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream(
130 AudioParameters(fmt, -2, 8000, 16), 0)); 130 AudioParameters(fmt, -2, 8000, 16, kSamplesPerPacket)));
131 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream( 131 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream(
132 AudioParameters(fmt, 2, -8000, 16), 0)); 132 AudioParameters(fmt, 2, -8000, 16, kSamplesPerPacket)));
133 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream( 133 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream(
134 AudioParameters(fmt, 2, 8000, -16), 0)); 134 AudioParameters(fmt, 2, 8000, -16, kSamplesPerPacket)));
135 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream( 135 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream(
136 AudioParameters(fmt, 2, 8000, 16), -1024)); 136 AudioParameters(fmt, 2, 8000, 16, -1024)));
137 } 137 }
138 138
139 // Test create and close of an AudioInputStream without recording audio. 139 // Test create and close of an AudioInputStream without recording audio.
140 TEST(AudioInputTest, CreateAndClose) { 140 TEST(AudioInputTest, CreateAndClose) {
141 if (!CanRunAudioTests()) 141 if (!CanRunAudioTests())
142 return; 142 return;
143 AudioInputStream* ais = CreateTestAudioInputStream(); 143 AudioInputStream* ais = CreateTestAudioInputStream();
144 ais->Close(); 144 ais->Close();
145 } 145 }
146 146
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 // Verify at least 500ms worth of audio was recorded, after giving sufficient 199 // Verify at least 500ms worth of audio was recorded, after giving sufficient
200 // extra time. 200 // extra time.
201 message_loop.PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask(), 590); 201 message_loop.PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask(), 590);
202 message_loop.Run(); 202 message_loop.Run();
203 EXPECT_GE(test_callback.callback_count(), 10); 203 EXPECT_GE(test_callback.callback_count(), 10);
204 EXPECT_FALSE(test_callback.had_error()); 204 EXPECT_FALSE(test_callback.had_error());
205 205
206 ais->Stop(); 206 ais->Stop();
207 ais->Close(); 207 ais->Close();
208 } 208 }
OLDNEW
« no previous file with comments | « media/audio/audio_input_controller_unittest.cc ('k') | media/audio/audio_io.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698