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

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

Issue 2883273003: Move the user interaction policy for FirstMeaningfulPaint UMA into renderer (Closed)
Patch Set: rebase Created 3 years, 6 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 "platform/testing/TestingPlatformSupport.h" 9 #include "platform/testing/TestingPlatformSupport.h"
10 #include "platform/wtf/text/StringBuilder.h" 10 #include "platform/wtf/text/StringBuilder.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 void SimulateNetwork0Quiet() { 49 void SimulateNetwork0Quiet() {
50 GetDocument().SetParsingState(Document::kFinishedParsing); 50 GetDocument().SetParsingState(Document::kFinishedParsing);
51 Detector().Network0QuietTimerFired(nullptr); 51 Detector().Network0QuietTimerFired(nullptr);
52 } 52 }
53 53
54 void SimulateNetwork2Quiet() { 54 void SimulateNetwork2Quiet() {
55 GetDocument().SetParsingState(Document::kFinishedParsing); 55 GetDocument().SetParsingState(Document::kFinishedParsing);
56 Detector().Network2QuietTimerFired(nullptr); 56 Detector().Network2QuietTimerFired(nullptr);
57 } 57 }
58 58
59 void SimulateUserInput() { Detector().NotifyInputEvent(); }
60
59 void SetActiveConnections(int connections) { 61 void SetActiveConnections(int connections) {
60 Detector().SetNetworkQuietTimers(connections); 62 Detector().SetNetworkQuietTimers(connections);
61 } 63 }
62 64
63 bool IsNetwork0QuietTimerActive() { 65 bool IsNetwork0QuietTimerActive() {
64 return Detector().network0_quiet_timer_.IsActive(); 66 return Detector().network0_quiet_timer_.IsActive();
65 } 67 }
66 68
67 bool IsNetwork2QuietTimerActive() { 69 bool IsNetwork2QuietTimerActive() {
68 return Detector().network2_quiet_timer_.IsActive(); 70 return Detector().network2_quiet_timer_.IsActive();
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 SetActiveConnections(2); // This should reset the 2-quiet timer. 244 SetActiveConnections(2); // This should reset the 2-quiet timer.
243 platform_->RunForPeriodSeconds(kNetwork2QuietWindowSeconds - 0.1); 245 platform_->RunForPeriodSeconds(kNetwork2QuietWindowSeconds - 0.1);
244 EXPECT_TRUE(IsNetwork2QuietTimerActive()); 246 EXPECT_TRUE(IsNetwork2QuietTimerActive());
245 EXPECT_FALSE(HadNetwork2Quiet()); 247 EXPECT_FALSE(HadNetwork2Quiet());
246 248
247 SetActiveConnections(1); // This should not reset the 2-quiet timer. 249 SetActiveConnections(1); // This should not reset the 2-quiet timer.
248 platform_->RunForPeriodSeconds(0.1001); 250 platform_->RunForPeriodSeconds(0.1001);
249 EXPECT_TRUE(HadNetwork2Quiet()); 251 EXPECT_TRUE(HadNetwork2Quiet());
250 } 252 }
251 253
254 TEST_F(FirstMeaningfulPaintDetectorTest,
255 FirstMeaningfulPaintAfterUserInteraction) {
256 GetPaintTiming().MarkFirstContentfulPaint();
257 SimulateUserInput();
258 SimulateLayoutAndPaint(10);
259 SimulateNetworkStable();
260 EXPECT_EQ(GetPaintTiming().FirstMeaningfulPaint(), 0.0);
261 }
tdresser 2017/06/07 12:32:54 Should we have a test showing that we ignore input
Kunihiko Sakamoto 2017/06/08 07:54:49 Done.
262
252 } // namespace blink 263 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698