| 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/frame/FrameView.h" | 5 #include "core/frame/FrameView.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/ExceptionStatePlaceholder.h" | 7 #include "bindings/core/v8/ExceptionStatePlaceholder.h" |
| 8 #include "core/frame/Settings.h" | 8 #include "core/frame/Settings.h" |
| 9 #include "core/html/HTMLElement.h" | 9 #include "core/html/HTMLElement.h" |
| 10 #include "core/layout/LayoutObject.h" | 10 #include "core/layout/LayoutObject.h" |
| 11 #include "core/loader/EmptyClients.h" | 11 #include "core/loader/EmptyClients.h" |
| 12 #include "core/page/Page.h" | 12 #include "core/page/Page.h" |
| 13 #include "core/testing/DummyPageHolder.h" | 13 #include "core/testing/DummyPageHolder.h" |
| 14 #include "platform/RuntimeEnabledFeatures.h" | 14 #include "platform/RuntimeEnabledFeatures.h" |
| 15 #include "platform/geometry/IntSize.h" | 15 #include "platform/geometry/IntSize.h" |
| 16 #include "platform/graphics/paint/PaintArtifact.h" | 16 #include "platform/graphics/paint/PaintArtifact.h" |
| 17 #include "platform/heap/Handle.h" | 17 #include "platform/heap/Handle.h" |
| 18 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h" |
| 18 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #include <memory> | 21 #include <memory> |
| 21 | 22 |
| 22 using testing::_; | 23 using testing::_; |
| 23 using testing::AnyNumber; | 24 using testing::AnyNumber; |
| 24 | 25 |
| 25 namespace blink { | 26 namespace blink { |
| 26 namespace { | 27 namespace { |
| 27 | 28 |
| 28 class MockChromeClient : public EmptyChromeClient { | 29 class MockChromeClient : public EmptyChromeClient { |
| 29 public: | 30 public: |
| 30 MockChromeClient() : m_hasScheduledAnimation(false) { } | 31 MockChromeClient() : m_hasScheduledAnimation(false) { } |
| 31 | 32 |
| 32 // ChromeClient | 33 // ChromeClient |
| 33 MOCK_METHOD1(didPaint, void(const PaintArtifact&)); | 34 MOCK_METHOD1(didPaint, void(const PaintArtifact&)); |
| 34 MOCK_METHOD2(attachRootGraphicsLayer, void(GraphicsLayer*, LocalFrame* local
Root)); | 35 MOCK_METHOD2(attachRootGraphicsLayer, void(GraphicsLayer*, LocalFrame* local
Root)); |
| 35 MOCK_METHOD2(setToolTip, void(const String&, TextDirection)); | 36 MOCK_METHOD2(setToolTip, void(const String&, TextDirection)); |
| 36 | 37 |
| 37 void scheduleAnimation(Widget*) override { m_hasScheduledAnimation = true; } | 38 void scheduleAnimation(Widget*) override { m_hasScheduledAnimation = true; } |
| 38 bool m_hasScheduledAnimation; | 39 bool m_hasScheduledAnimation; |
| 39 }; | 40 }; |
| 40 | 41 |
| 42 typedef bool TestParamRootLayerScrolling; |
| 41 class FrameViewTestBase | 43 class FrameViewTestBase |
| 42 : public testing::Test | 44 : public testing::WithParamInterface<TestParamRootLayerScrolling> |
| 43 , public testing::WithParamInterface<FrameSettingOverrideFunction> { | 45 , private ScopedRootLayerScrollingForTest |
| 46 , public testing::Test { |
| 44 protected: | 47 protected: |
| 45 FrameViewTestBase() | 48 FrameViewTestBase() |
| 46 : m_chromeClient(new MockChromeClient) | 49 : ScopedRootLayerScrollingForTest(GetParam()) |
| 47 { } | 50 , m_chromeClient(new MockChromeClient) { } |
| 48 | 51 |
| 49 ~FrameViewTestBase() | 52 ~FrameViewTestBase() |
| 50 { | 53 { |
| 51 testing::Mock::VerifyAndClearExpectations(&chromeClient()); | 54 testing::Mock::VerifyAndClearExpectations(&chromeClient()); |
| 52 } | 55 } |
| 53 | 56 |
| 54 void SetUp() override | 57 void SetUp() override |
| 55 { | 58 { |
| 56 Page::PageClients clients; | 59 Page::PageClients clients; |
| 57 fillWithEmptyClients(clients); | 60 fillWithEmptyClients(clients); |
| 58 clients.chromeClient = m_chromeClient.get(); | 61 clients.chromeClient = m_chromeClient.get(); |
| 59 m_pageHolder = DummyPageHolder::create(IntSize(800, 600), &clients); | 62 m_pageHolder = DummyPageHolder::create(IntSize(800, 600), &clients); |
| 60 m_pageHolder->page().settings().setAcceleratedCompositingEnabled(true); | 63 m_pageHolder->page().settings().setAcceleratedCompositingEnabled(true); |
| 61 if (GetParam()) | |
| 62 (*GetParam())(m_pageHolder->page().settings()); | |
| 63 } | 64 } |
| 64 | 65 |
| 65 Document& document() { return m_pageHolder->document(); } | 66 Document& document() { return m_pageHolder->document(); } |
| 66 MockChromeClient& chromeClient() { return *m_chromeClient; } | 67 MockChromeClient& chromeClient() { return *m_chromeClient; } |
| 67 | 68 |
| 68 private: | 69 private: |
| 69 Persistent<MockChromeClient> m_chromeClient; | 70 Persistent<MockChromeClient> m_chromeClient; |
| 70 std::unique_ptr<DummyPageHolder> m_pageHolder; | 71 std::unique_ptr<DummyPageHolder> m_pageHolder; |
| 71 }; | 72 }; |
| 72 | 73 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 97 | 98 |
| 98 void TearDown() override | 99 void TearDown() override |
| 99 { | 100 { |
| 100 m_featuresBackup.restore(); | 101 m_featuresBackup.restore(); |
| 101 } | 102 } |
| 102 | 103 |
| 103 private: | 104 private: |
| 104 RuntimeEnabledFeatures::Backup m_featuresBackup; | 105 RuntimeEnabledFeatures::Backup m_featuresBackup; |
| 105 }; | 106 }; |
| 106 | 107 |
| 107 INSTANTIATE_TEST_CASE_P(All, FrameViewTest, ::testing::Values( | 108 INSTANTIATE_TEST_CASE_P(All, FrameViewTest, ::testing::Bool()); |
| 108 nullptr, | 109 INSTANTIATE_TEST_CASE_P(All, FrameViewSlimmingPaintV2Test, ::testing::Bool()); |
| 109 &RootLayerScrollsFrameSettingOverride)); | |
| 110 | |
| 111 INSTANTIATE_TEST_CASE_P(All, FrameViewSlimmingPaintV2Test, ::testing::Values( | |
| 112 nullptr, | |
| 113 &RootLayerScrollsFrameSettingOverride)); | |
| 114 | 110 |
| 115 // These tests ensure that FrameView informs the ChromeClient of changes to the | 111 // These tests ensure that FrameView informs the ChromeClient of changes to the |
| 116 // paint artifact so that they can be shown to the user (e.g. via the | 112 // paint artifact so that they can be shown to the user (e.g. via the |
| 117 // compositor). | 113 // compositor). |
| 118 TEST_P(FrameViewSlimmingPaintV2Test, PaintOnce) | 114 TEST_P(FrameViewSlimmingPaintV2Test, PaintOnce) |
| 119 { | 115 { |
| 120 EXPECT_CALL(chromeClient(), didPaint(_)); | 116 EXPECT_CALL(chromeClient(), didPaint(_)); |
| 121 document().body()->setInnerHTML("Hello world", ASSERT_NO_EXCEPTION); | 117 document().body()->setInnerHTML("Hello world", ASSERT_NO_EXCEPTION); |
| 122 document().view()->updateAllLifecyclePhases(); | 118 document().view()->updateAllLifecyclePhases(); |
| 123 } | 119 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 { | 158 { |
| 163 document().body()->setInnerHTML("<div style='width:1000px;height:1000px'></d
iv>", ASSERT_NO_EXCEPTION); | 159 document().body()->setInnerHTML("<div style='width:1000px;height:1000px'></d
iv>", ASSERT_NO_EXCEPTION); |
| 164 document().view()->updateAllLifecyclePhases(); | 160 document().view()->updateAllLifecyclePhases(); |
| 165 | 161 |
| 166 EXPECT_CALL(chromeClient(), setToolTip(String(), _)); | 162 EXPECT_CALL(chromeClient(), setToolTip(String(), _)); |
| 167 document().view()->layoutViewportScrollableArea()->setScrollPosition(DoubleP
oint(1, 1), UserScroll); | 163 document().view()->layoutViewportScrollableArea()->setScrollPosition(DoubleP
oint(1, 1), UserScroll); |
| 168 } | 164 } |
| 169 | 165 |
| 170 } // namespace | 166 } // namespace |
| 171 } // namespace blink | 167 } // namespace blink |
| OLD | NEW |