| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/session/audio_focus_manager.h" | 5 #include "content/browser/media/session/audio_focus_manager.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "content/browser/media/session/media_session_impl.h" | 9 #include "content/browser/media/session/media_session_impl.h" |
| 10 #include "content/browser/media/session/media_session_player_observer.h" | 10 #include "content/browser/media/session/media_session_player_observer.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 using SuspendType = MediaSession::SuspendType; | 34 using SuspendType = MediaSession::SuspendType; |
| 35 | 35 |
| 36 class AudioFocusManagerTest : public testing::Test { | 36 class AudioFocusManagerTest : public testing::Test { |
| 37 public: | 37 public: |
| 38 AudioFocusManagerTest() = default; | 38 AudioFocusManagerTest() = default; |
| 39 | 39 |
| 40 void SetUp() override { | 40 void SetUp() override { |
| 41 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 41 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 42 switches::kEnableDefaultMediaSession); | 42 switches::kEnableDefaultMediaSession); |
| 43 rph_factory_.reset(new MockRenderProcessHostFactory()); | 43 rph_factory_.reset(new MockRenderProcessHostFactory()); |
| 44 SiteInstanceImpl::set_render_process_host_factory(rph_factory_.get()); | 44 RenderProcessHostImpl::set_render_process_host_factory(rph_factory_.get()); |
| 45 browser_context_.reset(new TestBrowserContext()); | 45 browser_context_.reset(new TestBrowserContext()); |
| 46 pepper_observer_.reset(new MockMediaSessionPlayerObserver()); | 46 pepper_observer_.reset(new MockMediaSessionPlayerObserver()); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void TearDown() override { | 49 void TearDown() override { |
| 50 // Run pending tasks. | 50 // Run pending tasks. |
| 51 base::RunLoop().RunUntilIdle(); | 51 base::RunLoop().RunUntilIdle(); |
| 52 | 52 |
| 53 browser_context_.reset(); | 53 browser_context_.reset(); |
| 54 SiteInstanceImpl::set_render_process_host_factory(nullptr); | 54 RenderProcessHostImpl::set_render_process_host_factory(nullptr); |
| 55 rph_factory_.reset(); | 55 rph_factory_.reset(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 MediaSessionImpl* GetAudioFocusedSession() const { | 58 MediaSessionImpl* GetAudioFocusedSession() const { |
| 59 const auto& audio_focus_stack = | 59 const auto& audio_focus_stack = |
| 60 AudioFocusManager::GetInstance()->audio_focus_stack_; | 60 AudioFocusManager::GetInstance()->audio_focus_stack_; |
| 61 for (auto iter = audio_focus_stack.rbegin(); | 61 for (auto iter = audio_focus_stack.rbegin(); |
| 62 iter != audio_focus_stack.rend(); ++iter) { | 62 iter != audio_focus_stack.rend(); ++iter) { |
| 63 if ((*iter)->audio_focus_type() == | 63 if ((*iter)->audio_focus_type() == |
| 64 AudioFocusManager::AudioFocusType::Gain) | 64 AudioFocusManager::AudioFocusType::Gain) |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 ASSERT_EQ(media_session_3, GetAudioFocusedSession()); | 453 ASSERT_EQ(media_session_3, GetAudioFocusedSession()); |
| 454 ASSERT_TRUE(media_session_2->IsSuspended()); | 454 ASSERT_TRUE(media_session_2->IsSuspended()); |
| 455 ASSERT_TRUE(media_session_1->IsActive()); | 455 ASSERT_TRUE(media_session_1->IsActive()); |
| 456 ASSERT_TRUE(IsSessionDucking(media_session_1)); | 456 ASSERT_TRUE(IsSessionDucking(media_session_1)); |
| 457 | 457 |
| 458 AbandonAudioFocus(media_session_3); | 458 AbandonAudioFocus(media_session_3); |
| 459 ASSERT_EQ(media_session_1, GetAudioFocusedSession()); | 459 ASSERT_EQ(media_session_1, GetAudioFocusedSession()); |
| 460 } | 460 } |
| 461 | 461 |
| 462 } // namespace content | 462 } // namespace content |
| OLD | NEW |