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 1486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1497 ASSERT_TRUE(pref_service); | 1497 ASSERT_TRUE(pref_service); |
1498 | 1498 |
1499 EXPECT_TRUE(pref_service->GetBoolean(prefs::kSafeBrowsingEnabled)); | 1499 EXPECT_TRUE(pref_service->GetBoolean(prefs::kSafeBrowsingEnabled)); |
1500 | 1500 |
1501 // SBS might still be starting, make sure this doesn't flake. | 1501 // SBS might still be starting, make sure this doesn't flake. |
1502 EXPECT_TRUE(sb_service->enabled_by_prefs()); | 1502 EXPECT_TRUE(sb_service->enabled_by_prefs()); |
1503 WaitForIOAndCheckEnabled(sb_service, true); | 1503 WaitForIOAndCheckEnabled(sb_service, true); |
1504 EXPECT_TRUE(csd_service->enabled()); | 1504 EXPECT_TRUE(csd_service->enabled()); |
1505 | 1505 |
1506 // Add a new Profile. SBS should keep running. | 1506 // Add a new Profile. SBS should keep running. |
| 1507 base::ThreadRestrictions::ScopedAllowIO allow_io; |
1507 ASSERT_TRUE(temp_profile_dir_.CreateUniqueTempDir()); | 1508 ASSERT_TRUE(temp_profile_dir_.CreateUniqueTempDir()); |
1508 std::unique_ptr<Profile> profile2(Profile::CreateProfile( | 1509 std::unique_ptr<Profile> profile2(Profile::CreateProfile( |
1509 temp_profile_dir_.GetPath(), nullptr, Profile::CREATE_MODE_SYNCHRONOUS)); | 1510 temp_profile_dir_.GetPath(), nullptr, Profile::CREATE_MODE_SYNCHRONOUS)); |
1510 ASSERT_TRUE(profile2); | 1511 ASSERT_TRUE(profile2); |
1511 StartupTaskRunnerServiceFactory::GetForProfile(profile2.get())-> | 1512 StartupTaskRunnerServiceFactory::GetForProfile(profile2.get())-> |
1512 StartDeferredTaskRunners(); | 1513 StartDeferredTaskRunners(); |
1513 PrefService* pref_service2 = profile2->GetPrefs(); | 1514 PrefService* pref_service2 = profile2->GetPrefs(); |
1514 EXPECT_TRUE(pref_service2->GetBoolean(prefs::kSafeBrowsingEnabled)); | 1515 EXPECT_TRUE(pref_service2->GetBoolean(prefs::kSafeBrowsingEnabled)); |
1515 // We don't expect the state to have changed, but if it did, wait for it. | 1516 // We don't expect the state to have changed, but if it did, wait for it. |
1516 EXPECT_TRUE(sb_service->enabled_by_prefs()); | 1517 EXPECT_TRUE(sb_service->enabled_by_prefs()); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1596 EXPECT_TRUE(pref_service->GetBoolean(prefs::kSafeBrowsingEnabled)); | 1597 EXPECT_TRUE(pref_service->GetBoolean(prefs::kSafeBrowsingEnabled)); |
1597 | 1598 |
1598 // SBS might still be starting, make sure this doesn't flake. | 1599 // SBS might still be starting, make sure this doesn't flake. |
1599 WaitForIOThread(); | 1600 WaitForIOThread(); |
1600 EXPECT_EQ(1, TestProtocolManager::create_count()); | 1601 EXPECT_EQ(1, TestProtocolManager::create_count()); |
1601 EXPECT_EQ(0, TestProtocolManager::delete_count()); | 1602 EXPECT_EQ(0, TestProtocolManager::delete_count()); |
1602 | 1603 |
1603 // Create an additional profile. We need to use the ProfileManager so that | 1604 // Create an additional profile. We need to use the ProfileManager so that |
1604 // the profile will get destroyed in the normal browser shutdown process. | 1605 // the profile will get destroyed in the normal browser shutdown process. |
1605 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1606 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
1606 ASSERT_TRUE(temp_profile_dir_.CreateUniqueTempDir()); | 1607 { |
| 1608 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 1609 ASSERT_TRUE(temp_profile_dir_.CreateUniqueTempDir()); |
| 1610 } |
1607 profile_manager->CreateProfileAsync( | 1611 profile_manager->CreateProfileAsync( |
1608 temp_profile_dir_.GetPath(), | 1612 temp_profile_dir_.GetPath(), |
1609 base::Bind(&SafeBrowsingServiceShutdownTest::OnUnblockOnProfileCreation, | 1613 base::Bind(&SafeBrowsingServiceShutdownTest::OnUnblockOnProfileCreation, |
1610 base::Unretained(this)), | 1614 base::Unretained(this)), |
1611 base::string16(), std::string(), std::string()); | 1615 base::string16(), std::string(), std::string()); |
1612 | 1616 |
1613 // Spin to allow profile creation to take place, loop is terminated | 1617 // Spin to allow profile creation to take place, loop is terminated |
1614 // by OnUnblockOnProfileCreation when the profile is created. | 1618 // by OnUnblockOnProfileCreation when the profile is created. |
1615 content::RunMessageLoop(); | 1619 content::RunMessageLoop(); |
1616 | 1620 |
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2489 } | 2493 } |
2490 | 2494 |
2491 INSTANTIATE_TEST_CASE_P( | 2495 INSTANTIATE_TEST_CASE_P( |
2492 MaybeSetMetadata, | 2496 MaybeSetMetadata, |
2493 V4SafeBrowsingServiceMetadataTest, | 2497 V4SafeBrowsingServiceMetadataTest, |
2494 testing::Values(ThreatPatternType::NONE, | 2498 testing::Values(ThreatPatternType::NONE, |
2495 ThreatPatternType::MALWARE_LANDING, | 2499 ThreatPatternType::MALWARE_LANDING, |
2496 ThreatPatternType::MALWARE_DISTRIBUTION)); | 2500 ThreatPatternType::MALWARE_DISTRIBUTION)); |
2497 | 2501 |
2498 } // namespace safe_browsing | 2502 } // namespace safe_browsing |
OLD | NEW |