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 "components/dom_distiller/content/browser/distillable_page_utils.h" | 5 #include "components/dom_distiller/content/browser/distillable_page_utils.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 LoadURL(kNonArticlePath); | 126 LoadURL(kNonArticlePath); |
127 base::RunLoop run_loop_; | 127 base::RunLoop run_loop_; |
128 ResultHolder holder(run_loop_.QuitClosure()); | 128 ResultHolder holder(run_loop_.QuitClosure()); |
129 IsOpenGraphArticle(shell()->web_contents(), holder.GetCallback()); | 129 IsOpenGraphArticle(shell()->web_contents(), holder.GetCallback()); |
130 run_loop_.Run(); | 130 run_loop_.Run(); |
131 ASSERT_FALSE(holder.GetResult()); | 131 ASSERT_FALSE(holder.GetResult()); |
132 } | 132 } |
133 | 133 |
134 IN_PROC_BROWSER_TEST_F(DomDistillerDistillablePageUtilsTest, | 134 IN_PROC_BROWSER_TEST_F(DomDistillerDistillablePageUtilsTest, |
135 TestIsDistillablePage) { | 135 TestIsDistillablePage) { |
136 scoped_ptr<AdaBoostProto> proto(new AdaBoostProto); | 136 std::unique_ptr<AdaBoostProto> proto(new AdaBoostProto); |
137 proto->set_num_features(kDerivedFeaturesCount); | 137 proto->set_num_features(kDerivedFeaturesCount); |
138 proto->set_num_stumps(1); | 138 proto->set_num_stumps(1); |
139 | 139 |
140 StumpProto* stump = proto->add_stump(); | 140 StumpProto* stump = proto->add_stump(); |
141 stump->set_feature_number(0); | 141 stump->set_feature_number(0); |
142 stump->set_weight(1); | 142 stump->set_weight(1); |
143 stump->set_split(-1); | 143 stump->set_split(-1); |
144 scoped_ptr<DistillablePageDetector> detector( | 144 std::unique_ptr<DistillablePageDetector> detector( |
145 new DistillablePageDetector(std::move(proto))); | 145 new DistillablePageDetector(std::move(proto))); |
146 EXPECT_DOUBLE_EQ(0.5, detector->GetThreshold()); | 146 EXPECT_DOUBLE_EQ(0.5, detector->GetThreshold()); |
147 // The first value of the first feature is either 0 or 1. Since the stump's | 147 // The first value of the first feature is either 0 or 1. Since the stump's |
148 // split is -1, the stump weight will be applied to any set of derived | 148 // split is -1, the stump weight will be applied to any set of derived |
149 // features. | 149 // features. |
150 LoadURL(kArticlePath); | 150 LoadURL(kArticlePath); |
151 base::RunLoop run_loop_; | 151 base::RunLoop run_loop_; |
152 ResultHolder holder(run_loop_.QuitClosure()); | 152 ResultHolder holder(run_loop_.QuitClosure()); |
153 IsDistillablePageForDetector(shell()->web_contents(), detector.get(), | 153 IsDistillablePageForDetector(shell()->web_contents(), detector.get(), |
154 holder.GetCallback()); | 154 holder.GetCallback()); |
155 run_loop_.Run(); | 155 run_loop_.Run(); |
156 ASSERT_TRUE(holder.GetResult()); | 156 ASSERT_TRUE(holder.GetResult()); |
157 } | 157 } |
158 | 158 |
159 IN_PROC_BROWSER_TEST_F(DomDistillerDistillablePageUtilsTest, | 159 IN_PROC_BROWSER_TEST_F(DomDistillerDistillablePageUtilsTest, |
160 TestIsNotDistillablePage) { | 160 TestIsNotDistillablePage) { |
161 scoped_ptr<AdaBoostProto> proto(new AdaBoostProto); | 161 std::unique_ptr<AdaBoostProto> proto(new AdaBoostProto); |
162 proto->set_num_features(kDerivedFeaturesCount); | 162 proto->set_num_features(kDerivedFeaturesCount); |
163 proto->set_num_stumps(1); | 163 proto->set_num_stumps(1); |
164 StumpProto* stump = proto->add_stump(); | 164 StumpProto* stump = proto->add_stump(); |
165 stump->set_feature_number(0); | 165 stump->set_feature_number(0); |
166 stump->set_weight(-1); | 166 stump->set_weight(-1); |
167 stump->set_split(-1); | 167 stump->set_split(-1); |
168 scoped_ptr<DistillablePageDetector> detector( | 168 std::unique_ptr<DistillablePageDetector> detector( |
169 new DistillablePageDetector(std::move(proto))); | 169 new DistillablePageDetector(std::move(proto))); |
170 EXPECT_DOUBLE_EQ(-0.5, detector->GetThreshold()); | 170 EXPECT_DOUBLE_EQ(-0.5, detector->GetThreshold()); |
171 // The first value of the first feature is either 0 or 1. Since the stump's | 171 // The first value of the first feature is either 0 or 1. Since the stump's |
172 // split is -1, the stump weight will be applied to any set of derived | 172 // split is -1, the stump weight will be applied to any set of derived |
173 // features. | 173 // features. |
174 LoadURL(kArticlePath); | 174 LoadURL(kArticlePath); |
175 base::RunLoop run_loop_; | 175 base::RunLoop run_loop_; |
176 ResultHolder holder(run_loop_.QuitClosure()); | 176 ResultHolder holder(run_loop_.QuitClosure()); |
177 IsDistillablePageForDetector(shell()->web_contents(), detector.get(), | 177 IsDistillablePageForDetector(shell()->web_contents(), detector.get(), |
178 holder.GetCallback()); | 178 holder.GetCallback()); |
179 run_loop_.Run(); | 179 run_loop_.Run(); |
180 ASSERT_FALSE(holder.GetResult()); | 180 ASSERT_FALSE(holder.GetResult()); |
181 } | 181 } |
182 | 182 |
183 } // namespace dom_distiller | 183 } // namespace dom_distiller |
OLD | NEW |