OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "content/browser/media/capture/web_contents_audio_input_stream.h" | 5 #include "content/browser/media/capture/web_contents_audio_input_stream.h" |
6 | 6 |
7 #include <list> | 7 #include <list> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
xhwang
2015/04/30 15:54:45
Do we still need this?
anujsharma
2015/05/04 08:07:56
Yes, it is required!!
| |
12 #include "base/single_thread_task_runner.h" | |
12 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
13 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
14 #include "content/browser/media/capture/audio_mirroring_manager.h" | 15 #include "content/browser/media/capture/audio_mirroring_manager.h" |
15 #include "content/browser/media/capture/web_contents_tracker.h" | 16 #include "content/browser/media/capture/web_contents_tracker.h" |
16 #include "content/public/browser/browser_thread.h" | 17 #include "content/public/browser/browser_thread.h" |
17 #include "content/public/test/test_browser_thread_bundle.h" | 18 #include "content/public/test/test_browser_thread_bundle.h" |
18 #include "media/audio/simple_sources.h" | 19 #include "media/audio/simple_sources.h" |
19 #include "media/audio/virtual_audio_input_stream.h" | 20 #include "media/audio/virtual_audio_input_stream.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 virtual ~MockWebContentsTracker() {} | 80 virtual ~MockWebContentsTracker() {} |
80 | 81 |
81 DISALLOW_COPY_AND_ASSIGN(MockWebContentsTracker); | 82 DISALLOW_COPY_AND_ASSIGN(MockWebContentsTracker); |
82 }; | 83 }; |
83 | 84 |
84 // A fully-functional VirtualAudioInputStream, but methods are mocked to allow | 85 // A fully-functional VirtualAudioInputStream, but methods are mocked to allow |
85 // tests to check how/when they are invoked. | 86 // tests to check how/when they are invoked. |
86 class MockVirtualAudioInputStream : public VirtualAudioInputStream { | 87 class MockVirtualAudioInputStream : public VirtualAudioInputStream { |
87 public: | 88 public: |
88 explicit MockVirtualAudioInputStream( | 89 explicit MockVirtualAudioInputStream( |
89 const scoped_refptr<base::MessageLoopProxy>& worker_loop) | 90 const scoped_refptr<base::SingleThreadTaskRunner>& worker_loop) |
90 : VirtualAudioInputStream(TestAudioParameters(), worker_loop, | 91 : VirtualAudioInputStream(TestAudioParameters(), worker_loop, |
91 VirtualAudioInputStream::AfterCloseCallback()), | 92 VirtualAudioInputStream::AfterCloseCallback()), |
92 real_(TestAudioParameters(), worker_loop, | 93 real_(TestAudioParameters(), worker_loop, |
93 base::Bind(&MockVirtualAudioInputStream::OnRealStreamHasClosed, | 94 base::Bind(&MockVirtualAudioInputStream::OnRealStreamHasClosed, |
94 base::Unretained(this))), | 95 base::Unretained(this))), |
95 real_stream_is_closed_(false) { | 96 real_stream_is_closed_(false) { |
96 // Set default actions of mocked methods to delegate to the concrete | 97 // Set default actions of mocked methods to delegate to the concrete |
97 // implementation. | 98 // implementation. |
98 ON_CALL(*this, Open()) | 99 ON_CALL(*this, Open()) |
99 .WillByDefault(Invoke(&real_, &VirtualAudioInputStream::Open)); | 100 .WillByDefault(Invoke(&real_, &VirtualAudioInputStream::Open)); |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
499 WaitForData(); | 500 WaitForData(); |
500 RUN_ON_AUDIO_THREAD(RemoveOneInputInFIFOOrder); | 501 RUN_ON_AUDIO_THREAD(RemoveOneInputInFIFOOrder); |
501 WaitForData(); | 502 WaitForData(); |
502 RUN_ON_AUDIO_THREAD(ChangeMirroringTarget); | 503 RUN_ON_AUDIO_THREAD(ChangeMirroringTarget); |
503 RUN_ON_AUDIO_THREAD(RemoveOneInputInFIFOOrder); | 504 RUN_ON_AUDIO_THREAD(RemoveOneInputInFIFOOrder); |
504 RUN_ON_AUDIO_THREAD(Stop); | 505 RUN_ON_AUDIO_THREAD(Stop); |
505 RUN_ON_AUDIO_THREAD(Close); | 506 RUN_ON_AUDIO_THREAD(Close); |
506 } | 507 } |
507 | 508 |
508 } // namespace content | 509 } // namespace content |
OLD | NEW |