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 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 profile2.reset(); | 894 profile2.reset(); |
895 WaitForIOThread(); | 895 WaitForIOThread(); |
896 EXPECT_FALSE(sb_service->enabled()); | 896 EXPECT_FALSE(sb_service->enabled()); |
897 EXPECT_FALSE(csd_service->enabled()); | 897 EXPECT_FALSE(csd_service->enabled()); |
898 } | 898 } |
899 | 899 |
900 } // namespace | 900 } // namespace |
901 | 901 |
902 class SafeBrowsingServiceShutdownTest : public SafeBrowsingServiceTest { | 902 class SafeBrowsingServiceShutdownTest : public SafeBrowsingServiceTest { |
903 public: | 903 public: |
904 virtual void TearDown() override { | 904 void TearDown() override { |
905 // Browser should be fully torn down by now, so we can safely check these | 905 // Browser should be fully torn down by now, so we can safely check these |
906 // counters. | 906 // counters. |
907 EXPECT_EQ(1, TestProtocolManager::create_count()); | 907 EXPECT_EQ(1, TestProtocolManager::create_count()); |
908 EXPECT_EQ(1, TestProtocolManager::delete_count()); | 908 EXPECT_EQ(1, TestProtocolManager::delete_count()); |
909 | 909 |
910 SafeBrowsingServiceTest::TearDown(); | 910 SafeBrowsingServiceTest::TearDown(); |
911 } | 911 } |
912 | 912 |
913 // An observer that returns back to test code after a new profile is | 913 // An observer that returns back to test code after a new profile is |
914 // initialized. | 914 // initialized. |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 | 967 |
968 // End the test, shutting down the browser. | 968 // End the test, shutting down the browser. |
969 // SafeBrowsingServiceShutdownTest::TearDown will check the create_count and | 969 // SafeBrowsingServiceShutdownTest::TearDown will check the create_count and |
970 // delete_count again. | 970 // delete_count again. |
971 } | 971 } |
972 | 972 |
973 class SafeBrowsingDatabaseManagerCookieTest : public InProcessBrowserTest { | 973 class SafeBrowsingDatabaseManagerCookieTest : public InProcessBrowserTest { |
974 public: | 974 public: |
975 SafeBrowsingDatabaseManagerCookieTest() {} | 975 SafeBrowsingDatabaseManagerCookieTest() {} |
976 | 976 |
977 virtual void SetUp() override { | 977 void SetUp() override { |
978 // We need to start the test server to get the host&port in the url. | 978 // We need to start the test server to get the host&port in the url. |
979 ASSERT_TRUE(test_server()->Start()); | 979 ASSERT_TRUE(test_server()->Start()); |
980 | 980 |
981 // Point to the testing server for all SafeBrowsing requests. | 981 // Point to the testing server for all SafeBrowsing requests. |
982 GURL url_prefix = test_server()->GetURL( | 982 GURL url_prefix = test_server()->GetURL( |
983 "expect-and-set-cookie?expect=a%3db" | 983 "expect-and-set-cookie?expect=a%3db" |
984 "&set=c%3dd%3b%20Expires=Fri,%2001%20Jan%202038%2001:01:01%20GMT" | 984 "&set=c%3dd%3b%20Expires=Fri,%2001%20Jan%202038%2001:01:01%20GMT" |
985 "&data=foo#"); | 985 "&data=foo#"); |
986 sb_factory_.reset(new TestSafeBrowsingServiceFactory(url_prefix.spec())); | 986 sb_factory_.reset(new TestSafeBrowsingServiceFactory(url_prefix.spec())); |
987 SafeBrowsingService::RegisterFactory(sb_factory_.get()); | 987 SafeBrowsingService::RegisterFactory(sb_factory_.get()); |
988 | 988 |
989 InProcessBrowserTest::SetUp(); | 989 InProcessBrowserTest::SetUp(); |
990 } | 990 } |
991 | 991 |
992 virtual void TearDown() override { | 992 void TearDown() override { |
993 InProcessBrowserTest::TearDown(); | 993 InProcessBrowserTest::TearDown(); |
994 | 994 |
995 SafeBrowsingService::RegisterFactory(NULL); | 995 SafeBrowsingService::RegisterFactory(NULL); |
996 } | 996 } |
997 | 997 |
998 bool SetUpUserDataDirectory() override { | 998 bool SetUpUserDataDirectory() override { |
999 base::FilePath cookie_path( | 999 base::FilePath cookie_path( |
1000 SafeBrowsingService::GetCookieFilePathForTesting()); | 1000 SafeBrowsingService::GetCookieFilePathForTesting()); |
1001 EXPECT_FALSE(base::PathExists(cookie_path)); | 1001 EXPECT_FALSE(base::PathExists(cookie_path)); |
1002 | 1002 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 content::WindowedNotificationObserver observer( | 1089 content::WindowedNotificationObserver observer( |
1090 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, | 1090 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, |
1091 content::Source<SafeBrowsingDatabaseManager>( | 1091 content::Source<SafeBrowsingDatabaseManager>( |
1092 sb_service_->database_manager().get())); | 1092 sb_service_->database_manager().get())); |
1093 BrowserThread::PostTask( | 1093 BrowserThread::PostTask( |
1094 BrowserThread::IO, | 1094 BrowserThread::IO, |
1095 FROM_HERE, | 1095 FROM_HERE, |
1096 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); | 1096 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); |
1097 observer.Wait(); | 1097 observer.Wait(); |
1098 } | 1098 } |
OLD | NEW |