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

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

Issue 8491044: Link things together and enable the device selection for linux and mac. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: fixing unittests Created 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/threading/platform_thread.h" 9 #include "base/threading/platform_thread.h"
10 #include "media/audio/audio_io.h" 10 #include "media/audio/audio_io.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 if (NULL == audio_man) 96 if (NULL == audio_man)
97 return false; 97 return false;
98 98
99 return audio_man->HasAudioInputDevices(); 99 return audio_man->HasAudioInputDevices();
100 } 100 }
101 101
102 static AudioInputStream* CreateTestAudioInputStream() { 102 static AudioInputStream* CreateTestAudioInputStream() {
103 AudioManager* audio_man = AudioManager::GetAudioManager(); 103 AudioManager* audio_man = AudioManager::GetAudioManager();
104 AudioInputStream* ais = audio_man->MakeAudioInputStream( 104 AudioInputStream* ais = audio_man->MakeAudioInputStream(
105 AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO, 105 AudioParameters(AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO,
106 kSamplingRate, 16, kSamplesPerPacket)); 106 kSamplingRate, 16, kSamplesPerPacket), "");
107 EXPECT_TRUE(NULL != ais); 107 EXPECT_TRUE(NULL != ais);
108 return ais; 108 return ais;
109 } 109 }
110 110
111 // Test that AudioInputStream rejects out of range parameters. 111 // Test that AudioInputStream rejects out of range parameters.
112 TEST(AudioInputTest, SanityOnMakeParams) { 112 TEST(AudioInputTest, SanityOnMakeParams) {
113 if (!CanRunAudioTests()) 113 if (!CanRunAudioTests())
114 return; 114 return;
115 AudioManager* audio_man = AudioManager::GetAudioManager(); 115 AudioManager* audio_man = AudioManager::GetAudioManager();
116 AudioParameters::Format fmt = AudioParameters::AUDIO_PCM_LINEAR; 116 AudioParameters::Format fmt = AudioParameters::AUDIO_PCM_LINEAR;
117 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream( 117 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream(
118 AudioParameters(fmt, CHANNEL_LAYOUT_7POINT1, 8000, 16, 118 AudioParameters(fmt, CHANNEL_LAYOUT_7POINT1, 8000, 16,
119 kSamplesPerPacket))); 119 kSamplesPerPacket), ""));
120 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream( 120 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream(
121 AudioParameters(fmt, CHANNEL_LAYOUT_MONO, 1024 * 1024, 16, 121 AudioParameters(fmt, CHANNEL_LAYOUT_MONO, 1024 * 1024, 16,
122 kSamplesPerPacket))); 122 kSamplesPerPacket), ""));
123 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream( 123 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream(
124 AudioParameters(fmt, CHANNEL_LAYOUT_STEREO, 8000, 80, 124 AudioParameters(fmt, CHANNEL_LAYOUT_STEREO, 8000, 80,
125 kSamplesPerPacket))); 125 kSamplesPerPacket), ""));
126 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream( 126 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream(
127 AudioParameters(fmt, CHANNEL_LAYOUT_STEREO, 8000, 80, 127 AudioParameters(fmt, CHANNEL_LAYOUT_STEREO, 8000, 80,
128 1000 * kSamplesPerPacket))); 128 1000 * kSamplesPerPacket), ""));
129 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream( 129 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream(
130 AudioParameters(fmt, CHANNEL_LAYOUT_UNSUPPORTED, 8000, 16, 130 AudioParameters(fmt, CHANNEL_LAYOUT_UNSUPPORTED, 8000, 16,
131 kSamplesPerPacket))); 131 kSamplesPerPacket), ""));
132 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream( 132 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream(
133 AudioParameters(fmt, CHANNEL_LAYOUT_STEREO, -8000, 16, 133 AudioParameters(fmt, CHANNEL_LAYOUT_STEREO, -8000, 16,
134 kSamplesPerPacket))); 134 kSamplesPerPacket), ""));
135 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream( 135 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream(
136 AudioParameters(fmt, CHANNEL_LAYOUT_STEREO, 8000, -16, 136 AudioParameters(fmt, CHANNEL_LAYOUT_STEREO, 8000, -16,
137 kSamplesPerPacket))); 137 kSamplesPerPacket), ""));
138 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream( 138 EXPECT_TRUE(NULL == audio_man->MakeAudioInputStream(
139 AudioParameters(fmt, CHANNEL_LAYOUT_STEREO, 8000, 16, -1024))); 139 AudioParameters(fmt, CHANNEL_LAYOUT_STEREO, 8000, 16, -1024), ""));
140 } 140 }
141 141
142 // Test create and close of an AudioInputStream without recording audio. 142 // Test create and close of an AudioInputStream without recording audio.
143 TEST(AudioInputTest, CreateAndClose) { 143 TEST(AudioInputTest, CreateAndClose) {
144 if (!CanRunAudioTests()) 144 if (!CanRunAudioTests())
145 return; 145 return;
146 AudioInputStream* ais = CreateTestAudioInputStream(); 146 AudioInputStream* ais = CreateTestAudioInputStream();
147 ais->Close(); 147 ais->Close();
148 } 148 }
149 149
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 // Verify at least 500ms worth of audio was recorded, after giving sufficient 202 // Verify at least 500ms worth of audio was recorded, after giving sufficient
203 // extra time. 203 // extra time.
204 message_loop.PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask(), 590); 204 message_loop.PostDelayedTask(FROM_HERE, new MessageLoop::QuitTask(), 590);
205 message_loop.Run(); 205 message_loop.Run();
206 EXPECT_GE(test_callback.callback_count(), 10); 206 EXPECT_GE(test_callback.callback_count(), 10);
207 EXPECT_FALSE(test_callback.had_error()); 207 EXPECT_FALSE(test_callback.had_error());
208 208
209 ais->Stop(); 209 ais->Stop();
210 ais->Close(); 210 ais->Close();
211 } 211 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698