OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 // Note that although this is not a "browser" test, it runs as part of | 5 // Note that although this is not a "browser" test, it runs as part of |
6 // browser_tests. This is because WebKit does not work properly if it is | 6 // browser_tests. This is because WebKit does not work properly if it is |
7 // shutdown and re-initialized. Since browser_tests runs each test in a | 7 // shutdown and re-initialized. Since browser_tests runs each test in a |
8 // new process, this avoids the problem. | 8 // new process, this avoids the problem. |
9 | 9 |
10 #include "chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h" | 10 #include "chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 virtual void TearDown() { | 57 virtual void TearDown() { |
58 RenderViewFakeResourcesTest::TearDown(); | 58 RenderViewFakeResourcesTest::TearDown(); |
59 } | 59 } |
60 | 60 |
61 // Runs the DOMFeatureExtractor on the RenderView, waiting for the | 61 // Runs the DOMFeatureExtractor on the RenderView, waiting for the |
62 // completion callback. Returns the success boolean from the callback. | 62 // completion callback. Returns the success boolean from the callback. |
63 bool ExtractFeatures(FeatureMap* features) { | 63 bool ExtractFeatures(FeatureMap* features) { |
64 success_ = false; | 64 success_ = false; |
65 extractor_->ExtractFeatures( | 65 extractor_->ExtractFeatures( |
66 features, | 66 features, |
67 NewCallback(this, &PhishingDOMFeatureExtractorTest::ExtractionDone)); | 67 base::Bind(&PhishingDOMFeatureExtractorTest::ExtractionDone, |
| 68 base::Unretained(this))); |
68 message_loop_.Run(); | 69 message_loop_.Run(); |
69 return success_; | 70 return success_; |
70 } | 71 } |
71 | 72 |
72 // Completion callback for feature extraction. | 73 // Completion callback for feature extraction. |
73 void ExtractionDone(bool success) { | 74 void ExtractionDone(bool success) { |
74 success_ = success; | 75 success_ = success; |
75 message_loop_.Quit(); | 76 message_loop_.Quit(); |
76 } | 77 } |
77 | 78 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 expected_features.AddBooleanFeature(features::kPageHasForms); | 393 expected_features.AddBooleanFeature(features::kPageHasForms); |
393 expected_features.AddBooleanFeature(features::kPageHasPswdInputs); | 394 expected_features.AddBooleanFeature(features::kPageHasPswdInputs); |
394 | 395 |
395 FeatureMap features; | 396 FeatureMap features; |
396 LoadURL("http://host.com/"); | 397 LoadURL("http://host.com/"); |
397 ASSERT_TRUE(ExtractFeatures(&features)); | 398 ASSERT_TRUE(ExtractFeatures(&features)); |
398 EXPECT_THAT(features.features(), ContainerEq(expected_features.features())); | 399 EXPECT_THAT(features.features(), ContainerEq(expected_features.features())); |
399 } | 400 } |
400 | 401 |
401 } // namespace safe_browsing | 402 } // namespace safe_browsing |
OLD | NEW |