OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/dom/DocumentStatisticsCollector.h" | 5 #include "core/dom/DocumentStatisticsCollector.h" |
6 | 6 |
7 #include "core/dom/Document.h" | 7 #include "core/dom/Document.h" |
8 #include "core/dom/DocumentVisibilityObserver.h" | 8 #include "core/dom/DocumentVisibilityObserver.h" |
9 #include "core/frame/FrameView.h" | 9 #include "core/frame/FrameView.h" |
10 #include "core/html/HTMLHeadElement.h" | 10 #include "core/html/HTMLHeadElement.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // Filter out short P elements. The threshold is set to around 2 English sentenc
es. | 23 // Filter out short P elements. The threshold is set to around 2 English sentenc
es. |
24 const unsigned kParagraphLengthThreshold = 140; | 24 const unsigned kParagraphLengthThreshold = 140; |
25 | 25 |
26 class DocumentStatisticsCollectorTest : public ::testing::Test { | 26 class DocumentStatisticsCollectorTest : public ::testing::Test { |
27 protected: | 27 protected: |
28 void SetUp() override; | 28 void SetUp() override; |
29 | 29 |
30 #if ENABLE(OILPAN) | 30 #if ENABLE(OILPAN) |
31 void TearDown() override | 31 void TearDown() override |
32 { | 32 { |
33 ThreadHeap::collectAllGarbage(); | 33 Heap::collectAllGarbage(); |
34 } | 34 } |
35 #endif | 35 #endif |
36 | 36 |
37 Document& document() const { return m_dummyPageHolder->document(); } | 37 Document& document() const { return m_dummyPageHolder->document(); } |
38 | 38 |
39 void setHtmlInnerHTML(const String&); | 39 void setHtmlInnerHTML(const String&); |
40 | 40 |
41 private: | 41 private: |
42 OwnPtr<DummyPageHolder> m_dummyPageHolder; | 42 OwnPtr<DummyPageHolder> m_dummyPageHolder; |
43 }; | 43 }; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 ); | 146 ); |
147 WebDistillabilityFeatures features = DocumentStatisticsCollector::collectSta
tistics(document()); | 147 WebDistillabilityFeatures features = DocumentStatisticsCollector::collectSta
tistics(document()); |
148 | 148 |
149 double error = 1e-5; | 149 double error = 1e-5; |
150 EXPECT_NEAR(features.mozScore, 6 * sqrt(kTextContentLengthSaturation - kPara
graphLengthThreshold), error); | 150 EXPECT_NEAR(features.mozScore, 6 * sqrt(kTextContentLengthSaturation - kPara
graphLengthThreshold), error); |
151 EXPECT_NEAR(features.mozScoreAllSqrt, 6 * sqrt(kTextContentLengthSaturation)
, error); | 151 EXPECT_NEAR(features.mozScoreAllSqrt, 6 * sqrt(kTextContentLengthSaturation)
, error); |
152 EXPECT_NEAR(features.mozScoreAllLinear, 6 * kTextContentLengthSaturation, er
ror); | 152 EXPECT_NEAR(features.mozScoreAllLinear, 6 * kTextContentLengthSaturation, er
ror); |
153 } | 153 } |
154 | 154 |
155 } // namespace blink | 155 } // namespace blink |
OLD | NEW |