| 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 "base/message_loop.h" | 5 #include "base/message_loop.h" |
| 6 #include "base/message_loop_proxy.h" | 6 #include "base/message_loop_proxy.h" |
| 7 #include "base/threading/platform_thread.h" | 7 #include "base/threading/platform_thread.h" |
| 8 #include "media/audio/audio_output_dispatcher.h" | 8 #include "media/audio/audio_output_dispatcher.h" |
| 9 #include "media/audio/audio_output_proxy.h" | 9 #include "media/audio/audio_output_proxy.h" |
| 10 #include "media/audio/audio_manager.h" | 10 #include "media/audio/audio_manager.h" |
| 11 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 13 |
| 14 using ::testing::_; | 14 using ::testing::_; |
| 15 using ::testing::Mock; | 15 using ::testing::Mock; |
| 16 using ::testing::Return; | 16 using ::testing::Return; |
| 17 using media::AudioBuffersState; |
| 18 using media::AudioInputStream; |
| 19 using media::AudioManager; |
| 20 using media::AudioOutputDispatcher; |
| 21 using media::AudioOutputProxy; |
| 22 using media::AudioOutputStream; |
| 23 using media::AudioParameters; |
| 24 |
| 25 namespace { |
| 17 | 26 |
| 18 static const int kTestCloseDelayMs = 100; | 27 static const int kTestCloseDelayMs = 100; |
| 19 | 28 |
| 20 // Used in the test where we don't want a stream to be closed unexpectedly. | 29 // Used in the test where we don't want a stream to be closed unexpectedly. |
| 21 static const int kTestBigCloseDelaySeconds = 1000; | 30 static const int kTestBigCloseDelaySeconds = 1000; |
| 22 | 31 |
| 23 class MockAudioOutputStream : public AudioOutputStream { | 32 class MockAudioOutputStream : public AudioOutputStream { |
| 24 public: | 33 public: |
| 25 MockAudioOutputStream() {} | 34 MockAudioOutputStream() {} |
| 26 | 35 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 }; | 67 }; |
| 59 | 68 |
| 60 class MockAudioSourceCallback : public AudioOutputStream::AudioSourceCallback { | 69 class MockAudioSourceCallback : public AudioOutputStream::AudioSourceCallback { |
| 61 public: | 70 public: |
| 62 MOCK_METHOD4(OnMoreData, uint32(AudioOutputStream* stream, | 71 MOCK_METHOD4(OnMoreData, uint32(AudioOutputStream* stream, |
| 63 uint8* dest, uint32 max_size, | 72 uint8* dest, uint32 max_size, |
| 64 AudioBuffersState buffers_state)); | 73 AudioBuffersState buffers_state)); |
| 65 MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code)); | 74 MOCK_METHOD2(OnError, void(AudioOutputStream* stream, int code)); |
| 66 }; | 75 }; |
| 67 | 76 |
| 77 } // namespace |
| 78 |
| 79 namespace media { |
| 80 |
| 68 class AudioOutputProxyTest : public testing::Test { | 81 class AudioOutputProxyTest : public testing::Test { |
| 69 protected: | 82 protected: |
| 70 virtual void SetUp() { | 83 virtual void SetUp() { |
| 71 EXPECT_CALL(manager_, GetMessageLoop()) | 84 EXPECT_CALL(manager_, GetMessageLoop()) |
| 72 .WillRepeatedly(Return(message_loop_.message_loop_proxy())); | 85 .WillRepeatedly(Return(message_loop_.message_loop_proxy())); |
| 73 InitDispatcher(base::TimeDelta::FromMilliseconds(kTestCloseDelayMs)); | 86 InitDispatcher(base::TimeDelta::FromMilliseconds(kTestCloseDelayMs)); |
| 74 } | 87 } |
| 75 | 88 |
| 76 virtual void TearDown() { | 89 virtual void TearDown() { |
| 77 // All paused proxies should have been closed at this point. | 90 // All paused proxies should have been closed at this point. |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 | 377 |
| 365 EXPECT_CALL(callback_, OnError(_, _)) | 378 EXPECT_CALL(callback_, OnError(_, _)) |
| 366 .Times(1); | 379 .Times(1); |
| 367 | 380 |
| 368 proxy->Start(&callback_); | 381 proxy->Start(&callback_); |
| 369 | 382 |
| 370 Mock::VerifyAndClear(&callback_); | 383 Mock::VerifyAndClear(&callback_); |
| 371 | 384 |
| 372 proxy->Close(); | 385 proxy->Close(); |
| 373 } | 386 } |
| 387 |
| 388 } // namespace media |
| OLD | NEW |