| 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 // 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 FROM_HERE, | 66 FROM_HERE, |
| 67 base::Bind(&PhishingDOMFeatureExtractorTest::RemoveIframe, | 67 base::Bind(&PhishingDOMFeatureExtractorTest::RemoveIframe, |
| 68 weak_factory_.GetWeakPtr())); | 68 weak_factory_.GetWeakPtr())); |
| 69 } | 69 } |
| 70 | 70 |
| 71 protected: | 71 protected: |
| 72 PhishingDOMFeatureExtractorTest() : weak_factory_(this) {} | 72 PhishingDOMFeatureExtractorTest() : weak_factory_(this) {} |
| 73 | 73 |
| 74 virtual ~PhishingDOMFeatureExtractorTest() {} | 74 virtual ~PhishingDOMFeatureExtractorTest() {} |
| 75 | 75 |
| 76 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 76 virtual void SetUpCommandLine(CommandLine* command_line) override { |
| 77 command_line->AppendSwitch(switches::kSingleProcess); | 77 command_line->AppendSwitch(switches::kSingleProcess); |
| 78 #if defined(OS_WIN) | 78 #if defined(OS_WIN) |
| 79 // Don't want to try to create a GPU process. | 79 // Don't want to try to create a GPU process. |
| 80 command_line->AppendSwitch(switches::kDisableGpu); | 80 command_line->AppendSwitch(switches::kDisableGpu); |
| 81 #endif | 81 #endif |
| 82 } | 82 } |
| 83 | 83 |
| 84 virtual void SetUpOnMainThread() OVERRIDE { | 84 virtual void SetUpOnMainThread() override { |
| 85 extractor_.reset(new PhishingDOMFeatureExtractor( | 85 extractor_.reset(new PhishingDOMFeatureExtractor( |
| 86 content::RenderView::FromRoutingID(kRenderViewRoutingId), &clock_)); | 86 content::RenderView::FromRoutingID(kRenderViewRoutingId), &clock_)); |
| 87 | 87 |
| 88 ASSERT_TRUE(StartTestServer()); | 88 ASSERT_TRUE(StartTestServer()); |
| 89 host_resolver()->AddRule("*", "127.0.0.1"); | 89 host_resolver()->AddRule("*", "127.0.0.1"); |
| 90 } | 90 } |
| 91 | 91 |
| 92 // Runs the DOMFeatureExtractor on the RenderView, waiting for the | 92 // Runs the DOMFeatureExtractor on the RenderView, waiting for the |
| 93 // completion callback. Returns the success boolean from the callback. | 93 // completion callback. Returns the success boolean from the callback. |
| 94 bool ExtractFeatures(FeatureMap* features) { | 94 bool ExtractFeatures(FeatureMap* features) { |
| (...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 LoadHtml( | 512 LoadHtml( |
| 513 "host.com", | 513 "host.com", |
| 514 "<html><head></head><body>" | 514 "<html><head></head><body>" |
| 515 "<iframe src=\"frame.html\" id=\"frame1\"></iframe>" | 515 "<iframe src=\"frame.html\" id=\"frame1\"></iframe>" |
| 516 "<form></form></body></html>"); | 516 "<form></form></body></html>"); |
| 517 ASSERT_TRUE(ExtractFeatures(&features)); | 517 ASSERT_TRUE(ExtractFeatures(&features)); |
| 518 ExpectFeatureMapsAreEqual(features, expected_features); | 518 ExpectFeatureMapsAreEqual(features, expected_features); |
| 519 } | 519 } |
| 520 | 520 |
| 521 } // namespace safe_browsing | 521 } // namespace safe_browsing |
| OLD | NEW |