| 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" |
| (...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 784 GetHistogramTester().ExpectTotalCount( | 784 GetHistogramTester().ExpectTotalCount( |
| 785 "Media.Timeline.DragGestureDuration.128_255", 1); | 785 "Media.Timeline.DragGestureDuration.128_255", 1); |
| 786 GetHistogramTester().ExpectUniqueSample("Media.Timeline.DragPercent.128_255", | 786 GetHistogramTester().ExpectUniqueSample("Media.Timeline.DragPercent.128_255", |
| 787 8 /* (-35.0%, -30.0%] */, 1); | 787 8 /* (-35.0%, -30.0%] */, 1); |
| 788 GetHistogramTester().ExpectUniqueSample( | 788 GetHistogramTester().ExpectUniqueSample( |
| 789 "Media.Timeline.DragSumAbsTimeDelta.128_255", 17 /* [8m, 15m) */, 1); | 789 "Media.Timeline.DragSumAbsTimeDelta.128_255", 17 /* [8m, 15m) */, 1); |
| 790 GetHistogramTester().ExpectUniqueSample( | 790 GetHistogramTester().ExpectUniqueSample( |
| 791 "Media.Timeline.DragTimeDelta.128_255", 9 /* (-4m, -2m] */, 1); | 791 "Media.Timeline.DragTimeDelta.128_255", 9 /* (-4m, -2m] */, 1); |
| 792 } | 792 } |
| 793 | 793 |
| 794 TEST_F(MediaControlsImplTest, ControlsRemainVisibleDuringKeyboardInteraction) { | 794 namespace { |
| 795 |
| 796 class MediaControlsImplTestWithMockScheduler : public MediaControlsImplTest { |
| 797 protected: |
| 798 void SetUp() override { |
| 799 // DocumentParserTiming has DCHECKS to make sure time > 0.0. |
| 800 platform_->AdvanceClockSeconds(1); |
| 801 |
| 802 MediaControlsImplTest::SetUp(); |
| 803 } |
| 804 |
| 795 ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler> | 805 ScopedTestingPlatformSupport<TestingPlatformSupportWithMockScheduler> |
| 796 platform; | 806 platform_; |
| 807 }; |
| 797 | 808 |
| 798 // DocumentParserTiming has DCHECKS to make sure time > 0.0. | 809 } // namespace |
| 799 platform->AdvanceClockSeconds(1); | |
| 800 | 810 |
| 801 // Need to reinitialize page since we changed the platform. | 811 TEST_F(MediaControlsImplTestWithMockScheduler, |
| 802 InitializePage(); | 812 ControlsRemainVisibleDuringKeyboardInteraction) { |
| 803 EnsureSizing(); | 813 EnsureSizing(); |
| 804 | 814 |
| 805 Element* panel = MediaControls().PanelElement(); | 815 Element* panel = MediaControls().PanelElement(); |
| 806 | 816 |
| 807 MediaControls().MediaElement().SetBooleanAttribute(HTMLNames::controlsAttr, | 817 MediaControls().MediaElement().SetBooleanAttribute(HTMLNames::controlsAttr, |
| 808 true); | 818 true); |
| 809 MediaControls().MediaElement().SetSrc("http://example.com"); | 819 MediaControls().MediaElement().SetSrc("http://example.com"); |
| 810 MediaControls().MediaElement().Play(); | 820 MediaControls().MediaElement().Play(); |
| 811 | 821 |
| 812 // Controls start out visible. | 822 // Controls start out visible. |
| 813 EXPECT_TRUE(IsElementVisible(*panel)); | 823 EXPECT_TRUE(IsElementVisible(*panel)); |
| 814 | 824 |
| 815 // Tabbing between controls prevents controls from hiding. | 825 // Tabbing between controls prevents controls from hiding. |
| 816 platform->RunForPeriodSeconds(2); | 826 platform_->RunForPeriodSeconds(2); |
| 817 MediaControls().DispatchEvent(Event::Create("focusin")); | 827 MediaControls().DispatchEvent(Event::Create("focusin")); |
| 818 platform->RunForPeriodSeconds(2); | 828 platform_->RunForPeriodSeconds(2); |
| 819 EXPECT_TRUE(IsElementVisible(*panel)); | 829 EXPECT_TRUE(IsElementVisible(*panel)); |
| 820 | 830 |
| 821 // Seeking on the timeline or volume bar prevents controls from hiding. | 831 // Seeking on the timeline or volume bar prevents controls from hiding. |
| 822 MediaControls().DispatchEvent(Event::Create("input")); | 832 MediaControls().DispatchEvent(Event::Create("input")); |
| 823 platform->RunForPeriodSeconds(2); | 833 platform_->RunForPeriodSeconds(2); |
| 824 EXPECT_TRUE(IsElementVisible(*panel)); | 834 EXPECT_TRUE(IsElementVisible(*panel)); |
| 825 | 835 |
| 826 // Pressing a key prevents controls from hiding. | 836 // Pressing a key prevents controls from hiding. |
| 827 MediaControls().PanelElement()->DispatchEvent(Event::Create("keypress")); | 837 MediaControls().PanelElement()->DispatchEvent(Event::Create("keypress")); |
| 828 platform->RunForPeriodSeconds(2); | 838 platform_->RunForPeriodSeconds(2); |
| 829 EXPECT_TRUE(IsElementVisible(*panel)); | 839 EXPECT_TRUE(IsElementVisible(*panel)); |
| 830 | 840 |
| 831 // Once user interaction stops, controls can hide. | 841 // Once user interaction stops, controls can hide. |
| 832 platform->RunForPeriodSeconds(2); | 842 platform_->RunForPeriodSeconds(2); |
| 833 EXPECT_FALSE(IsElementVisible(*panel)); | 843 EXPECT_FALSE(IsElementVisible(*panel)); |
| 834 } | 844 } |
| 835 | 845 |
| 836 TEST_F(MediaControlsImplTest, | 846 TEST_F(MediaControlsImplTest, |
| 837 RemovingFromDocumentRemovesListenersAndCallbacks) { | 847 RemovingFromDocumentRemovesListenersAndCallbacks) { |
| 838 auto page_holder = DummyPageHolder::Create(); | 848 auto page_holder = DummyPageHolder::Create(); |
| 839 | 849 |
| 840 HTMLMediaElement* element = | 850 HTMLMediaElement* element = |
| 841 HTMLVideoElement::Create(page_holder->GetDocument()); | 851 HTMLVideoElement::Create(page_holder->GetDocument()); |
| 842 element->SetBooleanAttribute(HTMLNames::controlsAttr, true); | 852 element->SetBooleanAttribute(HTMLNames::controlsAttr, true); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 884 { | 894 { |
| 885 Persistent<HTMLMediaElement> video_holder = element; | 895 Persistent<HTMLMediaElement> video_holder = element; |
| 886 page_holder->GetDocument().body()->RemoveChild(element); | 896 page_holder->GetDocument().body()->RemoveChild(element); |
| 887 page_holder->GetDocument().body()->AppendChild(video_holder.Get()); | 897 page_holder->GetDocument().body()->AppendChild(video_holder.Get()); |
| 888 EXPECT_TRUE(remote_playback->HasEventListeners()); | 898 EXPECT_TRUE(remote_playback->HasEventListeners()); |
| 889 EXPECT_TRUE(HasAvailabilityCallbacks(remote_playback)); | 899 EXPECT_TRUE(HasAvailabilityCallbacks(remote_playback)); |
| 890 } | 900 } |
| 891 } | 901 } |
| 892 | 902 |
| 893 } // namespace blink | 903 } // namespace blink |
| OLD | NEW |