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

Side by Side Diff: content/browser/renderer_host/media/audio_input_device_manager_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: rebase2 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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "content/browser/browser_thread_impl.h" 10 #include "content/browser/browser_thread_impl.h"
11 #include "content/browser/renderer_host/media/audio_input_device_manager.h" 11 #include "content/browser/renderer_host/media/audio_input_device_manager.h"
12 #include "content/browser/renderer_host/media/audio_input_device_manager_event_h andler.h" 12 #include "content/browser/renderer_host/media/audio_input_device_manager_event_h andler.h"
13 #include "media/audio/audio_manager.h" 13 #include "media/audio/audio_manager_base.h"
14 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 16
17 using ::testing::_; 17 using ::testing::_;
18 using ::testing::AnyNumber; 18 using ::testing::AnyNumber;
19 using ::testing::InSequence; 19 using ::testing::InSequence;
20 using ::testing::Return; 20 using ::testing::Return;
21 using content::BrowserThread; 21 using content::BrowserThread;
22 22
23 using content::BrowserThreadImpl; 23 using content::BrowserThreadImpl;
(...skipping 25 matching lines...) Expand all
49 private: 49 private:
50 DISALLOW_COPY_AND_ASSIGN(MockAudioInputDeviceManagerListener); 50 DISALLOW_COPY_AND_ASSIGN(MockAudioInputDeviceManagerListener);
51 }; 51 };
52 52
53 class MockAudioInputDeviceManagerEventHandler 53 class MockAudioInputDeviceManagerEventHandler
54 : public AudioInputDeviceManagerEventHandler { 54 : public AudioInputDeviceManagerEventHandler {
55 public: 55 public:
56 MockAudioInputDeviceManagerEventHandler() {} 56 MockAudioInputDeviceManagerEventHandler() {}
57 virtual ~MockAudioInputDeviceManagerEventHandler() {} 57 virtual ~MockAudioInputDeviceManagerEventHandler() {}
58 58
59 MOCK_METHOD2(OnDeviceStarted, void(int, int)); 59 MOCK_METHOD2(OnDeviceStarted, void(int, const std::string&));
60 MOCK_METHOD1(OnDeviceStopped, void(int)); 60 MOCK_METHOD1(OnDeviceStopped, void(int));
61 61
62 private: 62 private:
63 DISALLOW_COPY_AND_ASSIGN(MockAudioInputDeviceManagerEventHandler); 63 DISALLOW_COPY_AND_ASSIGN(MockAudioInputDeviceManagerEventHandler);
64 }; 64 };
65 65
66 // Returns true if machine has audio input device, else returns false. 66 // Returns true if machine has audio input device, else returns false.
67 static bool CanRunAudioInputDeviceTests() { 67 static bool CanRunAudioInputDeviceTests() {
68 AudioManager* audio_manager = AudioManager::GetAudioManager(); 68 AudioManager* audio_manager = AudioManager::GetAudioManager();
69 if (!audio_manager) 69 if (!audio_manager)
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 session_id[index] = manager_->Open(*iter); 292 session_id[index] = manager_->Open(*iter);
293 manager_->Start(session_id[index], audio_input_event_handler.get()); 293 manager_->Start(session_id[index], audio_input_event_handler.get());
294 manager_->Stop(session_id[index]); 294 manager_->Stop(session_id[index]);
295 manager_->Close(session_id[index]); 295 manager_->Close(session_id[index]);
296 296
297 // Expected mock calls with expected return values. 297 // Expected mock calls with expected return values.
298 EXPECT_CALL(*audio_input_listener_, Opened(kAudioCapture, 298 EXPECT_CALL(*audio_input_listener_, Opened(kAudioCapture,
299 session_id[index])) 299 session_id[index]))
300 .Times(1); 300 .Times(1);
301 EXPECT_CALL(*audio_input_event_handler, 301 EXPECT_CALL(*audio_input_event_handler,
302 OnDeviceStarted(session_id[index], index)) 302 OnDeviceStarted(session_id[index], iter->device_id))
303 .Times(1); 303 .Times(1);
304 EXPECT_CALL(*audio_input_listener_, Closed(kAudioCapture, 304 EXPECT_CALL(*audio_input_listener_, Closed(kAudioCapture,
305 session_id[index])) 305 session_id[index]))
306 .Times(1); 306 .Times(1);
307 SyncWithAudioInputDeviceManagerThread(); 307 SyncWithAudioInputDeviceManagerThread();
308 } 308 }
309 } 309 }
310 310
311 // Test the behavior of calling Close without calling Stop. 311 // Test the behavior of calling Close without calling Stop.
312 TEST_F(AudioInputDeviceManagerTest, CloseWithoutStopDevice) { 312 TEST_F(AudioInputDeviceManagerTest, CloseWithoutStopDevice) {
(...skipping 17 matching lines...) Expand all
330 // Open/start/close the device. 330 // Open/start/close the device.
331 session_id[index] = manager_->Open(*iter); 331 session_id[index] = manager_->Open(*iter);
332 manager_->Start(session_id[index], audio_input_event_handler.get()); 332 manager_->Start(session_id[index], audio_input_event_handler.get());
333 manager_->Close(session_id[index]); 333 manager_->Close(session_id[index]);
334 334
335 // Expected mock calls with expected return values. 335 // Expected mock calls with expected return values.
336 EXPECT_CALL(*audio_input_listener_, Opened(kAudioCapture, 336 EXPECT_CALL(*audio_input_listener_, Opened(kAudioCapture,
337 session_id[index])) 337 session_id[index]))
338 .Times(1); 338 .Times(1);
339 EXPECT_CALL(*audio_input_event_handler, 339 EXPECT_CALL(*audio_input_event_handler,
340 OnDeviceStarted(session_id[index], index)) 340 OnDeviceStarted(session_id[index], iter->device_id))
341 .Times(1); 341 .Times(1);
342 // Event Handler should get a stop device notification as no stop is called 342 // Event Handler should get a stop device notification as no stop is called
343 // before closing the device. 343 // before closing the device.
344 EXPECT_CALL(*audio_input_event_handler, 344 EXPECT_CALL(*audio_input_event_handler,
345 OnDeviceStopped(session_id[index])) 345 OnDeviceStopped(session_id[index]))
346 .Times(1); 346 .Times(1);
347 EXPECT_CALL(*audio_input_listener_, Closed(kAudioCapture, 347 EXPECT_CALL(*audio_input_listener_, Closed(kAudioCapture,
348 session_id[index])) 348 session_id[index]))
349 .Times(1); 349 .Times(1);
350 SyncWithAudioInputDeviceManagerThread(); 350 SyncWithAudioInputDeviceManagerThread();
(...skipping 28 matching lines...) Expand all
379 manager_->Close(first_session_id); 379 manager_->Close(first_session_id);
380 manager_->Close(second_session_id); 380 manager_->Close(second_session_id);
381 381
382 // Expected mock calls with expected return values. 382 // Expected mock calls with expected return values.
383 EXPECT_NE(first_session_id, second_session_id); 383 EXPECT_NE(first_session_id, second_session_id);
384 EXPECT_CALL(*audio_input_listener_, Opened(kAudioCapture, first_session_id)) 384 EXPECT_CALL(*audio_input_listener_, Opened(kAudioCapture, first_session_id))
385 .Times(1); 385 .Times(1);
386 EXPECT_CALL(*audio_input_listener_, Opened(kAudioCapture, second_session_id)) 386 EXPECT_CALL(*audio_input_listener_, Opened(kAudioCapture, second_session_id))
387 .Times(1); 387 .Times(1);
388 EXPECT_CALL(*first_audio_input_event_handler, 388 EXPECT_CALL(*first_audio_input_event_handler,
389 OnDeviceStarted(first_session_id, 0)) 389 OnDeviceStarted(first_session_id,
390 AudioManagerBase::kDefaultDeviceId))
390 .Times(1); 391 .Times(1);
391 EXPECT_CALL(*second_audio_input_event_handler, 392 EXPECT_CALL(*second_audio_input_event_handler,
392 OnDeviceStarted(second_session_id, 0)) 393 OnDeviceStarted(second_session_id,
394 AudioManagerBase::kDefaultDeviceId))
393 .Times(1); 395 .Times(1);
394 EXPECT_CALL(*audio_input_listener_, Closed(kAudioCapture, first_session_id)) 396 EXPECT_CALL(*audio_input_listener_, Closed(kAudioCapture, first_session_id))
395 .Times(1); 397 .Times(1);
396 EXPECT_CALL(*audio_input_listener_, Closed(kAudioCapture, second_session_id)) 398 EXPECT_CALL(*audio_input_listener_, Closed(kAudioCapture, second_session_id))
397 .Times(1); 399 .Times(1);
398 SyncWithAudioInputDeviceManagerThread(); 400 SyncWithAudioInputDeviceManagerThread();
399 } 401 }
400 402
401 } // namespace media_stream 403 } // namespace media_stream
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698