| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/audio_stream_monitor.h" | 5 #include "content/browser/media/audio_stream_monitor.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" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 clock_.Advance(base::TimeDelta::FromSeconds(1000000)); | 46 clock_.Advance(base::TimeDelta::FromSeconds(1000000)); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void SetUp() override { | 49 void SetUp() override { |
| 50 RenderViewHostTestHarness::SetUp(); | 50 RenderViewHostTestHarness::SetUp(); |
| 51 | 51 |
| 52 WebContentsImpl* web_contents = reinterpret_cast<WebContentsImpl*>( | 52 WebContentsImpl* web_contents = reinterpret_cast<WebContentsImpl*>( |
| 53 RenderViewHostTestHarness::web_contents()); | 53 RenderViewHostTestHarness::web_contents()); |
| 54 web_contents->SetDelegate(&mock_web_contents_delegate_); | 54 web_contents->SetDelegate(&mock_web_contents_delegate_); |
| 55 | 55 |
| 56 AudioStateProvider* provider = web_contents->audio_state_provider(); | 56 monitor_ = web_contents->audio_stream_monitor(); |
| 57 ASSERT_TRUE(provider); | |
| 58 | |
| 59 monitor_ = provider->audio_stream_monitor(); | |
| 60 ASSERT_TRUE(monitor_); | |
| 61 | |
| 62 const_cast<base::TickClock*&>(monitor_->clock_) = &clock_; | 57 const_cast<base::TickClock*&>(monitor_->clock_) = &clock_; |
| 63 } | 58 } |
| 64 | 59 |
| 65 base::TimeTicks GetTestClockTime() { return clock_.NowTicks(); } | 60 base::TimeTicks GetTestClockTime() { return clock_.NowTicks(); } |
| 66 | 61 |
| 67 void AdvanceClock(const base::TimeDelta& delta) { clock_.Advance(delta); } | 62 void AdvanceClock(const base::TimeDelta& delta) { clock_.Advance(delta); } |
| 68 | 63 |
| 69 AudioStreamMonitor::ReadPowerAndClipCallback CreatePollCallback( | 64 AudioStreamMonitor::ReadPowerAndClipCallback CreatePollCallback( |
| 70 int stream_id) { | 65 int stream_id) { |
| 71 return base::Bind( | 66 return base::Bind( |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 StartMonitoring( | 289 StartMonitoring( |
| 295 kAnotherRenderProcessId, kStreamId, CreatePollCallback(kStreamId)); | 290 kAnotherRenderProcessId, kStreamId, CreatePollCallback(kStreamId)); |
| 296 ExpectIsPolling(kRenderProcessId, kStreamId, true); | 291 ExpectIsPolling(kRenderProcessId, kStreamId, true); |
| 297 ExpectIsPolling(kAnotherRenderProcessId, kStreamId, true); | 292 ExpectIsPolling(kAnotherRenderProcessId, kStreamId, true); |
| 298 StopMonitoring(kAnotherRenderProcessId, kStreamId); | 293 StopMonitoring(kAnotherRenderProcessId, kStreamId); |
| 299 ExpectIsPolling(kRenderProcessId, kStreamId, true); | 294 ExpectIsPolling(kRenderProcessId, kStreamId, true); |
| 300 ExpectIsPolling(kAnotherRenderProcessId, kStreamId, false); | 295 ExpectIsPolling(kAnotherRenderProcessId, kStreamId, false); |
| 301 } | 296 } |
| 302 | 297 |
| 303 } // namespace content | 298 } // namespace content |
| OLD | NEW |