| OLD | NEW |
| 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" |
| 11 #include "core/dom/ClientRect.h" | 11 #include "core/dom/ClientRect.h" |
| 12 #include "core/dom/Document.h" | 12 #include "core/dom/Document.h" |
| 13 #include "core/dom/ElementTraversal.h" | 13 #include "core/dom/ElementTraversal.h" |
| 14 #include "core/dom/StyleEngine.h" | 14 #include "core/dom/StyleEngine.h" |
| 15 #include "core/events/Event.h" | 15 #include "core/events/Event.h" |
| 16 #include "core/frame/Settings.h" | 16 #include "core/frame/Settings.h" |
| 17 #include "core/html/HTMLElement.h" | 17 #include "core/html/HTMLElement.h" |
| 18 #include "core/html/HTMLVideoElement.h" | 18 #include "core/html/HTMLVideoElement.h" |
| 19 #include "core/html/shadow/MediaControlElementTypes.h" | 19 #include "core/html/shadow/MediaControlElementTypes.h" |
| 20 #include "core/input/EventHandler.h" | 20 #include "core/input/EventHandler.h" |
| 21 #include "core/layout/LayoutObject.h" | 21 #include "core/layout/LayoutObject.h" |
| 22 #include "core/loader/EmptyClients.h" | 22 #include "core/loader/EmptyClients.h" |
| 23 #include "core/testing/DummyPageHolder.h" | 23 #include "core/testing/DummyPageHolder.h" |
| 24 #include "modules/media_controls/elements/MediaControlCurrentTimeDisplayElement.
h" |
| 24 #include "platform/heap/Handle.h" | 25 #include "platform/heap/Handle.h" |
| 25 #include "platform/testing/EmptyWebMediaPlayer.h" | 26 #include "platform/testing/EmptyWebMediaPlayer.h" |
| 26 #include "platform/testing/HistogramTester.h" | 27 #include "platform/testing/HistogramTester.h" |
| 27 #include "platform/testing/TestingPlatformSupport.h" | 28 #include "platform/testing/TestingPlatformSupport.h" |
| 28 #include "platform/testing/UnitTestHelpers.h" | 29 #include "platform/testing/UnitTestHelpers.h" |
| 29 #include "public/platform/WebMouseEvent.h" | 30 #include "public/platform/WebMouseEvent.h" |
| 30 #include "public/platform/WebScreenInfo.h" | 31 #include "public/platform/WebScreenInfo.h" |
| 31 #include "public/platform/WebSize.h" | 32 #include "public/platform/WebSize.h" |
| 32 #include "public/platform/modules/remoteplayback/WebRemotePlaybackAvailability.h
" | 33 #include "public/platform/modules/remoteplayback/WebRemotePlaybackAvailability.h
" |
| 33 #include "public/platform/modules/remoteplayback/WebRemotePlaybackClient.h" | 34 #include "public/platform/modules/remoteplayback/WebRemotePlaybackClient.h" |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 | 199 |
| 199 void SimulateLoadedMetadata() { media_controls_->OnLoadedMetadata(); } | 200 void SimulateLoadedMetadata() { media_controls_->OnLoadedMetadata(); } |
| 200 | 201 |
| 201 MediaControlsImpl& MediaControls() { return *media_controls_; } | 202 MediaControlsImpl& MediaControls() { return *media_controls_; } |
| 202 MediaControlVolumeSliderElement* VolumeSliderElement() const { | 203 MediaControlVolumeSliderElement* VolumeSliderElement() const { |
| 203 return media_controls_->volume_slider_; | 204 return media_controls_->volume_slider_; |
| 204 } | 205 } |
| 205 MediaControlTimelineElement* TimelineElement() const { | 206 MediaControlTimelineElement* TimelineElement() const { |
| 206 return media_controls_->timeline_; | 207 return media_controls_->timeline_; |
| 207 } | 208 } |
| 209 MediaControlCurrentTimeDisplayElement* GetCurrentTimeDisplayElement() const { |
| 210 return media_controls_->current_time_display_; |
| 211 } |
| 208 MockVideoWebMediaPlayer* WebMediaPlayer() { | 212 MockVideoWebMediaPlayer* WebMediaPlayer() { |
| 209 return static_cast<MockVideoWebMediaPlayer*>( | 213 return static_cast<MockVideoWebMediaPlayer*>( |
| 210 MediaControls().MediaElement().GetWebMediaPlayer()); | 214 MediaControls().MediaElement().GetWebMediaPlayer()); |
| 211 } | 215 } |
| 212 Document& GetDocument() { return page_holder_->GetDocument(); } | 216 Document& GetDocument() { return page_holder_->GetDocument(); } |
| 213 | 217 |
| 214 HistogramTester& GetHistogramTester() { return histogram_tester_; } | 218 HistogramTester& GetHistogramTester() { return histogram_tester_; } |
| 215 | 219 |
| 216 void LoadMediaWithDuration(double duration) { | 220 void LoadMediaWithDuration(double duration) { |
| 217 MediaControls().MediaElement().SetSrc("https://example.com/foo.mp4"); | 221 MediaControls().MediaElement().SetSrc("https://example.com/foo.mp4"); |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 ASSERT_EQ(rounded_up_duration, timeline->valueAsNumber()); | 567 ASSERT_EQ(rounded_up_duration, timeline->valueAsNumber()); |
| 564 EXPECT_EQ(0.0, MediaControls().MediaElement().currentTime()); | 568 EXPECT_EQ(0.0, MediaControls().MediaElement().currentTime()); |
| 565 timeline->DispatchInputEvent(); | 569 timeline->DispatchInputEvent(); |
| 566 EXPECT_EQ(exact_duration, MediaControls().MediaElement().currentTime()); | 570 EXPECT_EQ(exact_duration, MediaControls().MediaElement().currentTime()); |
| 567 } | 571 } |
| 568 | 572 |
| 569 TEST_F(MediaControlsImplTest, TimelineImmediatelyUpdatesCurrentTime) { | 573 TEST_F(MediaControlsImplTest, TimelineImmediatelyUpdatesCurrentTime) { |
| 570 EnsureSizing(); | 574 EnsureSizing(); |
| 571 | 575 |
| 572 MediaControlCurrentTimeDisplayElement* current_time_display = | 576 MediaControlCurrentTimeDisplayElement* current_time_display = |
| 573 static_cast<MediaControlCurrentTimeDisplayElement*>( | 577 GetCurrentTimeDisplayElement(); |
| 574 GetElementByShadowPseudoId( | |
| 575 MediaControls(), "-webkit-media-controls-current-time-display")); | |
| 576 | |
| 577 double duration = 600; | 578 double duration = 600; |
| 578 LoadMediaWithDuration(duration); | 579 LoadMediaWithDuration(duration); |
| 579 | 580 |
| 580 // Simulate seeking the underlying range to 50%. Current time display should | 581 // Simulate seeking the underlying range to 50%. Current time display should |
| 581 // update synchronously (rather than waiting for media to finish seeking). | 582 // update synchronously (rather than waiting for media to finish seeking). |
| 582 TimelineElement()->setValueAsNumber(duration / 2, ASSERT_NO_EXCEPTION); | 583 TimelineElement()->setValueAsNumber(duration / 2, ASSERT_NO_EXCEPTION); |
| 583 TimelineElement()->DispatchInputEvent(); | 584 TimelineElement()->DispatchInputEvent(); |
| 584 EXPECT_EQ(duration / 2, current_time_display->CurrentValue()); | 585 EXPECT_EQ(duration / 2, current_time_display->CurrentValue()); |
| 585 } | 586 } |
| 586 | 587 |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 842 MediaControls().PanelElement()->DispatchEvent(Event::Create("keypress")); | 843 MediaControls().PanelElement()->DispatchEvent(Event::Create("keypress")); |
| 843 platform->RunForPeriodSeconds(2); | 844 platform->RunForPeriodSeconds(2); |
| 844 EXPECT_TRUE(IsElementVisible(*panel)); | 845 EXPECT_TRUE(IsElementVisible(*panel)); |
| 845 | 846 |
| 846 // Once user interaction stops, controls can hide. | 847 // Once user interaction stops, controls can hide. |
| 847 platform->RunForPeriodSeconds(2); | 848 platform->RunForPeriodSeconds(2); |
| 848 EXPECT_FALSE(IsElementVisible(*panel)); | 849 EXPECT_FALSE(IsElementVisible(*panel)); |
| 849 } | 850 } |
| 850 | 851 |
| 851 } // namespace blink | 852 } // namespace blink |
| OLD | NEW |