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