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 creates a safebrowsing service using test safebrowsing database | 5 // This test creates a safebrowsing service using test safebrowsing database |
6 // and a test protocol manager. It is used to test logics in safebrowsing | 6 // and a test protocol manager. It is used to test logics in safebrowsing |
7 // service. | 7 // service. |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 void TearDownOnMainThread() override { | 470 void TearDownOnMainThread() override { |
471 g_browser_process->safe_browsing_service()->ui_manager()->RemoveObserver( | 471 g_browser_process->safe_browsing_service()->ui_manager()->RemoveObserver( |
472 &observer_); | 472 &observer_); |
473 InProcessBrowserTest::TearDownOnMainThread(); | 473 InProcessBrowserTest::TearDownOnMainThread(); |
474 } | 474 } |
475 | 475 |
476 void SetUpInProcessBrowserTestFixture() override { | 476 void SetUpInProcessBrowserTestFixture() override { |
477 base::FilePath test_data_dir; | 477 base::FilePath test_data_dir; |
478 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); | 478 PathService::Get(chrome::DIR_TEST_DATA, &test_data_dir); |
479 embedded_test_server()->ServeFilesFromDirectory(test_data_dir); | 479 embedded_test_server()->ServeFilesFromDirectory(test_data_dir); |
480 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 480 ASSERT_TRUE(embedded_test_server()->Start()); |
481 } | 481 } |
482 | 482 |
483 // This will setup the "url" prefix in database and prepare protocol manager | 483 // This will setup the "url" prefix in database and prepare protocol manager |
484 // to respond with |full_hash|, as well as other |full_hash|es previously set | 484 // to respond with |full_hash|, as well as other |full_hash|es previously set |
485 // via this call, on GetFullHash requests. | 485 // via this call, on GetFullHash requests. |
486 void SetupResponseForUrl(const GURL& url, const SBFullHashResult& full_hash) { | 486 void SetupResponseForUrl(const GURL& url, const SBFullHashResult& full_hash) { |
487 std::vector<SBPrefix> prefix_hits; | 487 std::vector<SBPrefix> prefix_hits; |
488 prefix_hits.push_back(full_hash.hash.prefix); | 488 prefix_hits.push_back(full_hash.hash.prefix); |
489 | 489 |
490 // Make sure the full hits is empty unless we need to test the | 490 // Make sure the full hits is empty unless we need to test the |
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1197 // SafeBrowsingServiceShutdownTest::TearDown will check the create_count and | 1197 // SafeBrowsingServiceShutdownTest::TearDown will check the create_count and |
1198 // delete_count again. | 1198 // delete_count again. |
1199 } | 1199 } |
1200 | 1200 |
1201 class SafeBrowsingDatabaseManagerCookieTest : public InProcessBrowserTest { | 1201 class SafeBrowsingDatabaseManagerCookieTest : public InProcessBrowserTest { |
1202 public: | 1202 public: |
1203 SafeBrowsingDatabaseManagerCookieTest() {} | 1203 SafeBrowsingDatabaseManagerCookieTest() {} |
1204 | 1204 |
1205 void SetUp() override { | 1205 void SetUp() override { |
1206 // We need to start the test server to get the host&port in the url. | 1206 // We need to start the test server to get the host&port in the url. |
1207 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 1207 ASSERT_TRUE(embedded_test_server()->Start()); |
1208 embedded_test_server()->RegisterRequestHandler( | 1208 embedded_test_server()->RegisterRequestHandler( |
1209 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::HandleRequest)); | 1209 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::HandleRequest)); |
1210 | 1210 |
1211 // Point to the testing server for all SafeBrowsing requests. | 1211 // Point to the testing server for all SafeBrowsing requests. |
1212 GURL url_prefix = embedded_test_server()->GetURL("/testpath"); | 1212 GURL url_prefix = embedded_test_server()->GetURL("/testpath"); |
1213 sb_factory_.reset(new TestSafeBrowsingServiceFactory(url_prefix.spec())); | 1213 sb_factory_.reset(new TestSafeBrowsingServiceFactory(url_prefix.spec())); |
1214 SafeBrowsingService::RegisterFactory(sb_factory_.get()); | 1214 SafeBrowsingService::RegisterFactory(sb_factory_.get()); |
1215 | 1215 |
1216 InProcessBrowserTest::SetUp(); | 1216 InProcessBrowserTest::SetUp(); |
1217 } | 1217 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1353 content::WindowedNotificationObserver observer( | 1353 content::WindowedNotificationObserver observer( |
1354 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, | 1354 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, |
1355 content::Source<SafeBrowsingDatabaseManager>( | 1355 content::Source<SafeBrowsingDatabaseManager>( |
1356 sb_service_->database_manager().get())); | 1356 sb_service_->database_manager().get())); |
1357 BrowserThread::PostTask( | 1357 BrowserThread::PostTask( |
1358 BrowserThread::IO, | 1358 BrowserThread::IO, |
1359 FROM_HERE, | 1359 FROM_HERE, |
1360 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); | 1360 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); |
1361 observer.Wait(); | 1361 observer.Wait(); |
1362 } | 1362 } |
OLD | NEW |