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