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

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

Issue 1896883002: Mojo interfaces needed for switching audio rendering stream creation and closing from IPC to Mojo (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/environment.h" 8 #include "base/environment.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 21 matching lines...) Expand all
32 static const int kBitsPerSample = 16; 32 static const int kBitsPerSample = 16;
33 static const ChannelLayout kChannelLayout = CHANNEL_LAYOUT_STEREO; 33 static const ChannelLayout kChannelLayout = CHANNEL_LAYOUT_STEREO;
34 static const int kSamplesPerPacket = kSampleRate / 100; 34 static const int kSamplesPerPacket = kSampleRate / 100;
35 static const double kTestVolume = 0.25; 35 static const double kTestVolume = 0.25;
36 36
37 class MockAudioOutputControllerEventHandler 37 class MockAudioOutputControllerEventHandler
38 : public AudioOutputController::EventHandler { 38 : public AudioOutputController::EventHandler {
39 public: 39 public:
40 MockAudioOutputControllerEventHandler() {} 40 MockAudioOutputControllerEventHandler() {}
41 41
42 MOCK_METHOD0(OnCreated, void()); 42 MOCK_METHOD1(
43 OnCreated,
44 void(const interfaces::AudioOutput::CreateStreamCallback& callback));
43 MOCK_METHOD0(OnPlaying, void()); 45 MOCK_METHOD0(OnPlaying, void());
44 MOCK_METHOD0(OnPaused, void()); 46 MOCK_METHOD0(OnPaused, void());
45 MOCK_METHOD0(OnError, void()); 47 MOCK_METHOD0(OnError, void());
46 48
47 private: 49 private:
48 DISALLOW_COPY_AND_ASSIGN(MockAudioOutputControllerEventHandler); 50 DISALLOW_COPY_AND_ASSIGN(MockAudioOutputControllerEventHandler);
49 }; 51 };
50 52
51 class MockAudioOutputControllerSyncReader 53 class MockAudioOutputControllerSyncReader
52 : public AudioOutputController::SyncReader { 54 : public AudioOutputController::SyncReader {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 protected: 108 protected:
107 void Create(int samples_per_packet) { 109 void Create(int samples_per_packet) {
108 EXPECT_FALSE(create_event_.IsSignaled()); 110 EXPECT_FALSE(create_event_.IsSignaled());
109 EXPECT_FALSE(play_event_.IsSignaled()); 111 EXPECT_FALSE(play_event_.IsSignaled());
110 EXPECT_FALSE(read_event_.IsSignaled()); 112 EXPECT_FALSE(read_event_.IsSignaled());
111 EXPECT_FALSE(pause_event_.IsSignaled()); 113 EXPECT_FALSE(pause_event_.IsSignaled());
112 114
113 params_ = AudioParameters( 115 params_ = AudioParameters(
114 AudioParameters::AUDIO_FAKE, kChannelLayout, 116 AudioParameters::AUDIO_FAKE, kChannelLayout,
115 kSampleRate, kBitsPerSample, samples_per_packet); 117 kSampleRate, kBitsPerSample, samples_per_packet);
116 118 interfaces::AudioOutput::CreateStreamCallback callback;
117 if (params_.IsValid()) { 119 if (params_.IsValid()) {
118 EXPECT_CALL(mock_event_handler_, OnCreated()) 120 EXPECT_CALL(mock_event_handler_, OnCreated(_))
119 .WillOnce(SignalEvent(&create_event_)); 121 .WillOnce(SignalEvent(&create_event_));
120 } 122 }
121 123
122 controller_ = AudioOutputController::Create( 124 controller_ = AudioOutputController::Create(
123 audio_manager_.get(), &mock_event_handler_, params_, std::string(), 125 audio_manager_.get(), &mock_event_handler_, params_, std::string(),
124 &mock_sync_reader_); 126 &mock_sync_reader_, callback);
125 if (controller_.get()) 127 if (controller_.get())
126 controller_->SetVolume(kTestVolume); 128 controller_->SetVolume(kTestVolume);
127 129
128 EXPECT_EQ(params_.IsValid(), controller_.get() != NULL); 130 EXPECT_EQ(params_.IsValid(), controller_.get() != NULL);
129 } 131 }
130 132
131 void Play() { 133 void Play() {
132 // Expect the event handler to receive one OnPlaying() call. 134 // Expect the event handler to receive one OnPlaying() call.
133 EXPECT_CALL(mock_event_handler_, OnPlaying()) 135 EXPECT_CALL(mock_event_handler_, OnPlaying())
134 .WillOnce(SignalEvent(&play_event_)); 136 .WillOnce(SignalEvent(&play_event_));
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 407
406 TEST_F(AudioOutputControllerTest, DivertRevertClose) { 408 TEST_F(AudioOutputControllerTest, DivertRevertClose) {
407 Create(kSamplesPerPacket); 409 Create(kSamplesPerPacket);
408 WaitForCreate(); 410 WaitForCreate();
409 DivertNeverPlaying(); 411 DivertNeverPlaying();
410 RevertWasNotPlaying(); 412 RevertWasNotPlaying();
411 Close(); 413 Close();
412 } 414 }
413 415
414 } // namespace media 416 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698