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 // 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 // blacklist. | 308 // blacklist. |
309 command_line->AppendSwitch(switches::kSbDisableExtensionBlacklist); | 309 command_line->AppendSwitch(switches::kSbDisableExtensionBlacklist); |
310 } | 310 } |
311 | 311 |
312 void SetTestStep(int step) { | 312 void SetTestStep(int step) { |
313 std::string test_step = base::StringPrintf("test_step=%d", step); | 313 std::string test_step = base::StringPrintf("test_step=%d", step); |
314 safe_browsing_service_->protocol_manager_->set_additional_query(test_step); | 314 safe_browsing_service_->protocol_manager_->set_additional_query(test_step); |
315 } | 315 } |
316 | 316 |
317 private: | 317 private: |
318 scoped_ptr<TestSafeBrowsingServiceFactory> sb_factory_; | 318 std::unique_ptr<TestSafeBrowsingServiceFactory> sb_factory_; |
319 | 319 |
320 SafeBrowsingService* safe_browsing_service_; | 320 SafeBrowsingService* safe_browsing_service_; |
321 | 321 |
322 scoped_ptr<net::SpawnedTestServer> test_server_; | 322 std::unique_ptr<net::SpawnedTestServer> test_server_; |
323 | 323 |
324 // Protects all variables below since they are read on UI thread | 324 // Protects all variables below since they are read on UI thread |
325 // but updated on IO thread or safebrowsing thread. | 325 // but updated on IO thread or safebrowsing thread. |
326 base::Lock update_status_mutex_; | 326 base::Lock update_status_mutex_; |
327 | 327 |
328 // States associated with safebrowsing service updates. | 328 // States associated with safebrowsing service updates. |
329 bool is_database_ready_; | 329 bool is_database_ready_; |
330 base::Time last_update_; | 330 base::Time last_update_; |
331 bool is_update_scheduled_; | 331 bool is_update_scheduled_; |
332 // Indicates if there is a match between a URL's prefix and safebrowsing | 332 // Indicates if there is a match between a URL's prefix and safebrowsing |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 url_fetcher_ = net::URLFetcher::Create(url, net::URLFetcher::GET, this); | 484 url_fetcher_ = net::URLFetcher::Create(url, net::URLFetcher::GET, this); |
485 url_fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); | 485 url_fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); |
486 url_fetcher_->SetRequestContext(request_context_); | 486 url_fetcher_->SetRequestContext(request_context_); |
487 url_fetcher_->Start(); | 487 url_fetcher_->Start(); |
488 content::RunMessageLoop(); | 488 content::RunMessageLoop(); |
489 return response_status_; | 489 return response_status_; |
490 } | 490 } |
491 | 491 |
492 base::OneShotTimer check_update_timer_; | 492 base::OneShotTimer check_update_timer_; |
493 SafeBrowsingServerTest* safe_browsing_test_; | 493 SafeBrowsingServerTest* safe_browsing_test_; |
494 scoped_ptr<net::URLFetcher> url_fetcher_; | 494 std::unique_ptr<net::URLFetcher> url_fetcher_; |
495 std::string response_data_; | 495 std::string response_data_; |
496 net::URLRequestStatus::Status response_status_; | 496 net::URLRequestStatus::Status response_status_; |
497 net::URLRequestContextGetter* request_context_; | 497 net::URLRequestContextGetter* request_context_; |
498 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServerTestHelper); | 498 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServerTestHelper); |
499 }; | 499 }; |
500 | 500 |
501 // TODO(shess): Disabled pending new data for third_party/safe_browsing/testing/ | 501 // TODO(shess): Disabled pending new data for third_party/safe_browsing/testing/ |
502 IN_PROC_BROWSER_TEST_F(SafeBrowsingServerTest, | 502 IN_PROC_BROWSER_TEST_F(SafeBrowsingServerTest, |
503 DISABLED_SafeBrowsingServerTest) { | 503 DISABLED_SafeBrowsingServerTest) { |
504 LOG(INFO) << "Start test"; | 504 LOG(INFO) << "Start test"; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 } | 582 } |
583 | 583 |
584 // Verifies with server if test is done and waits till server responses. | 584 // Verifies with server if test is done and waits till server responses. |
585 EXPECT_EQ(net::URLRequestStatus::SUCCESS, | 585 EXPECT_EQ(net::URLRequestStatus::SUCCESS, |
586 safe_browsing_helper->VerifyTestComplete(spawned_test_server(), | 586 safe_browsing_helper->VerifyTestComplete(spawned_test_server(), |
587 last_step)); | 587 last_step)); |
588 EXPECT_EQ("yes", safe_browsing_helper->response_data()); | 588 EXPECT_EQ("yes", safe_browsing_helper->response_data()); |
589 } | 589 } |
590 | 590 |
591 } // namespace safe_browsing | 591 } // namespace safe_browsing |
OLD | NEW |