Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_service_browsertest.cc

Issue 10700100: Remove debug logging for SafeBrowsingServiceTest.StartAndStop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 sb_service->download_urlcheck_timeout_ms_ = ms; 392 sb_service->download_urlcheck_timeout_ms_ = ms;
393 } 393 }
394 394
395 void SetDownloadHashCheckTimeout(SafeBrowsingService* sb_service, int64 ms) { 395 void SetDownloadHashCheckTimeout(SafeBrowsingService* sb_service, int64 ms) {
396 sb_service->download_hashcheck_timeout_ms_ = ms; 396 sb_service->download_hashcheck_timeout_ms_ = ms;
397 } 397 }
398 398
399 void CreateCSDService() { 399 void CreateCSDService() {
400 safe_browsing::ClientSideDetectionService* csd_service = 400 safe_browsing::ClientSideDetectionService* csd_service =
401 safe_browsing::ClientSideDetectionService::Create(NULL); 401 safe_browsing::ClientSideDetectionService::Create(NULL);
402 LOG(INFO) << "CSDS created";
403 SafeBrowsingService* sb_service = 402 SafeBrowsingService* sb_service =
404 g_browser_process->safe_browsing_service(); 403 g_browser_process->safe_browsing_service();
405 sb_service->csd_service_.reset(csd_service); 404 sb_service->csd_service_.reset(csd_service);
406 LOG(INFO) << "refreshing..";
407 sb_service->RefreshState(); 405 sb_service->RefreshState();
408 LOG(INFO) << "refreshed";
409 } 406 }
410 407
411 protected: 408 protected:
412 StrictMock<MockObserver> observer_; 409 StrictMock<MockObserver> observer_;
413 410
414 // Temporary profile dir for test cases that create a second profile. This is 411 // Temporary profile dir for test cases that create a second profile. This is
415 // owned by the SafeBrowsingServiceTest object so that it will not get 412 // owned by the SafeBrowsingServiceTest object so that it will not get
416 // destructed until after the test Browser has been torn down, since the 413 // destructed until after the test Browser has been torn down, since the
417 // ImportantFileWriter may still be modifying it after the Profile object has 414 // ImportantFileWriter may still be modifying it after the Profile object has
418 // been destroyed. 415 // been destroyed.
419 ScopedTempDir temp_profile_dir_; 416 ScopedTempDir temp_profile_dir_;
420 417
421 // Waits for pending tasks on the IO thread to complete. This is useful 418 // Waits for pending tasks on the IO thread to complete. This is useful
422 // to wait for the SafeBrowsingService to finish loading/stopping. 419 // to wait for the SafeBrowsingService to finish loading/stopping.
423 void WaitForIOThread() { 420 void WaitForIOThread() {
424 LOG(INFO) << "waiting for io thread";
425 scoped_refptr<base::ThreadTestHelper> io_helper(new base::ThreadTestHelper( 421 scoped_refptr<base::ThreadTestHelper> io_helper(new base::ThreadTestHelper(
426 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); 422 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)));
427 ASSERT_TRUE(io_helper->Run()); 423 ASSERT_TRUE(io_helper->Run());
428 LOG(INFO) << "done waiting";
429 } 424 }
430 425
431 private: 426 private:
432 TestSafeBrowsingDatabaseFactory db_factory_; 427 TestSafeBrowsingDatabaseFactory db_factory_;
433 TestSBProtocolManagerFactory pm_factory_; 428 TestSBProtocolManagerFactory pm_factory_;
434 429
435 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceTest); 430 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingServiceTest);
436 }; 431 };
437 432
438 namespace { 433 namespace {
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 client->CheckDownloadHash(full_hash); 707 client->CheckDownloadHash(full_hash);
713 708
714 // There should be a timeout and the hash would be considered as safe. 709 // There should be a timeout and the hash would be considered as safe.
715 EXPECT_EQ(SafeBrowsingService::SAFE, client->GetResult()); 710 EXPECT_EQ(SafeBrowsingService::SAFE, client->GetResult());
716 711
717 // Need to set the timeout back to the default value. 712 // Need to set the timeout back to the default value.
718 SetDownloadHashCheckTimeout(sb_service, default_hashcheck_timeout); 713 SetDownloadHashCheckTimeout(sb_service, default_hashcheck_timeout);
719 } 714 }
720 715
721 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, StartAndStop) { 716 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceTest, StartAndStop) {
722 LOG(INFO) << __FUNCTION__;
723 CreateCSDService(); 717 CreateCSDService();
724 SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service(); 718 SafeBrowsingService* sb_service = g_browser_process->safe_browsing_service();
725 safe_browsing::ClientSideDetectionService* csd_service = 719 safe_browsing::ClientSideDetectionService* csd_service =
726 sb_service->safe_browsing_detection_service(); 720 sb_service->safe_browsing_detection_service();
727 LOG(INFO) << "get prefs";
728 PrefService* pref_service = browser()->profile()->GetPrefs(); 721 PrefService* pref_service = browser()->profile()->GetPrefs();
729 722
730 ASSERT_TRUE(sb_service != NULL); 723 ASSERT_TRUE(sb_service != NULL);
731 ASSERT_TRUE(csd_service != NULL); 724 ASSERT_TRUE(csd_service != NULL);
732 ASSERT_TRUE(pref_service != NULL); 725 ASSERT_TRUE(pref_service != NULL);
733 726
734 LOG(INFO) << "checking pref";
735 EXPECT_TRUE(pref_service->GetBoolean(prefs::kSafeBrowsingEnabled)); 727 EXPECT_TRUE(pref_service->GetBoolean(prefs::kSafeBrowsingEnabled));
736 728
737 // SBS might still be starting, make sure this doesn't flake. 729 // SBS might still be starting, make sure this doesn't flake.
738 WaitForIOThread(); 730 WaitForIOThread();
739 EXPECT_TRUE(sb_service->enabled()); 731 EXPECT_TRUE(sb_service->enabled());
740 EXPECT_TRUE(csd_service->enabled()); 732 EXPECT_TRUE(csd_service->enabled());
741 733
742 // Add a new Profile. SBS should keep running. 734 // Add a new Profile. SBS should keep running.
743 LOG(INFO) << "creating ScopedTempDir";
744 ASSERT_TRUE(temp_profile_dir_.CreateUniqueTempDir()); 735 ASSERT_TRUE(temp_profile_dir_.CreateUniqueTempDir());
745 LOG(INFO) << "created " << temp_profile_dir_.path().LossyDisplayName();
746 LOG(INFO) << "creating profile2";
747 scoped_ptr<Profile> profile2(Profile::CreateProfile( 736 scoped_ptr<Profile> profile2(Profile::CreateProfile(
748 temp_profile_dir_.path(), NULL, Profile::CREATE_MODE_SYNCHRONOUS)); 737 temp_profile_dir_.path(), NULL, Profile::CREATE_MODE_SYNCHRONOUS));
749 ASSERT_TRUE(profile2.get() != NULL); 738 ASSERT_TRUE(profile2.get() != NULL);
750 LOG(INFO) << "get prefs2";
751 PrefService* pref_service2 = profile2->GetPrefs(); 739 PrefService* pref_service2 = profile2->GetPrefs();
752 LOG(INFO) << "checking pref2";
753 EXPECT_TRUE(pref_service2->GetBoolean(prefs::kSafeBrowsingEnabled)); 740 EXPECT_TRUE(pref_service2->GetBoolean(prefs::kSafeBrowsingEnabled));
754 // We don't expect the state to have changed, but if it did, wait for it. 741 // We don't expect the state to have changed, but if it did, wait for it.
755 WaitForIOThread(); 742 WaitForIOThread();
756 EXPECT_TRUE(sb_service->enabled()); 743 EXPECT_TRUE(sb_service->enabled());
757 EXPECT_TRUE(csd_service->enabled()); 744 EXPECT_TRUE(csd_service->enabled());
758 745
759 LOG(INFO) << "setting pref";
760 // Change one of the prefs. SBS should keep running. 746 // Change one of the prefs. SBS should keep running.
761 pref_service->SetBoolean(prefs::kSafeBrowsingEnabled, false); 747 pref_service->SetBoolean(prefs::kSafeBrowsingEnabled, false);
762 WaitForIOThread(); 748 WaitForIOThread();
763 EXPECT_TRUE(sb_service->enabled()); 749 EXPECT_TRUE(sb_service->enabled());
764 EXPECT_TRUE(csd_service->enabled()); 750 EXPECT_TRUE(csd_service->enabled());
765 751
766 LOG(INFO) << "setting pref2";
767 // Change the other pref. SBS should stop now. 752 // Change the other pref. SBS should stop now.
768 pref_service2->SetBoolean(prefs::kSafeBrowsingEnabled, false); 753 pref_service2->SetBoolean(prefs::kSafeBrowsingEnabled, false);
769 WaitForIOThread(); 754 WaitForIOThread();
770 EXPECT_FALSE(sb_service->enabled()); 755 EXPECT_FALSE(sb_service->enabled());
771 EXPECT_FALSE(csd_service->enabled()); 756 EXPECT_FALSE(csd_service->enabled());
772 757
773 LOG(INFO) << "setting pref2";
774 // Turn it back on. SBS comes back. 758 // Turn it back on. SBS comes back.
775 pref_service2->SetBoolean(prefs::kSafeBrowsingEnabled, true); 759 pref_service2->SetBoolean(prefs::kSafeBrowsingEnabled, true);
776 WaitForIOThread(); 760 WaitForIOThread();
777 EXPECT_TRUE(sb_service->enabled()); 761 EXPECT_TRUE(sb_service->enabled());
778 EXPECT_TRUE(csd_service->enabled()); 762 EXPECT_TRUE(csd_service->enabled());
779 763
780 LOG(INFO) << "deleting profile2";
781 // Delete the Profile. SBS stops again. 764 // Delete the Profile. SBS stops again.
782 pref_service2 = NULL; 765 pref_service2 = NULL;
783 profile2.reset(); 766 profile2.reset();
784 WaitForIOThread(); 767 WaitForIOThread();
785 EXPECT_FALSE(sb_service->enabled()); 768 EXPECT_FALSE(sb_service->enabled());
786 EXPECT_FALSE(csd_service->enabled()); 769 EXPECT_FALSE(csd_service->enabled());
787 LOG(INFO) << __FUNCTION__ << " done";
788 } 770 }
789 771
790 } // namespace 772 } // namespace
791 773
792 class SafeBrowsingServiceCookieTest : public InProcessBrowserTest { 774 class SafeBrowsingServiceCookieTest : public InProcessBrowserTest {
793 public: 775 public:
794 SafeBrowsingServiceCookieTest() {} 776 SafeBrowsingServiceCookieTest() {}
795 777
796 virtual void SetUpCommandLine(CommandLine* command_line) { 778 virtual void SetUpCommandLine(CommandLine* command_line) {
797 InProcessBrowserTest::SetUpCommandLine(command_line); 779 InProcessBrowserTest::SetUpCommandLine(command_line);
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 // save cookies. 881 // save cookies.
900 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceCookieTest, TestSBUpdateCookies) { 882 IN_PROC_BROWSER_TEST_F(SafeBrowsingServiceCookieTest, TestSBUpdateCookies) {
901 ui_test_utils::WindowedNotificationObserver observer( 883 ui_test_utils::WindowedNotificationObserver observer(
902 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, 884 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE,
903 content::Source<SafeBrowsingService>(sb_service_.get())); 885 content::Source<SafeBrowsingService>(sb_service_.get()));
904 BrowserThread::PostTask( 886 BrowserThread::PostTask(
905 BrowserThread::IO, FROM_HERE, 887 BrowserThread::IO, FROM_HERE,
906 base::Bind(&SafeBrowsingServiceCookieTest::ForceUpdate, this)); 888 base::Bind(&SafeBrowsingServiceCookieTest::ForceUpdate, this));
907 observer.Wait(); 889 observer.Wait();
908 } 890 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698