OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/renderer/safe_browsing/phishing_term_feature_extractor.h" | 5 #include "chrome/renderer/safe_browsing/phishing_term_feature_extractor.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 void PartialExtractFeatures(const string16* page_text, FeatureMap* features) { | 92 void PartialExtractFeatures(const string16* page_text, FeatureMap* features) { |
93 extractor_->ExtractFeatures( | 93 extractor_->ExtractFeatures( |
94 page_text, | 94 page_text, |
95 features, | 95 features, |
96 base::Bind(&PhishingTermFeatureExtractorTest::ExtractionDone, | 96 base::Bind(&PhishingTermFeatureExtractorTest::ExtractionDone, |
97 base::Unretained(this))); | 97 base::Unretained(this))); |
98 msg_loop_.PostTask( | 98 msg_loop_.PostTask( |
99 FROM_HERE, | 99 FROM_HERE, |
100 base::Bind(&PhishingTermFeatureExtractorTest::QuitExtraction, | 100 base::Bind(&PhishingTermFeatureExtractorTest::QuitExtraction, |
101 base::Unretained(this))); | 101 base::Unretained(this))); |
102 msg_loop_.RunAllPending(); | 102 msg_loop_.RunUntilIdle(); |
103 } | 103 } |
104 | 104 |
105 // Completion callback for feature extraction. | 105 // Completion callback for feature extraction. |
106 void ExtractionDone(bool success) { | 106 void ExtractionDone(bool success) { |
107 success_ = success; | 107 success_ = success; |
108 msg_loop_.Quit(); | 108 msg_loop_.Quit(); |
109 } | 109 } |
110 | 110 |
111 void QuitExtraction() { | 111 void QuitExtraction() { |
112 extractor_->CancelPendingExtraction(); | 112 extractor_->CancelPendingExtraction(); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 // Now extract normally and make sure nothing breaks. | 306 // Now extract normally and make sure nothing breaks. |
307 EXPECT_TRUE(ExtractFeatures(page_text.get(), &features)); | 307 EXPECT_TRUE(ExtractFeatures(page_text.get(), &features)); |
308 | 308 |
309 FeatureMap expected_features; | 309 FeatureMap expected_features; |
310 expected_features.AddBooleanFeature(features::kPageTerm + | 310 expected_features.AddBooleanFeature(features::kPageTerm + |
311 std::string("multi word test")); | 311 std::string("multi word test")); |
312 ExpectFeatureMapsAreEqual(features, expected_features); | 312 ExpectFeatureMapsAreEqual(features, expected_features); |
313 } | 313 } |
314 | 314 |
315 } // namespace safe_browsing | 315 } // namespace safe_browsing |
OLD | NEW |