| 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/memory/scoped_ptr.h" | 6 #include "base/memory/scoped_ptr.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
| 10 #include "media/audio/audio_io.h" | 10 #include "media/audio/audio_io.h" |
| 11 #include "media/audio/audio_manager.h" | 11 #include "media/audio/audio_manager.h" |
| 12 #include "media/audio/mock_audio_source_callback.h" | 12 #include "media/audio/mock_audio_source_callback.h" |
| 13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 15 |
| 16 using testing::_; | 16 using testing::_; |
| 17 using testing::DoAll; | 17 using testing::DoAll; |
| 18 using testing::Return; | 18 using testing::Return; |
| 19 | 19 |
| 20 // TODO(crogers): Most of these tests can be made platform agnostic. | 20 // TODO(crogers): Most of these tests can be made platform agnostic. |
| 21 // http://crbug.com/223242 | 21 // http://crbug.com/223242 |
| 22 | 22 |
| 23 namespace media { | 23 namespace media { |
| 24 | 24 |
| 25 ACTION(ZeroBuffer) { | 25 ACTION(ZeroBuffer) { |
| 26 arg1->Zero(); | 26 arg0->Zero(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 ACTION_P(SignalEvent, event) { | 29 ACTION_P(SignalEvent, event) { |
| 30 event->Signal(); | 30 event->Signal(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 class AUHALStreamTest : public testing::Test { | 33 class AUHALStreamTest : public testing::Test { |
| 34 public: | 34 public: |
| 35 AUHALStreamTest() | 35 AUHALStreamTest() |
| 36 : message_loop_(base::MessageLoop::TYPE_UI), | 36 : message_loop_(base::MessageLoop::TYPE_UI), |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 | 86 |
| 87 TEST_F(AUHALStreamTest, CreateOpenStartStopClose) { | 87 TEST_F(AUHALStreamTest, CreateOpenStartStopClose) { |
| 88 if (!CanRunAudioTests()) | 88 if (!CanRunAudioTests()) |
| 89 return; | 89 return; |
| 90 | 90 |
| 91 AudioOutputStream* stream = Create(); | 91 AudioOutputStream* stream = Create(); |
| 92 EXPECT_TRUE(stream->Open()); | 92 EXPECT_TRUE(stream->Open()); |
| 93 | 93 |
| 94 // Wait for the first data callback from the OS. | 94 // Wait for the first data callback from the OS. |
| 95 base::WaitableEvent event(false, false); | 95 base::WaitableEvent event(false, false); |
| 96 EXPECT_CALL(source_, OnMoreIOData(_, _, _)) | 96 EXPECT_CALL(source_, OnMoreData(_, _)) |
| 97 .WillOnce(DoAll(ZeroBuffer(), SignalEvent(&event), Return(0))); | 97 .WillOnce(DoAll(ZeroBuffer(), SignalEvent(&event), Return(0))); |
| 98 EXPECT_CALL(source_, OnError(_)).Times(0); | 98 EXPECT_CALL(source_, OnError(_)).Times(0); |
| 99 stream->Start(&source_); | 99 stream->Start(&source_); |
| 100 event.Wait(); | 100 event.Wait(); |
| 101 | 101 |
| 102 stream->Stop(); | 102 stream->Stop(); |
| 103 stream->Close(); | 103 stream->Close(); |
| 104 } | 104 } |
| 105 | 105 |
| 106 } // namespace media | 106 } // namespace media |
| OLD | NEW |