OLD | NEW |
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 Loading... |
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 content::mojom::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 Loading... |
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 content::mojom::AudioOutput::CreateStreamCallback callback; |
117 if (params_.IsValid()) { | 119 if (params_.IsValid()) { |
118 EXPECT_CALL(mock_event_handler_, OnCreated()) | 120 /* |
119 .WillOnce(SignalEvent(&create_event_)); | 121 EXPECT_CALL(mock_event_handler_, OnCreated(callback)) |
| 122 .WillOnce(SignalEvent(&create_event_));*/ |
120 } | 123 } |
121 | 124 |
122 controller_ = AudioOutputController::Create( | 125 controller_ = AudioOutputController::Create( |
123 audio_manager_.get(), &mock_event_handler_, params_, std::string(), | 126 audio_manager_.get(), &mock_event_handler_, params_, std::string(), |
124 &mock_sync_reader_); | 127 &mock_sync_reader_, callback); |
125 if (controller_.get()) | 128 if (controller_.get()) |
126 controller_->SetVolume(kTestVolume); | 129 controller_->SetVolume(kTestVolume); |
127 | 130 |
128 EXPECT_EQ(params_.IsValid(), controller_.get() != NULL); | 131 EXPECT_EQ(params_.IsValid(), controller_.get() != NULL); |
129 } | 132 } |
130 | 133 |
131 void Play() { | 134 void Play() { |
132 // Expect the event handler to receive one OnPlaying() call. | 135 // Expect the event handler to receive one OnPlaying() call. |
133 EXPECT_CALL(mock_event_handler_, OnPlaying()) | 136 EXPECT_CALL(mock_event_handler_, OnPlaying()) |
134 .WillOnce(SignalEvent(&play_event_)); | 137 .WillOnce(SignalEvent(&play_event_)); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 | 408 |
406 TEST_F(AudioOutputControllerTest, DivertRevertClose) { | 409 TEST_F(AudioOutputControllerTest, DivertRevertClose) { |
407 Create(kSamplesPerPacket); | 410 Create(kSamplesPerPacket); |
408 WaitForCreate(); | 411 WaitForCreate(); |
409 DivertNeverPlaying(); | 412 DivertNeverPlaying(); |
410 RevertWasNotPlaying(); | 413 RevertWasNotPlaying(); |
411 Close(); | 414 Close(); |
412 } | 415 } |
413 | 416 |
414 } // namespace media | 417 } // namespace media |
OLD | NEW |