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

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

Issue 1339183002: Add localized default audio device names. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor fixes. Created 5 years, 3 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
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/environment.h" 7 #include "base/environment.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/strings/utf_string_conversions.h"
12 #include "base/synchronization/waitable_event.h" 13 #include "base/synchronization/waitable_event.h"
13 #include "media/audio/audio_manager_base.h" 14 #include "media/audio/audio_manager_base.h"
14 #include "media/audio/audio_output_controller.h" 15 #include "media/audio/audio_output_controller.h"
15 #include "media/audio/audio_parameters.h" 16 #include "media/audio/audio_parameters.h"
16 #include "media/base/audio_bus.h" 17 #include "media/base/audio_bus.h"
18 #include "media/base/media_resources.h"
17 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
19 21
20 using ::testing::_; 22 using ::testing::_;
21 using ::testing::AtLeast; 23 using ::testing::AtLeast;
22 using ::testing::DoAll; 24 using ::testing::DoAll;
23 using ::testing::Invoke; 25 using ::testing::Invoke;
24 using ::testing::NotNull; 26 using ::testing::NotNull;
25 using ::testing::Return; 27 using ::testing::Return;
26 28
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 83 }
82 84
83 static const float kBufferNonZeroData = 1.0f; 85 static const float kBufferNonZeroData = 1.0f;
84 ACTION(PopulateBuffer) { 86 ACTION(PopulateBuffer) {
85 arg0->Zero(); 87 arg0->Zero();
86 // Note: To confirm the buffer will be populated in these tests, it's 88 // Note: To confirm the buffer will be populated in these tests, it's
87 // sufficient that only the first float in channel 0 is set to the value. 89 // sufficient that only the first float in channel 0 is set to the value.
88 arg0->channel(0)[0] = kBufferNonZeroData; 90 arg0->channel(0)[0] = kBufferNonZeroData;
89 } 91 }
90 92
93 base::string16 FakeLocalizedStringProvider(MessageId message_id) {
ajm 2015/09/17 05:47:28 I could move this to a fake_media_resources.h if w
ajm 2015/09/18 00:43:21 Ended up doing this because there was another test
94 return base::ASCIIToUTF16("FakeString");
95 }
96
91 class AudioOutputControllerTest : public testing::Test { 97 class AudioOutputControllerTest : public testing::Test {
92 public: 98 public:
99 static void SetUpTestCase() {
100 SetLocalizedStringProvider(FakeLocalizedStringProvider);
101 }
102
93 AudioOutputControllerTest() 103 AudioOutputControllerTest()
94 : audio_manager_(AudioManager::CreateForTesting()), 104 : audio_manager_(AudioManager::CreateForTesting()),
95 create_event_(false, false), 105 create_event_(false, false),
96 play_event_(false, false), 106 play_event_(false, false),
97 read_event_(false, false), 107 read_event_(false, false),
98 pause_event_(false, false) { 108 pause_event_(false, false) {
99 } 109 }
100 110
101 ~AudioOutputControllerTest() override {} 111 ~AudioOutputControllerTest() override {}
102 112
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 220
211 void SwitchDevice(bool diverting) { 221 void SwitchDevice(bool diverting) {
212 if (!diverting) { 222 if (!diverting) {
213 // Expect the current stream to close and a new stream to start 223 // Expect the current stream to close and a new stream to start
214 // playing if not diverting. When diverting, nothing happens 224 // playing if not diverting. When diverting, nothing happens
215 // until diverting is stopped. 225 // until diverting is stopped.
216 EXPECT_CALL(mock_event_handler_, OnPlaying()) 226 EXPECT_CALL(mock_event_handler_, OnPlaying())
217 .WillOnce(SignalEvent(&play_event_)); 227 .WillOnce(SignalEvent(&play_event_));
218 } 228 }
219 229
220 controller_->SwitchOutputDevice(AudioManagerBase::kDefaultDeviceName, 230 controller_->SwitchOutputDevice(AudioManager::GetDefaultDeviceName(),
221 base::Bind(&base::DoNothing)); 231 base::Bind(&base::DoNothing));
222 } 232 }
223 233
224 void Close() { 234 void Close() {
225 EXPECT_CALL(mock_sync_reader_, Close()); 235 EXPECT_CALL(mock_sync_reader_, Close());
226 236
227 controller_->Close(base::MessageLoop::QuitClosure()); 237 controller_->Close(base::MessageLoop::QuitClosure());
228 base::MessageLoop::current()->Run(); 238 base::MessageLoop::current()->Run();
229 } 239 }
230 240
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 413
404 TEST_F(AudioOutputControllerTest, DivertRevertClose) { 414 TEST_F(AudioOutputControllerTest, DivertRevertClose) {
405 Create(kSamplesPerPacket); 415 Create(kSamplesPerPacket);
406 WaitForCreate(); 416 WaitForCreate();
407 DivertNeverPlaying(); 417 DivertNeverPlaying();
408 RevertWasNotPlaying(); 418 RevertWasNotPlaying();
409 Close(); 419 Close();
410 } 420 }
411 421
412 } // namespace media 422 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698