Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(474)

Side by Side Diff: content/browser/media/audio_stream_monitor_unittest.cc

Issue 896673003: Propagate audible state from player to the containing tab (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments by Daniel and Min Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // Start |clock_| at non-zero. 45 // Start |clock_| at non-zero.
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 monitor_ = web_contents->audio_stream_monitor(); 55
56 web_contents->SetAudioStateProviderForTesting(
Tima Vaisburd 2015/03/02 18:37:30 Is it better to keep this test on Android (and add
57 new AudioStreamMonitor(web_contents));
58
59 monitor_ = static_cast<AudioStreamMonitor*>(
60 web_contents->audio_state_provider());
61
62 ASSERT_TRUE(monitor_);
63
56 const_cast<base::TickClock*&>(monitor_->clock_) = &clock_; 64 const_cast<base::TickClock*&>(monitor_->clock_) = &clock_;
57 } 65 }
58 66
59 base::TimeTicks GetTestClockTime() { return clock_.NowTicks(); } 67 base::TimeTicks GetTestClockTime() { return clock_.NowTicks(); }
60 68
61 void AdvanceClock(const base::TimeDelta& delta) { clock_.Advance(delta); } 69 void AdvanceClock(const base::TimeDelta& delta) { clock_.Advance(delta); }
62 70
63 AudioStreamMonitor::ReadPowerAndClipCallback CreatePollCallback( 71 AudioStreamMonitor::ReadPowerAndClipCallback CreatePollCallback(
64 int stream_id) { 72 int stream_id) {
65 return base::Bind( 73 return base::Bind(
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 StartMonitoring( 296 StartMonitoring(
289 kAnotherRenderProcessId, kStreamId, CreatePollCallback(kStreamId)); 297 kAnotherRenderProcessId, kStreamId, CreatePollCallback(kStreamId));
290 ExpectIsPolling(kRenderProcessId, kStreamId, true); 298 ExpectIsPolling(kRenderProcessId, kStreamId, true);
291 ExpectIsPolling(kAnotherRenderProcessId, kStreamId, true); 299 ExpectIsPolling(kAnotherRenderProcessId, kStreamId, true);
292 StopMonitoring(kAnotherRenderProcessId, kStreamId); 300 StopMonitoring(kAnotherRenderProcessId, kStreamId);
293 ExpectIsPolling(kRenderProcessId, kStreamId, true); 301 ExpectIsPolling(kRenderProcessId, kStreamId, true);
294 ExpectIsPolling(kAnotherRenderProcessId, kStreamId, false); 302 ExpectIsPolling(kAnotherRenderProcessId, kStreamId, false);
295 } 303 }
296 304
297 } // namespace content 305 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698