| 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 |
| 11 namespace blink { | 11 namespace blink { |
| 12 | 12 |
| 13 class FirstMeaningfulPaintDetectorTest : public testing::Test { | 13 class FirstMeaningfulPaintDetectorTest : public testing::Test { |
| 14 protected: | 14 protected: |
| 15 void SetUp() override | 15 void SetUp() override |
| 16 { | 16 { |
| 17 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); | 17 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); |
| 18 s_timeElapsed = 0.0; | 18 s_timeElapsed = 0.0; |
| 19 m_originalTimeFunction = setTimeFunctionsForTesting(returnMockTime); | 19 m_originalTimeFunction = setMonotonicallyIncreasingTimeFunctionForTestin
g(returnMockTime); |
| 20 } | 20 } |
| 21 | 21 |
| 22 void TearDown() override | 22 void TearDown() override |
| 23 { | 23 { |
| 24 setTimeFunctionsForTesting(m_originalTimeFunction); | 24 setMonotonicallyIncreasingTimeFunctionForTesting(m_originalTimeFunction)
; |
| 25 } | 25 } |
| 26 | 26 |
| 27 Document& document() { return m_dummyPageHolder->document(); } | 27 Document& document() { return m_dummyPageHolder->document(); } |
| 28 PaintTiming& paintTiming() { return PaintTiming::from(document()); } | 28 PaintTiming& paintTiming() { return PaintTiming::from(document()); } |
| 29 FirstMeaningfulPaintDetector& detector() { return paintTiming().firstMeaning
fulPaintDetector(); } | 29 FirstMeaningfulPaintDetector& detector() { return paintTiming().firstMeaning
fulPaintDetector(); } |
| 30 | 30 |
| 31 void simulateLayoutAndPaint(int newElements) | 31 void simulateLayoutAndPaint(int newElements) |
| 32 { | 32 { |
| 33 StringBuilder builder; | 33 StringBuilder builder; |
| 34 for (int i = 0; i < newElements; i++) | 34 for (int i = 0; i < newElements; i++) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 paintTiming().markFirstPaint(); | 92 paintTiming().markFirstPaint(); |
| 93 simulateLayoutAndPaint(10); | 93 simulateLayoutAndPaint(10); |
| 94 double afterLayout1 = monotonicallyIncreasingTime(); | 94 double afterLayout1 = monotonicallyIncreasingTime(); |
| 95 simulateLayoutAndPaint(1); | 95 simulateLayoutAndPaint(1); |
| 96 simulateNetworkStable(); | 96 simulateNetworkStable(); |
| 97 EXPECT_GT(paintTiming().firstMeaningfulPaint(), paintTiming().firstPaint()); | 97 EXPECT_GT(paintTiming().firstMeaningfulPaint(), paintTiming().firstPaint()); |
| 98 EXPECT_LT(paintTiming().firstMeaningfulPaint(), afterLayout1); | 98 EXPECT_LT(paintTiming().firstMeaningfulPaint(), afterLayout1); |
| 99 } | 99 } |
| 100 | 100 |
| 101 } // namespace blink | 101 } // namespace blink |
| OLD | NEW |