| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/message_loop_proxy.h" | 9 #include "base/message_loop_proxy.h" |
| 10 #include "media/audio/audio_output_dispatcher_impl.h" | 10 #include "media/audio/audio_output_dispatcher_impl.h" |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 class MockAudioSourceCallback : public AudioOutputStream::AudioSourceCallback { | 124 class MockAudioSourceCallback : public AudioOutputStream::AudioSourceCallback { |
| 125 public: | 125 public: |
| 126 int OnMoreData(AudioBus* audio_bus, AudioBuffersState buffers_state) { | 126 int OnMoreData(AudioBus* audio_bus, AudioBuffersState buffers_state) { |
| 127 audio_bus->Zero(); | 127 audio_bus->Zero(); |
| 128 return audio_bus->frames(); | 128 return audio_bus->frames(); |
| 129 } | 129 } |
| 130 int OnMoreIOData(AudioBus* source, AudioBus* dest, | 130 int OnMoreIOData(AudioBus* source, AudioBus* dest, |
| 131 AudioBuffersState buffers_state) { | 131 AudioBuffersState buffers_state) { |
| 132 return OnMoreData(dest, buffers_state); | 132 return OnMoreData(dest, buffers_state); |
| 133 } | 133 } |
| 134 MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code)); | 134 MOCK_METHOD1(OnError, void(AudioOutputStream* stream)); |
| 135 }; | 135 }; |
| 136 | 136 |
| 137 } // namespace | 137 } // namespace |
| 138 | 138 |
| 139 namespace media { | 139 namespace media { |
| 140 | 140 |
| 141 class AudioOutputProxyTest : public testing::Test { | 141 class AudioOutputProxyTest : public testing::Test { |
| 142 protected: | 142 protected: |
| 143 virtual void SetUp() { | 143 virtual void SetUp() { |
| 144 EXPECT_CALL(manager_, GetMessageLoop()) | 144 EXPECT_CALL(manager_, GetMessageLoop()) |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 message_loop_.RunUntilIdle(); | 424 message_loop_.RunUntilIdle(); |
| 425 | 425 |
| 426 // Verify expectation before calling Close(). | 426 // Verify expectation before calling Close(). |
| 427 Mock::VerifyAndClear(&stream); | 427 Mock::VerifyAndClear(&stream); |
| 428 | 428 |
| 429 // |stream| is closed at this point. Start() should reopen it again. | 429 // |stream| is closed at this point. Start() should reopen it again. |
| 430 EXPECT_CALL(manager(), MakeAudioOutputStream(_)) | 430 EXPECT_CALL(manager(), MakeAudioOutputStream(_)) |
| 431 .Times(2) | 431 .Times(2) |
| 432 .WillRepeatedly(Return(reinterpret_cast<AudioOutputStream*>(NULL))); | 432 .WillRepeatedly(Return(reinterpret_cast<AudioOutputStream*>(NULL))); |
| 433 | 433 |
| 434 EXPECT_CALL(callback_, OnError(_, _)) | 434 EXPECT_CALL(callback_, OnError(_)) |
| 435 .Times(2); | 435 .Times(2); |
| 436 | 436 |
| 437 proxy->Start(&callback_); | 437 proxy->Start(&callback_); |
| 438 | 438 |
| 439 // Double Start() in the error case should be allowed since it's possible a | 439 // Double Start() in the error case should be allowed since it's possible a |
| 440 // callback may not have had time to process the OnError() in between. | 440 // callback may not have had time to process the OnError() in between. |
| 441 proxy->Stop(); | 441 proxy->Stop(); |
| 442 proxy->Start(&callback_); | 442 proxy->Start(&callback_); |
| 443 | 443 |
| 444 Mock::VerifyAndClear(&callback_); | 444 Mock::VerifyAndClear(&callback_); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 WaitForCloseTimer(kTestCloseDelayMs); | 733 WaitForCloseTimer(kTestCloseDelayMs); |
| 734 EXPECT_TRUE(stream1.stop_called()); | 734 EXPECT_TRUE(stream1.stop_called()); |
| 735 EXPECT_TRUE(stream1.start_called()); | 735 EXPECT_TRUE(stream1.start_called()); |
| 736 EXPECT_TRUE(stream2.stop_called()); | 736 EXPECT_TRUE(stream2.stop_called()); |
| 737 EXPECT_TRUE(stream2.start_called()); | 737 EXPECT_TRUE(stream2.start_called()); |
| 738 EXPECT_FALSE(stream3.stop_called()); | 738 EXPECT_FALSE(stream3.stop_called()); |
| 739 EXPECT_FALSE(stream3.start_called()); | 739 EXPECT_FALSE(stream3.start_called()); |
| 740 } | 740 } |
| 741 | 741 |
| 742 } // namespace media | 742 } // namespace media |
| OLD | NEW |