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 class FrameViewTestBase : public testing::Test { | 41 class FrameViewTestBase |
| 42 : public testing::Test | |
| 43 , public testing::WithParamInterface<FrameSettingOverrideFunction> { | |
| 42 protected: | 44 protected: |
| 43 FrameViewTestBase() | 45 FrameViewTestBase() |
| 44 : m_chromeClient(new MockChromeClient) | 46 : m_chromeClient(new MockChromeClient) |
| 45 { } | 47 { } |
| 46 | 48 |
| 47 ~FrameViewTestBase() | 49 ~FrameViewTestBase() |
| 48 { | 50 { |
| 49 testing::Mock::VerifyAndClearExpectations(&chromeClient()); | 51 testing::Mock::VerifyAndClearExpectations(&chromeClient()); |
| 50 } | 52 } |
| 51 | 53 |
| 52 void SetUp() override | 54 void SetUp() override |
| 53 { | 55 { |
| 54 Page::PageClients clients; | 56 Page::PageClients clients; |
| 55 fillWithEmptyClients(clients); | 57 fillWithEmptyClients(clients); |
| 56 clients.chromeClient = m_chromeClient.get(); | 58 clients.chromeClient = m_chromeClient.get(); |
| 57 m_pageHolder = DummyPageHolder::create(IntSize(800, 600), &clients); | 59 m_pageHolder = DummyPageHolder::create(IntSize(800, 600), &clients); |
| 58 m_pageHolder->page().settings().setAcceleratedCompositingEnabled(true); | 60 m_pageHolder->page().settings().setAcceleratedCompositingEnabled(true); |
| 61 if (GetParam()) | |
| 62 (*GetParam())(m_pageHolder->page().settings()); | |
| 59 } | 63 } |
| 60 | 64 |
| 61 Document& document() { return m_pageHolder->document(); } | 65 Document& document() { return m_pageHolder->document(); } |
| 62 MockChromeClient& chromeClient() { return *m_chromeClient; } | 66 MockChromeClient& chromeClient() { return *m_chromeClient; } |
| 63 | 67 |
| 64 private: | 68 private: |
| 65 Persistent<MockChromeClient> m_chromeClient; | 69 Persistent<MockChromeClient> m_chromeClient; |
| 66 std::unique_ptr<DummyPageHolder> m_pageHolder; | 70 std::unique_ptr<DummyPageHolder> m_pageHolder; |
| 67 }; | 71 }; |
| 68 | 72 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 93 | 97 |
| 94 void TearDown() override | 98 void TearDown() override |
| 95 { | 99 { |
| 96 m_featuresBackup.restore(); | 100 m_featuresBackup.restore(); |
| 97 } | 101 } |
| 98 | 102 |
| 99 private: | 103 private: |
| 100 RuntimeEnabledFeatures::Backup m_featuresBackup; | 104 RuntimeEnabledFeatures::Backup m_featuresBackup; |
| 101 }; | 105 }; |
| 102 | 106 |
| 107 INSTANTIATE_TEST_CASE_P(All, FrameViewTest, ::testing::Values( | |
| 108 nullptr, | |
| 109 &RootLayerScrollsFrameSettingOverride)); | |
| 110 | |
| 111 INSTANTIATE_TEST_CASE_P(All, FrameViewSlimmingPaintV2Test, ::testing::Values( | |
| 112 nullptr, | |
| 113 &RootLayerScrollsFrameSettingOverride)); | |
|
tdresser
2016/08/08 13:15:44
Aren't these two instantiations identical?
szager1
2016/08/08 18:12:34
No, the first one ("nullptr") will not apply any o
tdresser
2016/08/08 18:21:28
Whoops, sorry, I was forgetting how INSTANTIATE_TE
| |
| 114 | |
| 103 // These tests ensure that FrameView informs the ChromeClient of changes to the | 115 // These tests ensure that FrameView informs the ChromeClient of changes to the |
| 104 // paint artifact so that they can be shown to the user (e.g. via the | 116 // paint artifact so that they can be shown to the user (e.g. via the |
| 105 // compositor). | 117 // compositor). |
| 106 TEST_F(FrameViewSlimmingPaintV2Test, PaintOnce) | 118 TEST_P(FrameViewSlimmingPaintV2Test, PaintOnce) |
| 107 { | 119 { |
| 108 EXPECT_CALL(chromeClient(), didPaint(_)); | 120 EXPECT_CALL(chromeClient(), didPaint(_)); |
| 109 document().body()->setInnerHTML("Hello world", ASSERT_NO_EXCEPTION); | 121 document().body()->setInnerHTML("Hello world", ASSERT_NO_EXCEPTION); |
| 110 document().view()->updateAllLifecyclePhases(); | 122 document().view()->updateAllLifecyclePhases(); |
| 111 } | 123 } |
| 112 | 124 |
| 113 TEST_F(FrameViewSlimmingPaintV2Test, PaintAndRepaint) | 125 TEST_P(FrameViewSlimmingPaintV2Test, PaintAndRepaint) |
| 114 { | 126 { |
| 115 EXPECT_CALL(chromeClient(), didPaint(_)).Times(2); | 127 EXPECT_CALL(chromeClient(), didPaint(_)).Times(2); |
| 116 document().body()->setInnerHTML("Hello", ASSERT_NO_EXCEPTION); | 128 document().body()->setInnerHTML("Hello", ASSERT_NO_EXCEPTION); |
| 117 document().view()->updateAllLifecyclePhases(); | 129 document().view()->updateAllLifecyclePhases(); |
| 118 document().body()->setInnerHTML("Hello world", ASSERT_NO_EXCEPTION); | 130 document().body()->setInnerHTML("Hello world", ASSERT_NO_EXCEPTION); |
| 119 document().view()->updateAllLifecyclePhases(); | 131 document().view()->updateAllLifecyclePhases(); |
| 120 } | 132 } |
| 121 | 133 |
| 122 TEST_F(FrameViewTest, SetPaintInvalidationDuringUpdateAllLifecyclePhases) | 134 TEST_P(FrameViewTest, SetPaintInvalidationDuringUpdateAllLifecyclePhases) |
| 123 { | 135 { |
| 124 document().body()->setInnerHTML("<div id='a' style='color: blue'>A</div>", A SSERT_NO_EXCEPTION); | 136 document().body()->setInnerHTML("<div id='a' style='color: blue'>A</div>", A SSERT_NO_EXCEPTION); |
| 125 document().view()->updateAllLifecyclePhases(); | 137 document().view()->updateAllLifecyclePhases(); |
| 126 document().getElementById("a")->setAttribute(HTMLNames::styleAttr, "color: g reen"); | 138 document().getElementById("a")->setAttribute(HTMLNames::styleAttr, "color: g reen"); |
| 127 chromeClient().m_hasScheduledAnimation = false; | 139 chromeClient().m_hasScheduledAnimation = false; |
| 128 document().view()->updateAllLifecyclePhases(); | 140 document().view()->updateAllLifecyclePhases(); |
| 129 EXPECT_FALSE(chromeClient().m_hasScheduledAnimation); | 141 EXPECT_FALSE(chromeClient().m_hasScheduledAnimation); |
| 130 } | 142 } |
| 131 | 143 |
| 132 TEST_F(FrameViewTest, SetPaintInvalidationOutOfUpdateAllLifecyclePhases) | 144 TEST_P(FrameViewTest, SetPaintInvalidationOutOfUpdateAllLifecyclePhases) |
| 133 { | 145 { |
| 134 document().body()->setInnerHTML("<div id='a' style='color: blue'>A</div>", A SSERT_NO_EXCEPTION); | 146 document().body()->setInnerHTML("<div id='a' style='color: blue'>A</div>", A SSERT_NO_EXCEPTION); |
| 135 document().view()->updateAllLifecyclePhases(); | 147 document().view()->updateAllLifecyclePhases(); |
| 136 chromeClient().m_hasScheduledAnimation = false; | 148 chromeClient().m_hasScheduledAnimation = false; |
| 137 document().getElementById("a")->layoutObject()->setShouldDoFullPaintInvalida tion(); | 149 document().getElementById("a")->layoutObject()->setShouldDoFullPaintInvalida tion(); |
| 138 EXPECT_TRUE(chromeClient().m_hasScheduledAnimation); | 150 EXPECT_TRUE(chromeClient().m_hasScheduledAnimation); |
| 139 chromeClient().m_hasScheduledAnimation = false; | 151 chromeClient().m_hasScheduledAnimation = false; |
| 140 document().getElementById("a")->layoutObject()->setShouldDoFullPaintInvalida tion(); | 152 document().getElementById("a")->layoutObject()->setShouldDoFullPaintInvalida tion(); |
| 141 EXPECT_TRUE(chromeClient().m_hasScheduledAnimation); | 153 EXPECT_TRUE(chromeClient().m_hasScheduledAnimation); |
| 142 chromeClient().m_hasScheduledAnimation = false; | 154 chromeClient().m_hasScheduledAnimation = false; |
| 143 document().view()->updateAllLifecyclePhases(); | 155 document().view()->updateAllLifecyclePhases(); |
| 144 EXPECT_FALSE(chromeClient().m_hasScheduledAnimation); | 156 EXPECT_FALSE(chromeClient().m_hasScheduledAnimation); |
| 145 } | 157 } |
| 146 | 158 |
| 147 // If we don't hide the tooltip on scroll, it can negatively impact scrolling | 159 // If we don't hide the tooltip on scroll, it can negatively impact scrolling |
| 148 // performance. See crbug.com/586852 for details. | 160 // performance. See crbug.com/586852 for details. |
| 149 TEST_F(FrameViewTest, HideTooltipWhenScrollPositionChanges) | 161 TEST_P(FrameViewTest, HideTooltipWhenScrollPositionChanges) |
| 150 { | 162 { |
| 151 document().body()->setInnerHTML("<div style='width:1000px;height:1000px'></d iv>", ASSERT_NO_EXCEPTION); | 163 document().body()->setInnerHTML("<div style='width:1000px;height:1000px'></d iv>", ASSERT_NO_EXCEPTION); |
| 152 document().view()->updateAllLifecyclePhases(); | 164 document().view()->updateAllLifecyclePhases(); |
| 153 | 165 |
| 154 EXPECT_CALL(chromeClient(), setToolTip(String(), _)); | 166 EXPECT_CALL(chromeClient(), setToolTip(String(), _)); |
| 155 document().view()->setScrollPosition(DoublePoint(1, 1), UserScroll); | 167 document().view()->layoutViewportScrollableArea()->setScrollPosition(DoubleP oint(1, 1), UserScroll); |
| 156 } | 168 } |
| 157 | 169 |
| 158 } // namespace | 170 } // namespace |
| 159 } // namespace blink | 171 } // namespace blink |
| OLD | NEW |