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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_test.cc

Issue 629603002: replace OVERRIDE and FINAL with override and final in chrome/browser/[r-z]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master Created 6 years, 2 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 (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 // This test uses the safebrowsing test server published at 5 // This test uses the safebrowsing test server published at
6 // http://code.google.com/p/google-safe-browsing/ to test the safebrowsing 6 // http://code.google.com/p/google-safe-browsing/ to test the safebrowsing
7 // protocol implemetation. Details of the safebrowsing testing flow is 7 // protocol implemetation. Details of the safebrowsing testing flow is
8 // documented at 8 // documented at
9 // http://code.google.com/p/google-safe-browsing/wiki/ProtocolTesting 9 // http://code.google.com/p/google-safe-browsing/wiki/ProtocolTesting
10 // 10 //
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 phishing_urls->push_back(phishing_url); 105 phishing_urls->push_back(phishing_url);
106 } 106 }
107 return true; 107 return true;
108 } 108 }
109 109
110 class FakeSafeBrowsingService : public SafeBrowsingService { 110 class FakeSafeBrowsingService : public SafeBrowsingService {
111 public: 111 public:
112 explicit FakeSafeBrowsingService(const std::string& url_prefix) 112 explicit FakeSafeBrowsingService(const std::string& url_prefix)
113 : url_prefix_(url_prefix) {} 113 : url_prefix_(url_prefix) {}
114 114
115 virtual SafeBrowsingProtocolConfig GetProtocolConfig() const OVERRIDE { 115 virtual SafeBrowsingProtocolConfig GetProtocolConfig() const override {
116 SafeBrowsingProtocolConfig config; 116 SafeBrowsingProtocolConfig config;
117 config.url_prefix = url_prefix_; 117 config.url_prefix = url_prefix_;
118 // Makes sure the auto update is not triggered. The tests will force the 118 // Makes sure the auto update is not triggered. The tests will force the
119 // update when needed. 119 // update when needed.
120 config.disable_auto_update = true; 120 config.disable_auto_update = true;
121 #if defined(OS_ANDROID) 121 #if defined(OS_ANDROID)
122 config.disable_connection_check = true; 122 config.disable_connection_check = true;
123 #endif 123 #endif
124 config.client_name = "browser_tests"; 124 config.client_name = "browser_tests";
125 return config; 125 return config;
126 } 126 }
127 127
128 private: 128 private:
129 virtual ~FakeSafeBrowsingService() {} 129 virtual ~FakeSafeBrowsingService() {}
130 130
131 std::string url_prefix_; 131 std::string url_prefix_;
132 132
133 DISALLOW_COPY_AND_ASSIGN(FakeSafeBrowsingService); 133 DISALLOW_COPY_AND_ASSIGN(FakeSafeBrowsingService);
134 }; 134 };
135 135
136 // Factory that creates FakeSafeBrowsingService instances. 136 // Factory that creates FakeSafeBrowsingService instances.
137 class TestSafeBrowsingServiceFactory : public SafeBrowsingServiceFactory { 137 class TestSafeBrowsingServiceFactory : public SafeBrowsingServiceFactory {
138 public: 138 public:
139 explicit TestSafeBrowsingServiceFactory(const std::string& url_prefix) 139 explicit TestSafeBrowsingServiceFactory(const std::string& url_prefix)
140 : url_prefix_(url_prefix) {} 140 : url_prefix_(url_prefix) {}
141 141
142 virtual SafeBrowsingService* CreateSafeBrowsingService() OVERRIDE { 142 virtual SafeBrowsingService* CreateSafeBrowsingService() override {
143 return new FakeSafeBrowsingService(url_prefix_); 143 return new FakeSafeBrowsingService(url_prefix_);
144 } 144 }
145 145
146 private: 146 private:
147 std::string url_prefix_; 147 std::string url_prefix_;
148 }; 148 };
149 149
150 } // namespace 150 } // namespace
151 151
152 // This starts the browser and keeps status of states related to SafeBrowsing. 152 // This starts the browser and keeps status of states related to SafeBrowsing.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 const net::SpawnedTestServer& test_server() const { 248 const net::SpawnedTestServer& test_server() const {
249 return *test_server_; 249 return *test_server_;
250 } 250 }
251 251
252 protected: 252 protected:
253 bool InitSafeBrowsingService() { 253 bool InitSafeBrowsingService() {
254 safe_browsing_service_ = g_browser_process->safe_browsing_service(); 254 safe_browsing_service_ = g_browser_process->safe_browsing_service();
255 return safe_browsing_service_ != NULL; 255 return safe_browsing_service_ != NULL;
256 } 256 }
257 257
258 virtual void SetUp() OVERRIDE { 258 virtual void SetUp() override {
259 base::FilePath datafile_path; 259 base::FilePath datafile_path;
260 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &datafile_path)); 260 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &datafile_path));
261 261
262 datafile_path = datafile_path.Append(FILE_PATH_LITERAL("third_party")) 262 datafile_path = datafile_path.Append(FILE_PATH_LITERAL("third_party"))
263 .Append(FILE_PATH_LITERAL("safe_browsing")) 263 .Append(FILE_PATH_LITERAL("safe_browsing"))
264 .Append(FILE_PATH_LITERAL("testing")) 264 .Append(FILE_PATH_LITERAL("testing"))
265 .Append(kDataFile); 265 .Append(kDataFile);
266 test_server_.reset(new LocalSafeBrowsingTestServer(datafile_path)); 266 test_server_.reset(new LocalSafeBrowsingTestServer(datafile_path));
267 ASSERT_TRUE(test_server_->Start()); 267 ASSERT_TRUE(test_server_->Start());
268 LOG(INFO) << "server is " << test_server_->host_port_pair().ToString(); 268 LOG(INFO) << "server is " << test_server_->host_port_pair().ToString();
269 269
270 // Point to the testing server for all SafeBrowsing requests. 270 // Point to the testing server for all SafeBrowsing requests.
271 std::string url_prefix = test_server_->GetURL("safebrowsing").spec(); 271 std::string url_prefix = test_server_->GetURL("safebrowsing").spec();
272 sb_factory_.reset(new TestSafeBrowsingServiceFactory(url_prefix)); 272 sb_factory_.reset(new TestSafeBrowsingServiceFactory(url_prefix));
273 SafeBrowsingService::RegisterFactory(sb_factory_.get()); 273 SafeBrowsingService::RegisterFactory(sb_factory_.get());
274 274
275 InProcessBrowserTest::SetUp(); 275 InProcessBrowserTest::SetUp();
276 } 276 }
277 277
278 virtual void TearDown() OVERRIDE { 278 virtual void TearDown() override {
279 InProcessBrowserTest::TearDown(); 279 InProcessBrowserTest::TearDown();
280 280
281 SafeBrowsingService::RegisterFactory(NULL); 281 SafeBrowsingService::RegisterFactory(NULL);
282 } 282 }
283 283
284 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 284 virtual void SetUpCommandLine(CommandLine* command_line) override {
285 // This test uses loopback. No need to use IPv6 especially it makes 285 // This test uses loopback. No need to use IPv6 especially it makes
286 // local requests slow on Windows trybot when ipv6 local address [::1] 286 // local requests slow on Windows trybot when ipv6 local address [::1]
287 // is not setup. 287 // is not setup.
288 command_line->AppendSwitch(switches::kDisableIPv6); 288 command_line->AppendSwitch(switches::kDisableIPv6);
289 289
290 // TODO(lzheng): The test server does not understand download related 290 // TODO(lzheng): The test server does not understand download related
291 // requests. We need to fix the server. 291 // requests. We need to fix the server.
292 command_line->AppendSwitch(switches::kSbDisableDownloadProtection); 292 command_line->AppendSwitch(switches::kSbDisableDownloadProtection);
293 293
294 // TODO(gcasto): Generate new testing data that includes the 294 // TODO(gcasto): Generate new testing data that includes the
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 SafeBrowsingServerTestHelper(SafeBrowsingServerTest* safe_browsing_test, 344 SafeBrowsingServerTestHelper(SafeBrowsingServerTest* safe_browsing_test,
345 net::URLRequestContextGetter* request_context) 345 net::URLRequestContextGetter* request_context)
346 : safe_browsing_test_(safe_browsing_test), 346 : safe_browsing_test_(safe_browsing_test),
347 response_status_(net::URLRequestStatus::FAILED), 347 response_status_(net::URLRequestStatus::FAILED),
348 request_context_(request_context) { 348 request_context_(request_context) {
349 } 349 }
350 350
351 // Callbacks for SafeBrowsingDatabaseManager::Client. 351 // Callbacks for SafeBrowsingDatabaseManager::Client.
352 virtual void OnCheckBrowseUrlResult(const GURL& url, 352 virtual void OnCheckBrowseUrlResult(const GURL& url,
353 SBThreatType threat_type, 353 SBThreatType threat_type,
354 const std::string& metadata) OVERRIDE { 354 const std::string& metadata) override {
355 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); 355 EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
356 EXPECT_TRUE(safe_browsing_test_->is_checked_url_in_db()); 356 EXPECT_TRUE(safe_browsing_test_->is_checked_url_in_db());
357 safe_browsing_test_->set_is_checked_url_safe( 357 safe_browsing_test_->set_is_checked_url_safe(
358 threat_type == SB_THREAT_TYPE_SAFE); 358 threat_type == SB_THREAT_TYPE_SAFE);
359 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, 359 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
360 base::Bind(&SafeBrowsingServerTestHelper::OnCheckUrlDone, this)); 360 base::Bind(&SafeBrowsingServerTestHelper::OnCheckUrlDone, this));
361 } 361 }
362 362
363 virtual void OnBlockingPageComplete(bool proceed) { 363 virtual void OnBlockingPageComplete(bool proceed) {
364 NOTREACHED() << "Not implemented."; 364 NOTREACHED() << "Not implemented.";
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 // this verification will fail. 446 // this verification will fail.
447 net::URLRequestStatus::Status VerifyTestComplete( 447 net::URLRequestStatus::Status VerifyTestComplete(
448 const net::SpawnedTestServer& test_server, 448 const net::SpawnedTestServer& test_server,
449 int test_step) { 449 int test_step) {
450 std::string path = base::StringPrintf( 450 std::string path = base::StringPrintf(
451 "%s?test_step=%d", kTestCompletePath, test_step); 451 "%s?test_step=%d", kTestCompletePath, test_step);
452 return FetchUrl(test_server.GetURL(path)); 452 return FetchUrl(test_server.GetURL(path));
453 } 453 }
454 454
455 // Callback for URLFetcher. 455 // Callback for URLFetcher.
456 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE { 456 virtual void OnURLFetchComplete(const net::URLFetcher* source) override {
457 source->GetResponseAsString(&response_data_); 457 source->GetResponseAsString(&response_data_);
458 response_status_ = source->GetStatus().status(); 458 response_status_ = source->GetStatus().status();
459 StopUILoop(); 459 StopUILoop();
460 } 460 }
461 461
462 const std::string& response_data() { 462 const std::string& response_data() {
463 return response_data_; 463 return response_data_;
464 } 464 }
465 465
466 private: 466 private:
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 safe_browsing_helper->FetchDBToVerify(test_server(), step)); 573 safe_browsing_helper->FetchDBToVerify(test_server(), step));
574 EXPECT_GT(safe_browsing_helper->response_data().size(), 0U); 574 EXPECT_GT(safe_browsing_helper->response_data().size(), 0U);
575 last_step = step; 575 last_step = step;
576 } 576 }
577 577
578 // Verifies with server if test is done and waits till server responses. 578 // Verifies with server if test is done and waits till server responses.
579 EXPECT_EQ(net::URLRequestStatus::SUCCESS, 579 EXPECT_EQ(net::URLRequestStatus::SUCCESS,
580 safe_browsing_helper->VerifyTestComplete(test_server(), last_step)); 580 safe_browsing_helper->VerifyTestComplete(test_server(), last_step));
581 EXPECT_EQ("yes", safe_browsing_helper->response_data()); 581 EXPECT_EQ("yes", safe_browsing_helper->response_data());
582 } 582 }
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_store_file.h ('k') | chrome/browser/safe_browsing/sandboxed_zip_analyzer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698