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

Side by Side Diff: third_party/WebKit/Source/core/dom/DocumentStatisticsCollectorTest.cpp

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 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/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/html/HTMLHeadElement.h" 9 #include "core/html/HTMLHeadElement.h"
10 #include "core/html/HTMLLinkElement.h" 10 #include "core/html/HTMLLinkElement.h"
11 #include "core/testing/DummyPageHolder.h" 11 #include "core/testing/DummyPageHolder.h"
12 #include "public/platform/WebDistillability.h" 12 #include "public/platform/WebDistillability.h"
13 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "wtf/text/StringBuilder.h" 15 #include "wtf/text/StringBuilder.h"
16 #include <memory>
17 16
18 namespace blink { 17 namespace blink {
19 18
20 // Saturate the length of a paragraph to save time. 19 // Saturate the length of a paragraph to save time.
21 const unsigned kTextContentLengthSaturation = 1000; 20 const unsigned kTextContentLengthSaturation = 1000;
22 21
23 // Filter out short P elements. The threshold is set to around 2 English sentenc es. 22 // Filter out short P elements. The threshold is set to around 2 English sentenc es.
24 const unsigned kParagraphLengthThreshold = 140; 23 const unsigned kParagraphLengthThreshold = 140;
25 24
26 class DocumentStatisticsCollectorTest : public ::testing::Test { 25 class DocumentStatisticsCollectorTest : public ::testing::Test {
27 protected: 26 protected:
28 void SetUp() override; 27 void SetUp() override;
29 28
30 void TearDown() override 29 void TearDown() override
31 { 30 {
32 ThreadHeap::collectAllGarbage(); 31 ThreadHeap::collectAllGarbage();
33 } 32 }
34 33
35 Document& document() const { return m_dummyPageHolder->document(); } 34 Document& document() const { return m_dummyPageHolder->document(); }
36 35
37 void setHtmlInnerHTML(const String&); 36 void setHtmlInnerHTML(const String&);
38 37
39 private: 38 private:
40 std::unique_ptr<DummyPageHolder> m_dummyPageHolder; 39 OwnPtr<DummyPageHolder> m_dummyPageHolder;
41 }; 40 };
42 41
43 void DocumentStatisticsCollectorTest::SetUp() 42 void DocumentStatisticsCollectorTest::SetUp()
44 { 43 {
45 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); 44 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600));
46 } 45 }
47 46
48 void DocumentStatisticsCollectorTest::setHtmlInnerHTML(const String& htmlContent ) 47 void DocumentStatisticsCollectorTest::setHtmlInnerHTML(const String& htmlContent )
49 { 48 {
50 document().documentElement()->setInnerHTML((htmlContent), ASSERT_NO_EXCEPTIO N); 49 document().documentElement()->setInnerHTML((htmlContent), ASSERT_NO_EXCEPTIO N);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 ); 143 );
145 WebDistillabilityFeatures features = DocumentStatisticsCollector::collectSta tistics(document()); 144 WebDistillabilityFeatures features = DocumentStatisticsCollector::collectSta tistics(document());
146 145
147 double error = 1e-5; 146 double error = 1e-5;
148 EXPECT_NEAR(features.mozScore, 6 * sqrt(kTextContentLengthSaturation - kPara graphLengthThreshold), error); 147 EXPECT_NEAR(features.mozScore, 6 * sqrt(kTextContentLengthSaturation - kPara graphLengthThreshold), error);
149 EXPECT_NEAR(features.mozScoreAllSqrt, 6 * sqrt(kTextContentLengthSaturation) , error); 148 EXPECT_NEAR(features.mozScoreAllSqrt, 6 * sqrt(kTextContentLengthSaturation) , error);
150 EXPECT_NEAR(features.mozScoreAllLinear, 6 * kTextContentLengthSaturation, er ror); 149 EXPECT_NEAR(features.mozScoreAllLinear, 6 * kTextContentLengthSaturation, er ror);
151 } 150 }
152 151
153 } // namespace blink 152 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/DocumentParser.cpp ('k') | third_party/WebKit/Source/core/dom/DocumentTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698