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

Side by Side Diff: chrome/renderer/safe_browsing/phishing_classifier_browsertest.cc

Issue 117693002: Make RenderFrameHostManager swap RenderFrameHosts, not RenderViewHosts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge conflicts Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/renderer/safe_browsing/phishing_classifier_delegate_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_classifier.h" 5 #include "chrome/renderer/safe_browsing/phishing_classifier.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 15 matching lines...) Expand all
26 #include "net/test/embedded_test_server/embedded_test_server.h" 26 #include "net/test/embedded_test_server/embedded_test_server.h"
27 #include "net/test/embedded_test_server/http_response.h" 27 #include "net/test/embedded_test_server/http_response.h"
28 #include "testing/gmock/include/gmock/gmock.h" 28 #include "testing/gmock/include/gmock/gmock.h"
29 #include "url/gurl.h" 29 #include "url/gurl.h"
30 30
31 using ::testing::AllOf; 31 using ::testing::AllOf;
32 using ::testing::Contains; 32 using ::testing::Contains;
33 using ::testing::Not; 33 using ::testing::Not;
34 using ::testing::Pair; 34 using ::testing::Pair;
35 35
36 namespace {
37
38 // The first RenderFrame is routing ID 1, and the first RenderView is 2.
39 const int kRenderViewRoutingId = 2;
40
41 }
42
36 namespace safe_browsing { 43 namespace safe_browsing {
37 44
38 class PhishingClassifierTest : public InProcessBrowserTest { 45 class PhishingClassifierTest : public InProcessBrowserTest {
39 protected: 46 protected:
40 PhishingClassifierTest() 47 PhishingClassifierTest()
41 : url_tld_token_net_(features::kUrlTldToken + std::string("net")), 48 : url_tld_token_net_(features::kUrlTldToken + std::string("net")),
42 page_link_domain_phishing_(features::kPageLinkDomain + 49 page_link_domain_phishing_(features::kPageLinkDomain +
43 std::string("phishing.com")), 50 std::string("phishing.com")),
44 page_term_login_(features::kPageTerm + std::string("login")) { 51 page_term_login_(features::kPageTerm + std::string("login")) {
45 } 52 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 model.add_page_term(3); 92 model.add_page_term(3);
86 model.set_murmur_hash_seed(2777808611U); 93 model.set_murmur_hash_seed(2777808611U);
87 model.add_page_word(MurmurHash3String("login", model.murmur_hash_seed())); 94 model.add_page_word(MurmurHash3String("login", model.murmur_hash_seed()));
88 model.set_max_words_per_term(1); 95 model.set_max_words_per_term(1);
89 96
90 clock_ = new MockFeatureExtractorClock; 97 clock_ = new MockFeatureExtractorClock;
91 scorer_.reset(Scorer::Create(model.SerializeAsString())); 98 scorer_.reset(Scorer::Create(model.SerializeAsString()));
92 ASSERT_TRUE(scorer_.get()); 99 ASSERT_TRUE(scorer_.get());
93 100
94 classifier_.reset(new PhishingClassifier( 101 classifier_.reset(new PhishingClassifier(
95 content::RenderView::FromRoutingID(1), 102 content::RenderView::FromRoutingID(kRenderViewRoutingId),
96 clock_)); 103 clock_));
97 } 104 }
98 105
99 virtual void TearDownOnMainThread() OVERRIDE { 106 virtual void TearDownOnMainThread() OVERRIDE {
100 content::RunAllPendingInMessageLoop(); 107 content::RunAllPendingInMessageLoop();
101 } 108 }
102 109
103 // Helper method to start phishing classification and wait for it to 110 // Helper method to start phishing classification and wait for it to
104 // complete. Returns the true if the page is classified as phishy and 111 // complete. Returns the true if the page is classified as phishy and
105 // false otherwise. 112 // false otherwise.
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 // Now set the scorer. 288 // Now set the scorer.
282 classifier_->set_phishing_scorer(scorer_.get()); 289 classifier_->set_phishing_scorer(scorer_.get());
283 EXPECT_TRUE(classifier_->is_ready()); 290 EXPECT_TRUE(classifier_->is_ready());
284 291
285 // Set a NULL scorer, which turns detection back off. 292 // Set a NULL scorer, which turns detection back off.
286 classifier_->set_phishing_scorer(NULL); 293 classifier_->set_phishing_scorer(NULL);
287 EXPECT_FALSE(classifier_->is_ready()); 294 EXPECT_FALSE(classifier_->is_ready());
288 } 295 }
289 296
290 } // namespace safe_browsing 297 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/safe_browsing/phishing_classifier_delegate_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698