Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: third_party/WebKit/Source/core/paint/FirstMeaningfulPaintDetectorTest.cpp

Issue 2738813003: Ensure the scheduler always changes from UseCase LOADING to NONE. (Closed)
Patch Set: Update FMPD to use the provisional time rather than the current time. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "wtf/text/StringBuilder.h" 10 #include "wtf/text/StringBuilder.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 simulateLayoutAndPaint(10); 100 simulateLayoutAndPaint(10);
101 // The second candidate gets reported. 101 // The second candidate gets reported.
102 EXPECT_GT(paintTiming().firstMeaningfulPaintCandidate(), afterPaint); 102 EXPECT_GT(paintTiming().firstMeaningfulPaintCandidate(), afterPaint);
103 double candidate = paintTiming().firstMeaningfulPaintCandidate(); 103 double candidate = paintTiming().firstMeaningfulPaintCandidate();
104 // The third candidate gets ignored since we already saw the first candidate. 104 // The third candidate gets ignored since we already saw the first candidate.
105 simulateLayoutAndPaint(10); 105 simulateLayoutAndPaint(10);
106 EXPECT_EQ(paintTiming().firstMeaningfulPaintCandidate(), candidate); 106 EXPECT_EQ(paintTiming().firstMeaningfulPaintCandidate(), candidate);
107 } 107 }
108 108
109 TEST_F(FirstMeaningfulPaintDetectorTest, 109 TEST_F(FirstMeaningfulPaintDetectorTest,
110 OnlyOneFirstMeaningfulPaintCandidateBeforeNetworkStable) {
111 paintTiming().markFirstContentfulPaint();
112 EXPECT_EQ(paintTiming().firstMeaningfulPaintCandidate(), 0.0);
113 double beforePaint = monotonicallyIncreasingTime();
114 simulateLayoutAndPaint(1);
115 // The first candidate is initially ignored.
116 EXPECT_EQ(paintTiming().firstMeaningfulPaintCandidate(), 0.0);
117 simulateNetworkStable();
118 // The networkStable then promotes the first candidate.
119 EXPECT_GT(paintTiming().firstMeaningfulPaintCandidate(), beforePaint);
120 double candidate = paintTiming().firstMeaningfulPaintCandidate();
121 // The second candidate is then ignored.
122 // candidate.
Kunihiko Sakamoto 2017/03/15 01:59:19 Remove this line
Dan Elphick 2017/03/15 09:25:07 Done.
123 simulateLayoutAndPaint(10);
124 EXPECT_EQ(paintTiming().firstMeaningfulPaintCandidate(), candidate);
125 }
126
127 TEST_F(FirstMeaningfulPaintDetectorTest,
110 NetworkStableBeforeFirstContentfulPaint) { 128 NetworkStableBeforeFirstContentfulPaint) {
111 paintTiming().markFirstPaint(); 129 paintTiming().markFirstPaint();
112 simulateLayoutAndPaint(1); 130 simulateLayoutAndPaint(1);
113 simulateNetworkStable(); 131 simulateNetworkStable();
114 EXPECT_EQ(paintTiming().firstMeaningfulPaint(), 0.0); 132 EXPECT_EQ(paintTiming().firstMeaningfulPaint(), 0.0);
115 paintTiming().markFirstContentfulPaint(); 133 paintTiming().markFirstContentfulPaint();
116 simulateNetworkStable(); 134 simulateNetworkStable();
117 EXPECT_NE(paintTiming().firstMeaningfulPaint(), 0.0); 135 EXPECT_NE(paintTiming().firstMeaningfulPaint(), 0.0);
118 } 136 }
119 137
120 TEST_F(FirstMeaningfulPaintDetectorTest, 138 TEST_F(FirstMeaningfulPaintDetectorTest,
121 FirstMeaningfulPaintShouldNotBeBeforeFirstContentfulPaint) { 139 FirstMeaningfulPaintShouldNotBeBeforeFirstContentfulPaint) {
122 paintTiming().markFirstPaint(); 140 paintTiming().markFirstPaint();
123 simulateLayoutAndPaint(10); 141 simulateLayoutAndPaint(10);
124 paintTiming().markFirstContentfulPaint(); 142 paintTiming().markFirstContentfulPaint();
125 simulateNetworkStable(); 143 simulateNetworkStable();
126 EXPECT_GE(paintTiming().firstMeaningfulPaint(), 144 EXPECT_GE(paintTiming().firstMeaningfulPaint(),
127 paintTiming().firstContentfulPaint()); 145 paintTiming().firstContentfulPaint());
128 } 146 }
129 147
130 } // namespace blink 148 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698