OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/macros.h" | 6 #include "base/macros.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/synchronization/waitable_event.h" | 8 #include "base/synchronization/waitable_event.h" |
9 #include "base/test/test_message_loop.h" | 9 #include "base/test/test_message_loop.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
11 #include "media/audio/audio_io.h" | 11 #include "media/audio/audio_io.h" |
12 #include "media/audio/audio_manager.h" | 12 #include "media/audio/audio_manager.h" |
13 #include "media/audio/audio_unittest_util.h" | 13 #include "media/audio/audio_unittest_util.h" |
14 #include "media/audio/mock_audio_source_callback.h" | 14 #include "media/audio/mock_audio_source_callback.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 | 17 |
18 using testing::_; | 18 using testing::_; |
19 using testing::DoAll; | 19 using testing::DoAll; |
20 using testing::Return; | 20 using testing::Return; |
21 | 21 |
22 // TODO(crogers): Most of these tests can be made platform agnostic. | 22 // TODO(crogers): Most of these tests can be made platform agnostic. |
23 // http://crbug.com/223242 | 23 // http://crbug.com/223242 |
24 | 24 |
25 namespace media { | 25 namespace media { |
26 | 26 |
27 ACTION(ZeroBuffer) { | 27 ACTION(ZeroBuffer) { |
28 arg0->Zero(); | 28 arg3->Zero(); |
29 } | 29 } |
30 | 30 |
31 ACTION_P3(MaybeSignalEvent, counter, signal_at_count, event) { | 31 ACTION_P3(MaybeSignalEvent, counter, signal_at_count, event) { |
32 if (++(*counter) == signal_at_count) | 32 if (++(*counter) == signal_at_count) |
33 event->Signal(); | 33 event->Signal(); |
34 } | 34 } |
35 | 35 |
36 class AUHALStreamTest : public testing::Test { | 36 class AUHALStreamTest : public testing::Test { |
37 public: | 37 public: |
38 AUHALStreamTest() | 38 AUHALStreamTest() |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 ABORT_AUDIO_TEST_IF_NOT(OutputDevicesAvailable()); | 91 ABORT_AUDIO_TEST_IF_NOT(OutputDevicesAvailable()); |
92 | 92 |
93 AudioOutputStream* stream = Create(); | 93 AudioOutputStream* stream = Create(); |
94 EXPECT_TRUE(stream->Open()); | 94 EXPECT_TRUE(stream->Open()); |
95 | 95 |
96 // Wait for the first two data callback from the OS. | 96 // Wait for the first two data callback from the OS. |
97 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, | 97 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
98 base::WaitableEvent::InitialState::NOT_SIGNALED); | 98 base::WaitableEvent::InitialState::NOT_SIGNALED); |
99 int callback_counter = 0; | 99 int callback_counter = 0; |
100 const int number_of_callbacks = 2; | 100 const int number_of_callbacks = 2; |
101 EXPECT_CALL(source_, OnMoreData(_, _, _)) | 101 EXPECT_CALL(source_, OnMoreData(_, _, _, _)) |
102 .Times(number_of_callbacks) | 102 .Times(number_of_callbacks) |
103 .WillRepeatedly(DoAll( | 103 .WillRepeatedly(DoAll( |
104 ZeroBuffer(), | 104 ZeroBuffer(), |
105 MaybeSignalEvent(&callback_counter, number_of_callbacks, &event), | 105 MaybeSignalEvent(&callback_counter, number_of_callbacks, &event), |
106 Return(0))); | 106 Return(0))); |
107 EXPECT_CALL(source_, OnError(_)).Times(0); | 107 EXPECT_CALL(source_, OnError(_)).Times(0); |
108 stream->Start(&source_); | 108 stream->Start(&source_); |
109 event.Wait(); | 109 event.Wait(); |
110 | 110 |
111 stream->Stop(); | 111 stream->Stop(); |
112 stream->Close(); | 112 stream->Close(); |
113 | 113 |
114 EXPECT_FALSE(log_message_.empty()); | 114 EXPECT_FALSE(log_message_.empty()); |
115 } | 115 } |
116 | 116 |
117 } // namespace media | 117 } // namespace media |
OLD | NEW |