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/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" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 | 31 |
| 32 // ChromeClient | 32 // ChromeClient |
| 33 MOCK_METHOD1(didPaint, void(const PaintArtifact&)); | 33 MOCK_METHOD1(didPaint, void(const PaintArtifact&)); |
| 34 MOCK_METHOD2(attachRootGraphicsLayer, void(GraphicsLayer*, LocalFrame* local Root)); | 34 MOCK_METHOD2(attachRootGraphicsLayer, void(GraphicsLayer*, LocalFrame* local Root)); |
| 35 MOCK_METHOD2(setToolTip, void(const String&, TextDirection)); | 35 MOCK_METHOD2(setToolTip, void(const String&, TextDirection)); |
| 36 | 36 |
| 37 void scheduleAnimation(Widget*) override { m_hasScheduledAnimation = true; } | 37 void scheduleAnimation(Widget*) override { m_hasScheduledAnimation = true; } |
| 38 bool m_hasScheduledAnimation; | 38 bool m_hasScheduledAnimation; |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 typedef bool TestParamRootLayerScrolling; | |
| 41 class FrameViewTestBase | 42 class FrameViewTestBase |
| 42 : public testing::Test | 43 : public testing::Test |
| 43 , public testing::WithParamInterface<FrameSettingOverrideFunction> { | 44 , public testing::WithParamInterface<TestParamRootLayerScrolling> { |
| 44 protected: | 45 protected: |
| 45 FrameViewTestBase() | 46 FrameViewTestBase() |
| 46 : m_chromeClient(new MockChromeClient) | 47 : m_chromeClient(new MockChromeClient) |
| 47 { } | 48 , m_originalRootLayerScrollingEnabled(RuntimeEnabledFeatures::rootLayerS crollingEnabled()) |
| 49 , m_enableRootLayerScrolling(GetParam()) | |
| 50 { | |
| 51 RuntimeEnabledFeatures::setRootLayerScrollingEnabled(m_enableRootLayerSc rolling); | |
| 52 } | |
| 48 | 53 |
| 49 ~FrameViewTestBase() | 54 ~FrameViewTestBase() |
| 50 { | 55 { |
| 51 testing::Mock::VerifyAndClearExpectations(&chromeClient()); | 56 testing::Mock::VerifyAndClearExpectations(&chromeClient()); |
| 57 CHECK_EQ(m_enableRootLayerScrolling, RuntimeEnabledFeatures::rootLayerSc rollingEnabled()); | |
| 58 RuntimeEnabledFeatures::setRootLayerScrollingEnabled(m_originalRootLayer ScrollingEnabled); | |
| 52 } | 59 } |
| 53 | 60 |
| 54 void SetUp() override | 61 void SetUp() override |
| 55 { | 62 { |
| 56 Page::PageClients clients; | 63 Page::PageClients clients; |
| 57 fillWithEmptyClients(clients); | 64 fillWithEmptyClients(clients); |
| 58 clients.chromeClient = m_chromeClient.get(); | 65 clients.chromeClient = m_chromeClient.get(); |
| 59 m_pageHolder = DummyPageHolder::create(IntSize(800, 600), &clients); | 66 m_pageHolder = DummyPageHolder::create(IntSize(800, 600), &clients); |
| 60 m_pageHolder->page().settings().setAcceleratedCompositingEnabled(true); | 67 m_pageHolder->page().settings().setAcceleratedCompositingEnabled(true); |
| 61 if (GetParam()) | 68 } |
| 62 (*GetParam())(m_pageHolder->page().settings()); | 69 |
| 70 void TearDown() override | |
| 71 { | |
| 72 RuntimeEnabledFeatures::setRootLayerScrollingEnabled(GetParam()); | |
|
skobes
2016/08/21 14:21:21
Why is this in TearDown?
trchen
2016/08/24 01:01:55
Whoops, probably a mis-paste. Deleted.
| |
| 63 } | 73 } |
| 64 | 74 |
| 65 Document& document() { return m_pageHolder->document(); } | 75 Document& document() { return m_pageHolder->document(); } |
| 66 MockChromeClient& chromeClient() { return *m_chromeClient; } | 76 MockChromeClient& chromeClient() { return *m_chromeClient; } |
| 67 | 77 |
| 68 private: | 78 private: |
| 69 Persistent<MockChromeClient> m_chromeClient; | 79 Persistent<MockChromeClient> m_chromeClient; |
| 70 std::unique_ptr<DummyPageHolder> m_pageHolder; | 80 std::unique_ptr<DummyPageHolder> m_pageHolder; |
| 81 bool m_originalRootLayerScrollingEnabled; | |
| 82 bool m_enableRootLayerScrolling; | |
| 71 }; | 83 }; |
| 72 | 84 |
| 73 class FrameViewTest : public FrameViewTestBase { | 85 class FrameViewTest : public FrameViewTestBase { |
| 74 protected: | 86 protected: |
| 75 FrameViewTest() | 87 FrameViewTest() |
| 76 { | 88 { |
| 77 EXPECT_CALL(chromeClient(), attachRootGraphicsLayer(_, _)).Times(AnyNumb er()); | 89 EXPECT_CALL(chromeClient(), attachRootGraphicsLayer(_, _)).Times(AnyNumb er()); |
| 78 } | 90 } |
| 79 }; | 91 }; |
| 80 | 92 |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 97 | 109 |
| 98 void TearDown() override | 110 void TearDown() override |
| 99 { | 111 { |
| 100 m_featuresBackup.restore(); | 112 m_featuresBackup.restore(); |
| 101 } | 113 } |
| 102 | 114 |
| 103 private: | 115 private: |
| 104 RuntimeEnabledFeatures::Backup m_featuresBackup; | 116 RuntimeEnabledFeatures::Backup m_featuresBackup; |
| 105 }; | 117 }; |
| 106 | 118 |
| 107 INSTANTIATE_TEST_CASE_P(All, FrameViewTest, ::testing::Values( | 119 INSTANTIATE_TEST_CASE_P(All, FrameViewTest, ::testing::Bool()); |
| 108 nullptr, | 120 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 | 121 |
| 115 // These tests ensure that FrameView informs the ChromeClient of changes to the | 122 // 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 | 123 // paint artifact so that they can be shown to the user (e.g. via the |
| 117 // compositor). | 124 // compositor). |
| 118 TEST_P(FrameViewSlimmingPaintV2Test, PaintOnce) | 125 TEST_P(FrameViewSlimmingPaintV2Test, PaintOnce) |
| 119 { | 126 { |
| 120 EXPECT_CALL(chromeClient(), didPaint(_)); | 127 EXPECT_CALL(chromeClient(), didPaint(_)); |
| 121 document().body()->setInnerHTML("Hello world", ASSERT_NO_EXCEPTION); | 128 document().body()->setInnerHTML("Hello world", ASSERT_NO_EXCEPTION); |
| 122 document().view()->updateAllLifecyclePhases(); | 129 document().view()->updateAllLifecyclePhases(); |
| 123 } | 130 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 { | 169 { |
| 163 document().body()->setInnerHTML("<div style='width:1000px;height:1000px'></d iv>", ASSERT_NO_EXCEPTION); | 170 document().body()->setInnerHTML("<div style='width:1000px;height:1000px'></d iv>", ASSERT_NO_EXCEPTION); |
| 164 document().view()->updateAllLifecyclePhases(); | 171 document().view()->updateAllLifecyclePhases(); |
| 165 | 172 |
| 166 EXPECT_CALL(chromeClient(), setToolTip(String(), _)); | 173 EXPECT_CALL(chromeClient(), setToolTip(String(), _)); |
| 167 document().view()->layoutViewportScrollableArea()->setScrollPosition(DoubleP oint(1, 1), UserScroll); | 174 document().view()->layoutViewportScrollableArea()->setScrollPosition(DoubleP oint(1, 1), UserScroll); |
| 168 } | 175 } |
| 169 | 176 |
| 170 } // namespace | 177 } // namespace |
| 171 } // namespace blink | 178 } // namespace blink |
| OLD | NEW |