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

Side by Side Diff: third_party/WebKit/Source/modules/media_controls/MediaControlsImplTest.cpp

Issue 2909093002: Add MediaControlsImplTestWithMockScheduler. (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "modules/media_controls/MediaControlsImpl.h" 5 #include "modules/media_controls/MediaControlsImpl.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <memory> 8 #include <memory>
9 #include "core/HTMLNames.h" 9 #include "core/HTMLNames.h"
10 #include "core/css/StylePropertySet.h" 10 #include "core/css/StylePropertySet.h"
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 144
145 GetDocument().write("<video>"); 145 GetDocument().write("<video>");
146 HTMLVideoElement& video = 146 HTMLVideoElement& video =
147 toHTMLVideoElement(*GetDocument().QuerySelector("video")); 147 toHTMLVideoElement(*GetDocument().QuerySelector("video"));
148 media_controls_ = static_cast<MediaControlsImpl*>(video.GetMediaControls()); 148 media_controls_ = static_cast<MediaControlsImpl*>(video.GetMediaControls());
149 149
150 // If scripts are not enabled, controls will always be shown. 150 // If scripts are not enabled, controls will always be shown.
151 page_holder_->GetFrame().GetSettings()->SetScriptEnabled(true); 151 page_holder_->GetFrame().GetSettings()->SetScriptEnabled(true);
152 } 152 }
153 153
154 void ResetPage() { page_holder_.reset(); }
155
154 void SimulateRouteAvailable() { 156 void SimulateRouteAvailable() {
155 media_controls_->MediaElement().RemoteRouteAvailabilityChanged( 157 media_controls_->MediaElement().RemoteRouteAvailabilityChanged(
156 WebRemotePlaybackAvailability::kDeviceAvailable); 158 WebRemotePlaybackAvailability::kDeviceAvailable);
157 } 159 }
158 160
159 void EnsureSizing() { 161 void EnsureSizing() {
160 // Fire the size-change callback to ensure that the controls have 162 // Fire the size-change callback to ensure that the controls have
161 // been properly notified of the video size. 163 // been properly notified of the video size.
162 media_controls_->NotifyElementSizeChanged( 164 media_controls_->NotifyElementSizeChanged(
163 media_controls_->MediaElement().getBoundingClientRect()); 165 media_controls_->MediaElement().getBoundingClientRect());
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 "Media.Timeline.DragGestureDuration.128_255", 1); 787 "Media.Timeline.DragGestureDuration.128_255", 1);
786 GetHistogramTester().ExpectUniqueSample("Media.Timeline.DragPercent.128_255", 788 GetHistogramTester().ExpectUniqueSample("Media.Timeline.DragPercent.128_255",
787 8 /* (-35.0%, -30.0%] */, 1); 789 8 /* (-35.0%, -30.0%] */, 1);
788 GetHistogramTester().ExpectUniqueSample( 790 GetHistogramTester().ExpectUniqueSample(
789 "Media.Timeline.DragSumAbsTimeDelta.128_255", 17 /* [8m, 15m) */, 1); 791 "Media.Timeline.DragSumAbsTimeDelta.128_255", 17 /* [8m, 15m) */, 1);
790 GetHistogramTester().ExpectUniqueSample( 792 GetHistogramTester().ExpectUniqueSample(
791 "Media.Timeline.DragTimeDelta.128_255", 9 /* (-4m, -2m] */, 1); 793 "Media.Timeline.DragTimeDelta.128_255", 9 /* (-4m, -2m] */, 1);
792 } 794 }
793 795
794 TEST_F(MediaControlsImplTest, ControlsRemainVisibleDuringKeyboardInteraction) { 796 TEST_F(MediaControlsImplTest, ControlsRemainVisibleDuringKeyboardInteraction) {
797 ResetPage();
whywhat 2017/05/29 18:19:53 This is the line that would likely look confusing
798
795 ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler> 799 ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler>
796 platform; 800 platform;
797 801
798 // DocumentParserTiming has DCHECKS to make sure time > 0.0. 802 // DocumentParserTiming has DCHECKS to make sure time > 0.0.
799 platform->AdvanceClockSeconds(1); 803 platform->AdvanceClockSeconds(1);
800 804
801 // Need to reinitialize page since we changed the platform. 805 // Need to reinitialize page since we changed the platform.
802 InitializePage(); 806 InitializePage();
803 EnsureSizing(); 807 EnsureSizing();
804 808
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 { 888 {
885 Persistent<HTMLMediaElement> video_holder = element; 889 Persistent<HTMLMediaElement> video_holder = element;
886 page_holder->GetDocument().body()->RemoveChild(element); 890 page_holder->GetDocument().body()->RemoveChild(element);
887 page_holder->GetDocument().body()->AppendChild(video_holder.Get()); 891 page_holder->GetDocument().body()->AppendChild(video_holder.Get());
888 EXPECT_TRUE(remote_playback->HasEventListeners()); 892 EXPECT_TRUE(remote_playback->HasEventListeners());
889 EXPECT_TRUE(HasAvailabilityCallbacks(remote_playback)); 893 EXPECT_TRUE(HasAvailabilityCallbacks(remote_playback));
890 } 894 }
891 } 895 }
892 896
893 } // namespace blink 897 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698