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

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

Issue 16103007: Privitize WaitTillDataReady() and DataReady(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Gotta catch'em all! Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « media/audio/audio_output_controller.cc ('k') | media/audio/audio_output_resampler.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/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"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 private: 48 private:
49 DISALLOW_COPY_AND_ASSIGN(MockAudioOutputControllerEventHandler); 49 DISALLOW_COPY_AND_ASSIGN(MockAudioOutputControllerEventHandler);
50 }; 50 };
51 51
52 class MockAudioOutputControllerSyncReader 52 class MockAudioOutputControllerSyncReader
53 : public AudioOutputController::SyncReader { 53 : public AudioOutputController::SyncReader {
54 public: 54 public:
55 MockAudioOutputControllerSyncReader() {} 55 MockAudioOutputControllerSyncReader() {}
56 56
57 MOCK_METHOD1(UpdatePendingBytes, void(uint32 bytes)); 57 MOCK_METHOD1(UpdatePendingBytes, void(uint32 bytes));
58 MOCK_METHOD2(Read, int(AudioBus* source, AudioBus* dest)); 58 MOCK_METHOD3(Read, int(bool block, const AudioBus* source, AudioBus* dest));
59 MOCK_METHOD0(Close, void()); 59 MOCK_METHOD0(Close, void());
60 MOCK_METHOD0(DataReady, bool());
61 60
62 private: 61 private:
63 DISALLOW_COPY_AND_ASSIGN(MockAudioOutputControllerSyncReader); 62 DISALLOW_COPY_AND_ASSIGN(MockAudioOutputControllerSyncReader);
64 }; 63 };
65 64
66 class MockAudioOutputStream : public AudioOutputStream { 65 class MockAudioOutputStream : public AudioOutputStream {
67 public: 66 public:
68 MOCK_METHOD0(Open, bool()); 67 MOCK_METHOD0(Open, bool());
69 MOCK_METHOD1(Start, void(AudioSourceCallback* callback)); 68 MOCK_METHOD1(Start, void(AudioSourceCallback* callback));
70 MOCK_METHOD0(Stop, void()); 69 MOCK_METHOD0(Stop, void());
71 MOCK_METHOD1(SetVolume, void(double volume)); 70 MOCK_METHOD1(SetVolume, void(double volume));
72 MOCK_METHOD1(GetVolume, void(double* volume)); 71 MOCK_METHOD1(GetVolume, void(double* volume));
73 MOCK_METHOD0(Close, void()); 72 MOCK_METHOD0(Close, void());
74 73
75 // Set/get the callback passed to Start(). 74 // Set/get the callback passed to Start().
76 AudioSourceCallback* callback() const { return callback_; } 75 AudioSourceCallback* callback() const { return callback_; }
77 void SetCallback(AudioSourceCallback* asc) { callback_ = asc; } 76 void SetCallback(AudioSourceCallback* asc) { callback_ = asc; }
78 77
79 private: 78 private:
80 AudioSourceCallback* callback_; 79 AudioSourceCallback* callback_;
81 }; 80 };
82 81
83 ACTION_P(SignalEvent, event) { 82 ACTION_P(SignalEvent, event) {
84 event->Signal(); 83 event->Signal();
85 } 84 }
86 85
87 static const float kBufferNonZeroData = 1.0f; 86 static const float kBufferNonZeroData = 1.0f;
88 ACTION(PopulateBuffer) { 87 ACTION(PopulateBuffer) {
89 arg1->Zero(); 88 arg2->Zero();
90 // Note: To confirm the buffer will be populated in these tests, it's 89 // Note: To confirm the buffer will be populated in these tests, it's
91 // sufficient that only the first float in channel 0 is set to the value. 90 // sufficient that only the first float in channel 0 is set to the value.
92 arg1->channel(0)[0] = kBufferNonZeroData; 91 arg2->channel(0)[0] = kBufferNonZeroData;
93 } 92 }
94 93
95 class AudioOutputControllerTest : public testing::Test { 94 class AudioOutputControllerTest : public testing::Test {
96 public: 95 public:
97 AudioOutputControllerTest() 96 AudioOutputControllerTest()
98 : audio_manager_(AudioManager::Create()), 97 : audio_manager_(AudioManager::Create()),
99 create_event_(false, false), 98 create_event_(false, false),
100 play_event_(false, false), 99 play_event_(false, false),
101 read_event_(false, false), 100 read_event_(false, false),
102 pause_event_(false, false) { 101 pause_event_(false, false) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 // OnAudible() calls. 134 // OnAudible() calls.
136 EXPECT_CALL(mock_event_handler_, OnPlaying()) 135 EXPECT_CALL(mock_event_handler_, OnPlaying())
137 .WillOnce(SignalEvent(&play_event_)); 136 .WillOnce(SignalEvent(&play_event_));
138 EXPECT_CALL(mock_event_handler_, OnAudible(_)) 137 EXPECT_CALL(mock_event_handler_, OnAudible(_))
139 .Times(AtLeast(1)); 138 .Times(AtLeast(1));
140 139
141 // During playback, the mock pretends to provide audio data rendered and 140 // During playback, the mock pretends to provide audio data rendered and
142 // sent from the render process. 141 // sent from the render process.
143 EXPECT_CALL(mock_sync_reader_, UpdatePendingBytes(_)) 142 EXPECT_CALL(mock_sync_reader_, UpdatePendingBytes(_))
144 .Times(AtLeast(1)); 143 .Times(AtLeast(1));
145 EXPECT_CALL(mock_sync_reader_, Read(_, _)) 144 EXPECT_CALL(mock_sync_reader_, Read(_, _, _))
146 .WillRepeatedly(DoAll(PopulateBuffer(), 145 .WillRepeatedly(DoAll(PopulateBuffer(),
147 SignalEvent(&read_event_), 146 SignalEvent(&read_event_),
148 Return(params_.frames_per_buffer()))); 147 Return(params_.frames_per_buffer())));
149 EXPECT_CALL(mock_sync_reader_, DataReady())
150 .WillRepeatedly(Return(true));
151
152 controller_->Play(); 148 controller_->Play();
153 } 149 }
154 150
155 void Pause() { 151 void Pause() {
156 // Expect the event handler to receive one OnPaused() call. 152 // Expect the event handler to receive one OnPaused() call.
157 EXPECT_CALL(mock_event_handler_, OnPaused()) 153 EXPECT_CALL(mock_event_handler_, OnPaused())
158 .WillOnce(SignalEvent(&pause_event_)); 154 .WillOnce(SignalEvent(&pause_event_));
159 155
160 controller_->Pause(); 156 controller_->Pause();
161 } 157 }
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 370
375 TEST_F(AudioOutputControllerTest, DivertRevertClose) { 371 TEST_F(AudioOutputControllerTest, DivertRevertClose) {
376 Create(kSamplesPerPacket); 372 Create(kSamplesPerPacket);
377 WaitForCreate(); 373 WaitForCreate();
378 DivertNeverPlaying(); 374 DivertNeverPlaying();
379 RevertWasNotPlaying(); 375 RevertWasNotPlaying();
380 Close(); 376 Close();
381 } 377 }
382 378
383 } // namespace media 379 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/audio_output_controller.cc ('k') | media/audio/audio_output_resampler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698