| 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/audio_mirroring_manager.h" | 5 #include "content/browser/media/capture/audio_mirroring_manager.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
| 15 #include "content/browser/browser_thread_impl.h" | 15 #include "content/browser/browser_thread_impl.h" |
| 16 #include "media/audio/audio_parameters.h" | 16 #include "media/audio/audio_parameters.h" |
| 17 #include "media/audio/virtual_audio_sink.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 18 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 20 |
| 20 using media::AudioOutputStream; | 21 using media::AudioOutputStream; |
| 21 using media::AudioParameters; | 22 using media::AudioParameters; |
| 23 using media::AudioPushSink; |
| 22 using testing::_; | 24 using testing::_; |
| 23 using testing::Invoke; | 25 using testing::Invoke; |
| 24 using testing::NotNull; | 26 using testing::NotNull; |
| 25 using testing::Ref; | 27 using testing::Ref; |
| 26 using testing::Return; | 28 using testing::Return; |
| 27 using testing::ReturnRef; | 29 using testing::ReturnRef; |
| 28 | 30 |
| 29 namespace content { | 31 namespace content { |
| 30 | 32 |
| 31 namespace { | 33 namespace { |
| 32 | 34 |
| 33 class MockDiverter : public AudioMirroringManager::Diverter { | 35 class MockDiverter : public AudioMirroringManager::Diverter { |
| 34 public: | 36 public: |
| 35 MOCK_METHOD0(GetAudioParameters, const AudioParameters&()); | 37 MOCK_METHOD0(GetAudioParameters, const AudioParameters&()); |
| 36 MOCK_METHOD1(StartDiverting, void(AudioOutputStream*)); | 38 MOCK_METHOD1(StartDiverting, void(AudioOutputStream*)); |
| 37 MOCK_METHOD0(StopDiverting, void()); | 39 MOCK_METHOD0(StopDiverting, void()); |
| 40 MOCK_METHOD1(StartDuplicating, void(AudioPushSink*)); |
| 41 MOCK_METHOD1(StopDuplicating, void(AudioPushSink*)); |
| 38 }; | 42 }; |
| 39 | 43 |
| 40 class MockMirroringDestination | 44 class MockMirroringDestination |
| 41 : public AudioMirroringManager::MirroringDestination { | 45 : public AudioMirroringManager::MirroringDestination { |
| 42 public: | 46 public: |
| 43 typedef AudioMirroringManager::SourceFrameRef SourceFrameRef; | 47 typedef AudioMirroringManager::SourceFrameRef SourceFrameRef; |
| 44 | 48 |
| 45 MockMirroringDestination(int render_process_id, int render_frame_id) | 49 MockMirroringDestination(int render_process_id, int render_frame_id) |
| 46 : render_process_id_(render_process_id), | 50 : render_process_id_(render_process_id), |
| 47 render_frame_id_(render_frame_id), | 51 render_frame_id_(render_frame_id), |
| 48 query_count_(0) {} | 52 query_count_(0) {} |
| 49 | 53 |
| 50 MOCK_METHOD2(QueryForMatches, | 54 MOCK_METHOD2(QueryForMatches, |
| 51 void(const std::set<SourceFrameRef>& candidates, | 55 void(const std::set<SourceFrameRef>& candidates, |
| 52 const MatchesCallback& results_callback)); | 56 const MatchesCallback& results_callback)); |
| 53 MOCK_METHOD1(AddInput, | 57 MOCK_METHOD1(AddInput, |
| 54 media::AudioOutputStream*(const media::AudioParameters& params)); | 58 media::AudioOutputStream*(const media::AudioParameters& params)); |
| 55 | 59 |
| 60 MOCK_METHOD1(AddPushInput, |
| 61 media::AudioPushSink*(const media::AudioParameters& params)); |
| 62 |
| 63 bool IsDuplication() override { return false; } |
| 64 |
| 56 void SimulateQuery(const std::set<SourceFrameRef>& candidates, | 65 void SimulateQuery(const std::set<SourceFrameRef>& candidates, |
| 57 const MatchesCallback& results_callback) { | 66 const MatchesCallback& results_callback) { |
| 58 ++query_count_; | 67 ++query_count_; |
| 59 | 68 |
| 60 std::set<SourceFrameRef> result; | 69 std::set<SourceFrameRef> result; |
| 61 if (candidates.find(SourceFrameRef(render_process_id_, render_frame_id_)) != | 70 if (candidates.find(SourceFrameRef(render_process_id_, render_frame_id_)) != |
| 62 candidates.end()) { | 71 candidates.end()) { |
| 63 result.insert(SourceFrameRef(render_process_id_, render_frame_id_)); | 72 result.insert(SourceFrameRef(render_process_id_, render_frame_id_)); |
| 64 } | 73 } |
| 65 results_callback.Run(result); | 74 results_callback.Run(result); |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 EXPECT_EQ(0, CountStreamsDivertedTo(destination)); | 555 EXPECT_EQ(0, CountStreamsDivertedTo(destination)); |
| 547 EXPECT_EQ(2, another_destination->query_count()); | 556 EXPECT_EQ(2, another_destination->query_count()); |
| 548 EXPECT_EQ(0, CountStreamsDivertedTo(another_destination)); | 557 EXPECT_EQ(0, CountStreamsDivertedTo(another_destination)); |
| 549 EXPECT_EQ(2, yet_another_destination->query_count()); | 558 EXPECT_EQ(2, yet_another_destination->query_count()); |
| 550 EXPECT_EQ(0, CountStreamsDivertedTo(yet_another_destination)); | 559 EXPECT_EQ(0, CountStreamsDivertedTo(yet_another_destination)); |
| 551 | 560 |
| 552 ExpectNoLongerManagingAnything(); | 561 ExpectNoLongerManagingAnything(); |
| 553 } | 562 } |
| 554 | 563 |
| 555 } // namespace content | 564 } // namespace content |
| OLD | NEW |