| 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" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 stream->Close(); | 87 stream->Close(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 TEST_F(AUHALStreamTest, CreateOpenStartStopClose) { | 90 TEST_F(AUHALStreamTest, CreateOpenStartStopClose) { |
| 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(false, false); | 97 base::WaitableEvent event(base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 98 base::WaitableEvent::InitialState::NOT_SIGNALED); |
| 98 int callback_counter = 0; | 99 int callback_counter = 0; |
| 99 const int number_of_callbacks = 2; | 100 const int number_of_callbacks = 2; |
| 100 EXPECT_CALL(source_, OnMoreData(_, _, _)) | 101 EXPECT_CALL(source_, OnMoreData(_, _, _)) |
| 101 .Times(number_of_callbacks) | 102 .Times(number_of_callbacks) |
| 102 .WillRepeatedly(DoAll( | 103 .WillRepeatedly(DoAll( |
| 103 ZeroBuffer(), | 104 ZeroBuffer(), |
| 104 MaybeSignalEvent(&callback_counter, number_of_callbacks, &event), | 105 MaybeSignalEvent(&callback_counter, number_of_callbacks, &event), |
| 105 Return(0))); | 106 Return(0))); |
| 106 EXPECT_CALL(source_, OnError(_)).Times(0); | 107 EXPECT_CALL(source_, OnError(_)).Times(0); |
| 107 stream->Start(&source_); | 108 stream->Start(&source_); |
| 108 event.Wait(); | 109 event.Wait(); |
| 109 | 110 |
| 110 stream->Stop(); | 111 stream->Stop(); |
| 111 stream->Close(); | 112 stream->Close(); |
| 112 | 113 |
| 113 EXPECT_FALSE(log_message_.empty()); | 114 EXPECT_FALSE(log_message_.empty()); |
| 114 } | 115 } |
| 115 | 116 |
| 116 } // namespace media | 117 } // namespace media |
| OLD | NEW |