| 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 "platform/testing/HistogramTester.h" | 5 #include "platform/testing/HistogramTester.h" |
| 6 #include "platform/testing/UnitTestHelpers.h" | 6 #include "platform/testing/UnitTestHelpers.h" |
| 7 #include "web/WebViewImpl.h" | 7 #include "web/WebViewImpl.h" |
| 8 #include "web/tests/sim/SimCompositor.h" | 8 #include "web/tests/sim/SimCompositor.h" |
| 9 #include "web/tests/sim/SimDisplayItemList.h" | 9 #include "web/tests/sim/SimDisplayItemList.h" |
| 10 #include "web/tests/sim/SimRequest.h" | 10 #include "web/tests/sim/SimRequest.h" |
| 11 #include "web/tests/sim/SimTest.h" | 11 #include "web/tests/sim/SimTest.h" |
| 12 | 12 |
| 13 namespace blink { | 13 namespace blink { |
| 14 | 14 |
| 15 static const char* kHistogramName = | 15 static const char* kHistogramName = |
| 16 "Navigation.DeferredDocumentLoading.StatesV2"; | 16 "Navigation.DeferredDocumentLoading.StatesV3"; |
| 17 | 17 |
| 18 class DeferredLoadingTest : public SimTest { | 18 class DeferredLoadingTest : public SimTest { |
| 19 protected: | 19 protected: |
| 20 DeferredLoadingTest() { webView().resize(WebSize(640, 480)); } | 20 DeferredLoadingTest() { webView().resize(WebSize(640, 480)); } |
| 21 void compositeFrame() { | 21 void compositeFrame() { |
| 22 compositor().beginFrame(); | 22 compositor().beginFrame(); |
| 23 testing::runPendingTasks(); | 23 testing::runPendingTasks(); |
| 24 if (compositor().needsBeginFrame()) | 24 if (compositor().needsBeginFrame()) |
| 25 compositor().beginFrame(); // VisibleNestedInRight doesn't need this. | 25 compositor().beginFrame(); // VisibleNestedInRight doesn't need this. |
| 26 ASSERT_FALSE(compositor().needsBeginFrame()); | 26 ASSERT_FALSE(compositor().needsBeginFrame()); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 TEST_F(DeferredLoadingTest, AboveAndLeft) { | 101 TEST_F(DeferredLoadingTest, AboveAndLeft) { |
| 102 HistogramTester histogramTester; | 102 HistogramTester histogramTester; |
| 103 std::unique_ptr<SimRequest> mainResource = createMainResource(); | 103 std::unique_ptr<SimRequest> mainResource = createMainResource(); |
| 104 | 104 |
| 105 mainResource->complete( | 105 mainResource->complete( |
| 106 "<iframe style='position:absolute; left:-10000px; top:-10000px' sandbox>" | 106 "<iframe style='position:absolute; left:-10000px; top:-10000px' sandbox>" |
| 107 "</iframe>"); | 107 "</iframe>"); |
| 108 | 108 |
| 109 compositeFrame(); | 109 compositeFrame(); |
| 110 | 110 |
| 111 // Don't log WouldLoadAbove AND WouldLoadLeft. | |
| 112 histogramTester.expectBucketCount(kHistogramName, Created, 1); | 111 histogramTester.expectBucketCount(kHistogramName, Created, 1); |
| 113 histogramTester.expectBucketCount(kHistogramName, WouldLoadAbove, 1); | 112 histogramTester.expectBucketCount(kHistogramName, WouldLoadAboveAndLeft, 1); |
| 114 histogramTester.expectTotalCount(kHistogramName, 2); | 113 histogramTester.expectTotalCount(kHistogramName, 2); |
| 115 } | 114 } |
| 116 | 115 |
| 117 TEST_F(DeferredLoadingTest, ZeroByZero) { | 116 TEST_F(DeferredLoadingTest, ZeroByZero) { |
| 118 HistogramTester histogramTester; | 117 HistogramTester histogramTester; |
| 119 std::unique_ptr<SimRequest> mainResource = createMainResource(); | 118 std::unique_ptr<SimRequest> mainResource = createMainResource(); |
| 120 | 119 |
| 121 mainResource->complete( | 120 mainResource->complete( |
| 122 "<iframe style='height:0px;width:0px;' sandbox></iframe>"); | 121 "<iframe style='height:0px;width:0px;' sandbox></iframe>"); |
| 123 | 122 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 SimRequest frameResource("https://example.com/iframe.html", "text/html"); | 177 SimRequest frameResource("https://example.com/iframe.html", "text/html"); |
| 179 | 178 |
| 180 mainResource->complete("<iframe src='iframe.html'></iframe>"); | 179 mainResource->complete("<iframe src='iframe.html'></iframe>"); |
| 181 frameResource.complete("<iframe></iframe>"); | 180 frameResource.complete("<iframe></iframe>"); |
| 182 compositeFrame(); | 181 compositeFrame(); |
| 183 | 182 |
| 184 histogramTester.expectTotalCount(kHistogramName, 0); | 183 histogramTester.expectTotalCount(kHistogramName, 0); |
| 185 } | 184 } |
| 186 | 185 |
| 187 } // namespace blink | 186 } // namespace blink |
| OLD | NEW |