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

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

Issue 2050123002: Remove OwnPtr from Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: First attempt to land. 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>
16 17
17 namespace blink { 18 namespace blink {
18 19
19 // Saturate the length of a paragraph to save time. 20 // Saturate the length of a paragraph to save time.
20 const unsigned kTextContentLengthSaturation = 1000; 21 const unsigned kTextContentLengthSaturation = 1000;
21 22
22 // 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.
23 const unsigned kParagraphLengthThreshold = 140; 24 const unsigned kParagraphLengthThreshold = 140;
24 25
25 class DocumentStatisticsCollectorTest : public ::testing::Test { 26 class DocumentStatisticsCollectorTest : public ::testing::Test {
26 protected: 27 protected:
27 void SetUp() override; 28 void SetUp() override;
28 29
29 void TearDown() override 30 void TearDown() override
30 { 31 {
31 ThreadHeap::collectAllGarbage(); 32 ThreadHeap::collectAllGarbage();
32 } 33 }
33 34
34 Document& document() const { return m_dummyPageHolder->document(); } 35 Document& document() const { return m_dummyPageHolder->document(); }
35 36
36 void setHtmlInnerHTML(const String&); 37 void setHtmlInnerHTML(const String&);
37 38
38 private: 39 private:
39 OwnPtr<DummyPageHolder> m_dummyPageHolder; 40 std::unique_ptr<DummyPageHolder> m_dummyPageHolder;
40 }; 41 };
41 42
42 void DocumentStatisticsCollectorTest::SetUp() 43 void DocumentStatisticsCollectorTest::SetUp()
43 { 44 {
44 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600)); 45 m_dummyPageHolder = DummyPageHolder::create(IntSize(800, 600));
45 } 46 }
46 47
47 void DocumentStatisticsCollectorTest::setHtmlInnerHTML(const String& htmlContent ) 48 void DocumentStatisticsCollectorTest::setHtmlInnerHTML(const String& htmlContent )
48 { 49 {
49 document().documentElement()->setInnerHTML((htmlContent), ASSERT_NO_EXCEPTIO N); 50 document().documentElement()->setInnerHTML((htmlContent), ASSERT_NO_EXCEPTIO N);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 ); 144 );
144 WebDistillabilityFeatures features = DocumentStatisticsCollector::collectSta tistics(document()); 145 WebDistillabilityFeatures features = DocumentStatisticsCollector::collectSta tistics(document());
145 146
146 double error = 1e-5; 147 double error = 1e-5;
147 EXPECT_NEAR(features.mozScore, 6 * sqrt(kTextContentLengthSaturation - kPara graphLengthThreshold), error); 148 EXPECT_NEAR(features.mozScore, 6 * sqrt(kTextContentLengthSaturation - kPara graphLengthThreshold), error);
148 EXPECT_NEAR(features.mozScoreAllSqrt, 6 * sqrt(kTextContentLengthSaturation) , error); 149 EXPECT_NEAR(features.mozScoreAllSqrt, 6 * sqrt(kTextContentLengthSaturation) , error);
149 EXPECT_NEAR(features.mozScoreAllLinear, 6 * kTextContentLengthSaturation, er ror); 150 EXPECT_NEAR(features.mozScoreAllLinear, 6 * kTextContentLengthSaturation, er ror);
150 } 151 }
151 152
152 } // namespace blink 153 } // 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