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().network0QuietTimerFired(nullptr); | |
43 detector().network2QuietTimerFired(nullptr); | |
tdresser
2017/03/07 17:15:51
Should we have a test where we hit the two network
Kunihiko Sakamoto
2017/03/08 04:34:51
Done.
| |
44 } | |
41 | 45 |
42 private: | 46 private: |
43 static double returnMockTime() { | 47 static double returnMockTime() { |
44 s_timeElapsed += 1.0; | 48 s_timeElapsed += 1.0; |
45 return s_timeElapsed; | 49 return s_timeElapsed; |
46 } | 50 } |
47 | 51 |
48 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; | 52 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; |
49 TimeFunction m_originalTimeFunction; | 53 TimeFunction m_originalTimeFunction; |
50 static double s_timeElapsed; | 54 static double s_timeElapsed; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 FirstMeaningfulPaintShouldNotBeBeforeFirstContentfulPaint) { | 124 FirstMeaningfulPaintShouldNotBeBeforeFirstContentfulPaint) { |
121 paintTiming().markFirstPaint(); | 125 paintTiming().markFirstPaint(); |
122 simulateLayoutAndPaint(10); | 126 simulateLayoutAndPaint(10); |
123 paintTiming().markFirstContentfulPaint(); | 127 paintTiming().markFirstContentfulPaint(); |
124 simulateNetworkStable(); | 128 simulateNetworkStable(); |
125 EXPECT_GE(paintTiming().firstMeaningfulPaint(), | 129 EXPECT_GE(paintTiming().firstMeaningfulPaint(), |
126 paintTiming().firstContentfulPaint()); | 130 paintTiming().firstContentfulPaint()); |
127 } | 131 } |
128 | 132 |
129 } // namespace blink | 133 } // namespace blink |
OLD | NEW |