| 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 "core/html/shadow/MediaControls.h" | 5 #include "core/html/shadow/MediaControls.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/Document.h" | 11 #include "core/dom/Document.h" |
| 12 #include "core/dom/ElementTraversal.h" | 12 #include "core/dom/ElementTraversal.h" |
| 13 #include "core/dom/StyleEngine.h" | 13 #include "core/dom/StyleEngine.h" |
| 14 #include "core/events/Event.h" |
| 14 #include "core/frame/Settings.h" | 15 #include "core/frame/Settings.h" |
| 16 #include "core/html/HTMLElement.h" |
| 15 #include "core/html/HTMLVideoElement.h" | 17 #include "core/html/HTMLVideoElement.h" |
| 16 #include "core/html/shadow/MediaControlElementTypes.h" | 18 #include "core/html/shadow/MediaControlElementTypes.h" |
| 19 #include "core/layout/LayoutObject.h" |
| 17 #include "core/loader/EmptyClients.h" | 20 #include "core/loader/EmptyClients.h" |
| 18 #include "core/testing/DummyPageHolder.h" | 21 #include "core/testing/DummyPageHolder.h" |
| 19 #include "platform/heap/Handle.h" | 22 #include "platform/heap/Handle.h" |
| 20 #include "platform/testing/EmptyWebMediaPlayer.h" | 23 #include "platform/testing/EmptyWebMediaPlayer.h" |
| 21 #include "platform/testing/HistogramTester.h" | 24 #include "platform/testing/HistogramTester.h" |
| 22 #include "platform/testing/UnitTestHelpers.h" | 25 #include "platform/testing/UnitTestHelpers.h" |
| 23 #include "public/platform/WebSize.h" | 26 #include "public/platform/WebSize.h" |
| 24 #include "public/platform/modules/remoteplayback/WebRemotePlaybackAvailability.h
" | 27 #include "public/platform/modules/remoteplayback/WebRemotePlaybackAvailability.h
" |
| 25 #include "public/platform/modules/remoteplayback/WebRemotePlaybackClient.h" | 28 #include "public/platform/modules/remoteplayback/WebRemotePlaybackClient.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 48 void promptCancelled() override {} | 51 void promptCancelled() override {} |
| 49 bool remotePlaybackAvailable() const override { | 52 bool remotePlaybackAvailable() const override { |
| 50 return m_availability == WebRemotePlaybackAvailability::DeviceAvailable; | 53 return m_availability == WebRemotePlaybackAvailability::DeviceAvailable; |
| 51 } | 54 } |
| 52 | 55 |
| 53 private: | 56 private: |
| 54 WebRemotePlaybackAvailability m_availability = | 57 WebRemotePlaybackAvailability m_availability = |
| 55 WebRemotePlaybackAvailability::Unknown; | 58 WebRemotePlaybackAvailability::Unknown; |
| 56 }; | 59 }; |
| 57 | 60 |
| 61 class MockLayoutObject : public LayoutObject { |
| 62 public: |
| 63 MockLayoutObject() : LayoutObject(nullptr) {} |
| 64 |
| 65 const char* name() const override { return "MockLayoutObject"; } |
| 66 void layout() override {} |
| 67 FloatRect localBoundingBoxRectForAccessibility() const override { |
| 68 return FloatRect(); |
| 69 } |
| 70 |
| 71 void setShouldDoFullPaintInvalidation(PaintInvalidationReason) { |
| 72 m_fullPaintInvalidationCallCount++; |
| 73 } |
| 74 |
| 75 int fullPaintInvalidationCallCount() const { |
| 76 return m_fullPaintInvalidationCallCount; |
| 77 } |
| 78 |
| 79 private: |
| 80 int m_fullPaintInvalidationCallCount = 0; |
| 81 }; |
| 82 |
| 58 class StubLocalFrameClient : public EmptyLocalFrameClient { | 83 class StubLocalFrameClient : public EmptyLocalFrameClient { |
| 59 public: | 84 public: |
| 60 static StubLocalFrameClient* create() { return new StubLocalFrameClient; } | 85 static StubLocalFrameClient* create() { return new StubLocalFrameClient; } |
| 61 | 86 |
| 62 std::unique_ptr<WebMediaPlayer> createWebMediaPlayer( | 87 std::unique_ptr<WebMediaPlayer> createWebMediaPlayer( |
| 63 HTMLMediaElement&, | 88 HTMLMediaElement&, |
| 64 const WebMediaPlayerSource&, | 89 const WebMediaPlayerSource&, |
| 65 WebMediaPlayerClient*) override { | 90 WebMediaPlayerClient*) override { |
| 66 return WTF::wrapUnique(new MockVideoWebMediaPlayer); | 91 return WTF::wrapUnique(new MockVideoWebMediaPlayer); |
| 67 } | 92 } |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 double duration = 600; | 519 double duration = 600; |
| 495 loadMediaWithDuration(duration); | 520 loadMediaWithDuration(duration); |
| 496 | 521 |
| 497 // Simulate seeking the underlying range to 50%. Current time display should | 522 // Simulate seeking the underlying range to 50%. Current time display should |
| 498 // update synchronously (rather than waiting for media to finish seeking). | 523 // update synchronously (rather than waiting for media to finish seeking). |
| 499 timeline->setValueAsNumber(duration / 2, ASSERT_NO_EXCEPTION); | 524 timeline->setValueAsNumber(duration / 2, ASSERT_NO_EXCEPTION); |
| 500 timeline->dispatchInputEvent(); | 525 timeline->dispatchInputEvent(); |
| 501 EXPECT_EQ(duration / 2, currentTimeDisplay->currentValue()); | 526 EXPECT_EQ(duration / 2, currentTimeDisplay->currentValue()); |
| 502 } | 527 } |
| 503 | 528 |
| 529 TEST_F(MediaControlsTest, VolumeSliderPaintInvalidationOnInput) { |
| 530 ensureSizing(); |
| 531 |
| 532 MediaControlVolumeSliderElement* volumeSlider = |
| 533 static_cast<MediaControlVolumeSliderElement*>(getElementByShadowPseudoId( |
| 534 mediaControls(), "-webkit-media-controls-volume-slider")); |
| 535 ASSERT_NE(nullptr, volumeSlider); |
| 536 |
| 537 HTMLElement* element = volumeSlider; |
| 538 |
| 539 MockLayoutObject layoutObject; |
| 540 LayoutObject* prevLayoutObject = volumeSlider->layoutObject(); |
| 541 volumeSlider->setLayoutObject(&layoutObject); |
| 542 |
| 543 Event* event = Event::create(EventTypeNames::input); |
| 544 element->defaultEventHandler(event); |
| 545 EXPECT_EQ(1, layoutObject.fullPaintInvalidationCallCount()); |
| 546 |
| 547 event = Event::create(EventTypeNames::input); |
| 548 element->defaultEventHandler(event); |
| 549 EXPECT_EQ(2, layoutObject.fullPaintInvalidationCallCount()); |
| 550 |
| 551 event = Event::create(EventTypeNames::input); |
| 552 element->defaultEventHandler(event); |
| 553 EXPECT_EQ(3, layoutObject.fullPaintInvalidationCallCount()); |
| 554 |
| 555 volumeSlider->setLayoutObject(prevLayoutObject); |
| 556 } |
| 557 |
| 504 } // namespace blink | 558 } // namespace blink |
| OLD | NEW |