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