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

Side by Side Diff: components/dom_distiller/core/distillable_page_detector_unittest.cc

Issue 2257793002: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 4 years, 3 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 "components/dom_distiller/core/distillable_page_detector.h" 5 #include "components/dom_distiller/core/distillable_page_detector.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace dom_distiller { 10 namespace dom_distiller {
(...skipping 12 matching lines...) Expand all
23 } 23 }
24 24
25 std::unique_ptr<DistillablePageDetector> Build() { 25 std::unique_ptr<DistillablePageDetector> Build() {
26 int num_features = 0; 26 int num_features = 0;
27 for (int i = 0; i < proto_.stump_size(); ++i) { 27 for (int i = 0; i < proto_.stump_size(); ++i) {
28 num_features = 28 num_features =
29 std::max(num_features, proto_.stump(i).feature_number() + 1); 29 std::max(num_features, proto_.stump(i).feature_number() + 1);
30 } 30 }
31 proto_.set_num_features(num_features); 31 proto_.set_num_features(num_features);
32 proto_.set_num_stumps(proto_.stump_size()); 32 proto_.set_num_stumps(proto_.stump_size());
33 return base::WrapUnique(new DistillablePageDetector( 33 return base::MakeUnique<DistillablePageDetector>(
34 base::WrapUnique(new AdaBoostProto(proto_)))); 34 base::WrapUnique(new AdaBoostProto(proto_)));
35 } 35 }
36 36
37 private: 37 private:
38 AdaBoostProto proto_; 38 AdaBoostProto proto_;
39 }; 39 };
40 40
41 } 41 }
42 42
43 TEST(DomDistillerDistillablePageDetectorTest, TestCalculateThreshold) { 43 TEST(DomDistillerDistillablePageDetectorTest, TestCalculateThreshold) {
44 std::unique_ptr<DistillablePageDetector> detector = 44 std::unique_ptr<DistillablePageDetector> detector =
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 std::vector<double> features; 100 std::vector<double> features;
101 EXPECT_DOUBLE_EQ(0.0, detector->Score(features)); 101 EXPECT_DOUBLE_EQ(0.0, detector->Score(features));
102 features.push_back(-3.0); 102 features.push_back(-3.0);
103 features.push_back(1.0); 103 features.push_back(1.0);
104 EXPECT_DOUBLE_EQ(0.0, detector->Score(features)); 104 EXPECT_DOUBLE_EQ(0.0, detector->Score(features));
105 } 105 }
106 106
107 107
108 } 108 }
109 109
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698