Index: third_party/WebKit/Source/core/paint/FirstMeaningfulPaintDetectorTest.cpp |
diff --git a/third_party/WebKit/Source/core/paint/FirstMeaningfulPaintDetectorTest.cpp b/third_party/WebKit/Source/core/paint/FirstMeaningfulPaintDetectorTest.cpp |
index 842d2731b0604d96e2da5a3b072ac73c9e1196ee..1beeb38678b1b6dac1e16515a3e22702eac001f7 100644 |
--- a/third_party/WebKit/Source/core/paint/FirstMeaningfulPaintDetectorTest.cpp |
+++ b/third_party/WebKit/Source/core/paint/FirstMeaningfulPaintDetectorTest.cpp |
@@ -37,7 +37,21 @@ class FirstMeaningfulPaintDetectorTest : public testing::Test { |
detector().notifyPaint(); |
} |
- void simulateNetworkStable() { detector().networkStableTimerFired(nullptr); } |
+ void simulateNetworkStable() { |
+ document().setParsingState(Document::FinishedParsing); |
+ detector().network0QuietTimerFired(nullptr); |
+ detector().network2QuietTimerFired(nullptr); |
+ } |
+ |
+ void simulateNetwork0Quiet() { |
+ document().setParsingState(Document::FinishedParsing); |
+ detector().network0QuietTimerFired(nullptr); |
+ } |
+ |
+ void simulateNetwork2Quiet() { |
+ document().setParsingState(Document::FinishedParsing); |
+ detector().network2QuietTimerFired(nullptr); |
+ } |
private: |
static double returnMockTime() { |
@@ -126,4 +140,35 @@ TEST_F(FirstMeaningfulPaintDetectorTest, |
paintTiming().firstContentfulPaint()); |
} |
+TEST_F(FirstMeaningfulPaintDetectorTest, Network2QuietThen0Quiet) { |
+ paintTiming().markFirstContentfulPaint(); |
+ |
+ simulateLayoutAndPaint(1); |
+ double afterFirstPaint = monotonicallyIncreasingTime(); |
+ simulateNetwork2Quiet(); |
+ |
+ simulateLayoutAndPaint(10); |
+ simulateNetwork0Quiet(); |
+ |
+ // The first paint is FirstMeaningfulPaint. |
+ EXPECT_GT(paintTiming().firstMeaningfulPaint(), 0.0); |
+ EXPECT_LT(paintTiming().firstMeaningfulPaint(), afterFirstPaint); |
+} |
+ |
+TEST_F(FirstMeaningfulPaintDetectorTest, Network0QuietThen2Quiet) { |
+ paintTiming().markFirstContentfulPaint(); |
+ |
+ simulateLayoutAndPaint(1); |
+ double afterFirstPaint = monotonicallyIncreasingTime(); |
+ simulateNetwork0Quiet(); |
+ |
+ simulateLayoutAndPaint(10); |
+ double afterSecondPaint = monotonicallyIncreasingTime(); |
+ simulateNetwork2Quiet(); |
+ |
+ // The second paint is FirstMeaningfulPaint. |
+ EXPECT_GT(paintTiming().firstMeaningfulPaint(), afterFirstPaint); |
+ EXPECT_LT(paintTiming().firstMeaningfulPaint(), afterSecondPaint); |
+} |
+ |
} // namespace blink |