OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/paint/FirstMeaningfulPaintDetector.h" | 5 #include "core/paint/FirstMeaningfulPaintDetector.h" |
6 | 6 |
7 #include "core/paint/PaintTiming.h" | 7 #include "core/paint/PaintTiming.h" |
8 #include "core/testing/DummyPageHolder.h" | 8 #include "core/testing/DummyPageHolder.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 void simulateLayoutAndPaint(int newElements) { | 31 void simulateLayoutAndPaint(int newElements) { |
32 StringBuilder builder; | 32 StringBuilder builder; |
33 for (int i = 0; i < newElements; i++) | 33 for (int i = 0; i < newElements; i++) |
34 builder.append("<span>a</span>"); | 34 builder.append("<span>a</span>"); |
35 document().write(builder.toString()); | 35 document().write(builder.toString()); |
36 document().updateStyleAndLayout(); | 36 document().updateStyleAndLayout(); |
37 detector().notifyPaint(); | 37 detector().notifyPaint(); |
38 } | 38 } |
39 | 39 |
40 void simulateNetworkStable() { detector().networkStableTimerFired(nullptr); } | 40 void simulateNetworkStable() { |
| 41 document().setParsingState(Document::FinishedParsing); |
| 42 detector().networkStableTimerFired(nullptr); |
| 43 } |
41 | 44 |
42 private: | 45 private: |
43 static double returnMockTime() { | 46 static double returnMockTime() { |
44 s_timeElapsed += 1.0; | 47 s_timeElapsed += 1.0; |
45 return s_timeElapsed; | 48 return s_timeElapsed; |
46 } | 49 } |
47 | 50 |
48 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; | 51 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; |
49 TimeFunction m_originalTimeFunction; | 52 TimeFunction m_originalTimeFunction; |
50 static double s_timeElapsed; | 53 static double s_timeElapsed; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 FirstMeaningfulPaintShouldNotBeBeforeFirstContentfulPaint) { | 123 FirstMeaningfulPaintShouldNotBeBeforeFirstContentfulPaint) { |
121 paintTiming().markFirstPaint(); | 124 paintTiming().markFirstPaint(); |
122 simulateLayoutAndPaint(10); | 125 simulateLayoutAndPaint(10); |
123 paintTiming().markFirstContentfulPaint(); | 126 paintTiming().markFirstContentfulPaint(); |
124 simulateNetworkStable(); | 127 simulateNetworkStable(); |
125 EXPECT_GE(paintTiming().firstMeaningfulPaint(), | 128 EXPECT_GE(paintTiming().firstMeaningfulPaint(), |
126 paintTiming().firstContentfulPaint()); | 129 paintTiming().firstContentfulPaint()); |
127 } | 130 } |
128 | 131 |
129 } // namespace blink | 132 } // namespace blink |
OLD | NEW |