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 13 matching lines...) Expand all Loading... |
24 using testing::AnyNumber; | 24 using testing::AnyNumber; |
25 | 25 |
26 namespace blink { | 26 namespace blink { |
27 namespace { | 27 namespace { |
28 | 28 |
29 class MockChromeClient : public EmptyChromeClient { | 29 class MockChromeClient : public EmptyChromeClient { |
30 public: | 30 public: |
31 MockChromeClient() : m_hasScheduledAnimation(false) { } | 31 MockChromeClient() : m_hasScheduledAnimation(false) { } |
32 | 32 |
33 // ChromeClient | 33 // ChromeClient |
34 MOCK_METHOD1(didPaint, void(const PaintArtifact&)); | |
35 MOCK_METHOD2(attachRootGraphicsLayer, void(GraphicsLayer*, LocalFrame* local
Root)); | 34 MOCK_METHOD2(attachRootGraphicsLayer, void(GraphicsLayer*, LocalFrame* local
Root)); |
36 MOCK_METHOD2(setToolTip, void(const String&, TextDirection)); | 35 MOCK_METHOD2(setToolTip, void(const String&, TextDirection)); |
37 | 36 |
38 void scheduleAnimation(Widget*) override { m_hasScheduledAnimation = true; } | 37 void scheduleAnimation(Widget*) override { m_hasScheduledAnimation = true; } |
39 bool m_hasScheduledAnimation; | 38 bool m_hasScheduledAnimation; |
40 }; | 39 }; |
41 | 40 |
42 typedef bool TestParamRootLayerScrolling; | 41 typedef bool TestParamRootLayerScrolling; |
43 class FrameViewTestBase | 42 class FrameViewTestBase |
44 : public testing::WithParamInterface<TestParamRootLayerScrolling> | 43 : public testing::WithParamInterface<TestParamRootLayerScrolling> |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 m_featuresBackup.restore(); | 100 m_featuresBackup.restore(); |
102 } | 101 } |
103 | 102 |
104 private: | 103 private: |
105 RuntimeEnabledFeatures::Backup m_featuresBackup; | 104 RuntimeEnabledFeatures::Backup m_featuresBackup; |
106 }; | 105 }; |
107 | 106 |
108 INSTANTIATE_TEST_CASE_P(All, FrameViewTest, ::testing::Bool()); | 107 INSTANTIATE_TEST_CASE_P(All, FrameViewTest, ::testing::Bool()); |
109 INSTANTIATE_TEST_CASE_P(All, FrameViewSlimmingPaintV2Test, ::testing::Bool()); | 108 INSTANTIATE_TEST_CASE_P(All, FrameViewSlimmingPaintV2Test, ::testing::Bool()); |
110 | 109 |
111 // These tests ensure that FrameView informs the ChromeClient of changes to the | |
112 // paint artifact so that they can be shown to the user (e.g. via the | |
113 // compositor). | |
114 TEST_P(FrameViewSlimmingPaintV2Test, PaintOnce) | |
115 { | |
116 EXPECT_CALL(chromeClient(), didPaint(_)); | |
117 document().body()->setInnerHTML("Hello world", ASSERT_NO_EXCEPTION); | |
118 document().view()->updateAllLifecyclePhases(); | |
119 } | |
120 | |
121 TEST_P(FrameViewSlimmingPaintV2Test, PaintAndRepaint) | |
122 { | |
123 EXPECT_CALL(chromeClient(), didPaint(_)).Times(2); | |
124 document().body()->setInnerHTML("Hello", ASSERT_NO_EXCEPTION); | |
125 document().view()->updateAllLifecyclePhases(); | |
126 document().body()->setInnerHTML("Hello world", ASSERT_NO_EXCEPTION); | |
127 document().view()->updateAllLifecyclePhases(); | |
128 } | |
129 | |
130 TEST_P(FrameViewTest, SetPaintInvalidationDuringUpdateAllLifecyclePhases) | 110 TEST_P(FrameViewTest, SetPaintInvalidationDuringUpdateAllLifecyclePhases) |
131 { | 111 { |
132 document().body()->setInnerHTML("<div id='a' style='color: blue'>A</div>", A
SSERT_NO_EXCEPTION); | 112 document().body()->setInnerHTML("<div id='a' style='color: blue'>A</div>", A
SSERT_NO_EXCEPTION); |
133 document().view()->updateAllLifecyclePhases(); | 113 document().view()->updateAllLifecyclePhases(); |
134 document().getElementById("a")->setAttribute(HTMLNames::styleAttr, "color: g
reen"); | 114 document().getElementById("a")->setAttribute(HTMLNames::styleAttr, "color: g
reen"); |
135 chromeClient().m_hasScheduledAnimation = false; | 115 chromeClient().m_hasScheduledAnimation = false; |
136 document().view()->updateAllLifecyclePhases(); | 116 document().view()->updateAllLifecyclePhases(); |
137 EXPECT_FALSE(chromeClient().m_hasScheduledAnimation); | 117 EXPECT_FALSE(chromeClient().m_hasScheduledAnimation); |
138 } | 118 } |
139 | 119 |
(...skipping 18 matching lines...) Expand all Loading... |
158 { | 138 { |
159 document().body()->setInnerHTML("<div style='width:1000px;height:1000px'></d
iv>", ASSERT_NO_EXCEPTION); | 139 document().body()->setInnerHTML("<div style='width:1000px;height:1000px'></d
iv>", ASSERT_NO_EXCEPTION); |
160 document().view()->updateAllLifecyclePhases(); | 140 document().view()->updateAllLifecyclePhases(); |
161 | 141 |
162 EXPECT_CALL(chromeClient(), setToolTip(String(), _)); | 142 EXPECT_CALL(chromeClient(), setToolTip(String(), _)); |
163 document().view()->layoutViewportScrollableArea()->setScrollPosition(DoubleP
oint(1, 1), UserScroll); | 143 document().view()->layoutViewportScrollableArea()->setScrollPosition(DoubleP
oint(1, 1), UserScroll); |
164 } | 144 } |
165 | 145 |
166 } // namespace | 146 } // namespace |
167 } // namespace blink | 147 } // namespace blink |
OLD | NEW |