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 "chrome/browser/safe_browsing/safe_browsing_service.h" | 9 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
10 | 10 |
(...skipping 1479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1490 EXPECT_TRUE(pref_service->GetBoolean(prefs::kSafeBrowsingEnabled)); | 1490 EXPECT_TRUE(pref_service->GetBoolean(prefs::kSafeBrowsingEnabled)); |
1491 | 1491 |
1492 // SBS might still be starting, make sure this doesn't flake. | 1492 // SBS might still be starting, make sure this doesn't flake. |
1493 EXPECT_TRUE(sb_service->enabled_by_prefs()); | 1493 EXPECT_TRUE(sb_service->enabled_by_prefs()); |
1494 WaitForIOAndCheckEnabled(sb_service, true); | 1494 WaitForIOAndCheckEnabled(sb_service, true); |
1495 EXPECT_TRUE(csd_service->enabled()); | 1495 EXPECT_TRUE(csd_service->enabled()); |
1496 | 1496 |
1497 // Add a new Profile. SBS should keep running. | 1497 // Add a new Profile. SBS should keep running. |
1498 ASSERT_TRUE(temp_profile_dir_.CreateUniqueTempDir()); | 1498 ASSERT_TRUE(temp_profile_dir_.CreateUniqueTempDir()); |
1499 std::unique_ptr<Profile> profile2(Profile::CreateProfile( | 1499 std::unique_ptr<Profile> profile2(Profile::CreateProfile( |
1500 temp_profile_dir_.path(), nullptr, Profile::CREATE_MODE_SYNCHRONOUS)); | 1500 temp_profile_dir_.GetPath(), nullptr, Profile::CREATE_MODE_SYNCHRONOUS)); |
1501 ASSERT_TRUE(profile2); | 1501 ASSERT_TRUE(profile2); |
1502 StartupTaskRunnerServiceFactory::GetForProfile(profile2.get())-> | 1502 StartupTaskRunnerServiceFactory::GetForProfile(profile2.get())-> |
1503 StartDeferredTaskRunners(); | 1503 StartDeferredTaskRunners(); |
1504 PrefService* pref_service2 = profile2->GetPrefs(); | 1504 PrefService* pref_service2 = profile2->GetPrefs(); |
1505 EXPECT_TRUE(pref_service2->GetBoolean(prefs::kSafeBrowsingEnabled)); | 1505 EXPECT_TRUE(pref_service2->GetBoolean(prefs::kSafeBrowsingEnabled)); |
1506 // We don't expect the state to have changed, but if it did, wait for it. | 1506 // We don't expect the state to have changed, but if it did, wait for it. |
1507 EXPECT_TRUE(sb_service->enabled_by_prefs()); | 1507 EXPECT_TRUE(sb_service->enabled_by_prefs()); |
1508 WaitForIOAndCheckEnabled(sb_service, true); | 1508 WaitForIOAndCheckEnabled(sb_service, true); |
1509 EXPECT_TRUE(csd_service->enabled()); | 1509 EXPECT_TRUE(csd_service->enabled()); |
1510 | 1510 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1589 // SBS might still be starting, make sure this doesn't flake. | 1589 // SBS might still be starting, make sure this doesn't flake. |
1590 WaitForIOThread(); | 1590 WaitForIOThread(); |
1591 EXPECT_EQ(1, TestProtocolManager::create_count()); | 1591 EXPECT_EQ(1, TestProtocolManager::create_count()); |
1592 EXPECT_EQ(0, TestProtocolManager::delete_count()); | 1592 EXPECT_EQ(0, TestProtocolManager::delete_count()); |
1593 | 1593 |
1594 // Create an additional profile. We need to use the ProfileManager so that | 1594 // Create an additional profile. We need to use the ProfileManager so that |
1595 // the profile will get destroyed in the normal browser shutdown process. | 1595 // the profile will get destroyed in the normal browser shutdown process. |
1596 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1596 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
1597 ASSERT_TRUE(temp_profile_dir_.CreateUniqueTempDir()); | 1597 ASSERT_TRUE(temp_profile_dir_.CreateUniqueTempDir()); |
1598 profile_manager->CreateProfileAsync( | 1598 profile_manager->CreateProfileAsync( |
1599 temp_profile_dir_.path(), | 1599 temp_profile_dir_.GetPath(), |
1600 base::Bind(&SafeBrowsingServiceShutdownTest::OnUnblockOnProfileCreation, | 1600 base::Bind(&SafeBrowsingServiceShutdownTest::OnUnblockOnProfileCreation, |
1601 base::Unretained(this)), | 1601 base::Unretained(this)), |
1602 base::string16(), std::string(), std::string()); | 1602 base::string16(), std::string(), std::string()); |
1603 | 1603 |
1604 // Spin to allow profile creation to take place, loop is terminated | 1604 // Spin to allow profile creation to take place, loop is terminated |
1605 // by OnUnblockOnProfileCreation when the profile is created. | 1605 // by OnUnblockOnProfileCreation when the profile is created. |
1606 content::RunMessageLoop(); | 1606 content::RunMessageLoop(); |
1607 | 1607 |
1608 PrefService* pref_service2 = profile2_->GetPrefs(); | 1608 PrefService* pref_service2 = profile2_->GetPrefs(); |
1609 EXPECT_TRUE(pref_service2->GetBoolean(prefs::kSafeBrowsingEnabled)); | 1609 EXPECT_TRUE(pref_service2->GetBoolean(prefs::kSafeBrowsingEnabled)); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1766 content::Source<SafeBrowsingDatabaseManager>( | 1766 content::Source<SafeBrowsingDatabaseManager>( |
1767 sb_factory_->test_safe_browsing_service()->database_manager().get())); | 1767 sb_factory_->test_safe_browsing_service()->database_manager().get())); |
1768 BrowserThread::PostTask( | 1768 BrowserThread::PostTask( |
1769 BrowserThread::IO, FROM_HERE, | 1769 BrowserThread::IO, FROM_HERE, |
1770 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, | 1770 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, |
1771 base::Unretained(this))); | 1771 base::Unretained(this))); |
1772 observer.Wait(); | 1772 observer.Wait(); |
1773 } | 1773 } |
1774 | 1774 |
1775 } // namespace safe_browsing | 1775 } // namespace safe_browsing |
OLD | NEW |