OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "chrome/browser/safe_browsing/srt_fetcher_win.h" | 5 #include "chrome/browser/safe_browsing/srt_fetcher_win.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 #include <memory> | 8 #include <memory> |
9 #include <set> | 9 #include <set> |
10 | 10 |
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 // If we try again before the reporting period is up, it should not do | 538 // If we try again before the reporting period is up, it should not do |
539 // anything. | 539 // anything. |
540 TestReporterLaunchCycle({}); | 540 TestReporterLaunchCycle({}); |
541 | 541 |
542 // After enough time has passed, should try the queue again. | 542 // After enough time has passed, should try the queue again. |
543 SetDaysSinceLastReport(kDaysBetweenSuccessfulSwReporterRuns); | 543 SetDaysSinceLastReport(kDaysBetweenSuccessfulSwReporterRuns); |
544 TestReporterLaunchCycle({path1}); | 544 TestReporterLaunchCycle({path1}); |
545 } | 545 } |
546 } | 546 } |
547 | 547 |
548 IN_PROC_BROWSER_TEST_F(SRTFetcherTest, ReporterLogging_FeatureDisabled) { | |
549 exit_code_to_report_ = kSwReporterNothingFound; | |
550 base::test::ScopedFeatureList scoped_feature_list; | |
551 scoped_feature_list.InitAndDisableFeature( | |
552 kSwReporterExtendedSafeBrowsingFeature); | |
553 RunReporter(); | |
554 TestReporterLaunchCycle({base::FilePath()}); | |
555 ExpectLoggingSwitches({/*expect no switches*/}); | |
556 ExpectLastTimeSentReportNotSet(); | |
557 } | |
558 | |
559 IN_PROC_BROWSER_TEST_F(SRTFetcherTest, ReporterLogging_NoSBExtendedReporting) { | 548 IN_PROC_BROWSER_TEST_F(SRTFetcherTest, ReporterLogging_NoSBExtendedReporting) { |
560 exit_code_to_report_ = kSwReporterNothingFound; | 549 exit_code_to_report_ = kSwReporterNothingFound; |
561 base::test::ScopedFeatureList scoped_feature_list; | 550 base::test::ScopedFeatureList scoped_feature_list; |
562 scoped_feature_list.InitAndEnableFeature( | |
563 kSwReporterExtendedSafeBrowsingFeature); | |
564 RunReporter(); | 551 RunReporter(); |
565 TestReporterLaunchCycle({base::FilePath()}); | 552 TestReporterLaunchCycle({base::FilePath()}); |
566 ExpectLoggingSwitches({/*expect no switches*/}); | 553 ExpectLoggingSwitches({/*expect no switches*/}); |
567 ExpectLastTimeSentReportNotSet(); | 554 ExpectLastTimeSentReportNotSet(); |
568 } | 555 } |
569 | 556 |
570 IN_PROC_BROWSER_TEST_F(SRTFetcherTest, ReporterLogging_EnabledFirstRun) { | 557 IN_PROC_BROWSER_TEST_F(SRTFetcherTest, ReporterLogging_EnabledFirstRun) { |
571 exit_code_to_report_ = kSwReporterNothingFound; | 558 exit_code_to_report_ = kSwReporterNothingFound; |
572 base::test::ScopedFeatureList scoped_feature_list; | 559 base::test::ScopedFeatureList scoped_feature_list; |
573 scoped_feature_list.InitAndEnableFeature( | |
574 kSwReporterExtendedSafeBrowsingFeature); | |
575 EnableSBExtendedReporting(); | 560 EnableSBExtendedReporting(); |
576 // Note: don't set last time sent logs in the local state. | 561 // Note: don't set last time sent logs in the local state. |
577 // SBER is enabled and there is no record in the local state of the last time | 562 // SBER is enabled and there is no record in the local state of the last time |
578 // logs have been sent, so we should send logs in this run. | 563 // logs have been sent, so we should send logs in this run. |
579 RunReporter(); | 564 RunReporter(); |
580 TestReporterLaunchCycle({base::FilePath()}); | 565 TestReporterLaunchCycle({base::FilePath()}); |
581 ExpectLoggingSwitches(std::set<std::string>(std::begin(kExpectedSwitches), | 566 ExpectLoggingSwitches(std::set<std::string>(std::begin(kExpectedSwitches), |
582 std::end(kExpectedSwitches))); | 567 std::end(kExpectedSwitches))); |
583 ExpectLastReportSentInTheLastHour(); | 568 ExpectLastReportSentInTheLastHour(); |
584 } | 569 } |
585 | 570 |
586 IN_PROC_BROWSER_TEST_F(SRTFetcherTest, ReporterLogging_EnabledNoRecentLogging) { | 571 IN_PROC_BROWSER_TEST_F(SRTFetcherTest, ReporterLogging_EnabledNoRecentLogging) { |
587 exit_code_to_report_ = kSwReporterNothingFound; | 572 exit_code_to_report_ = kSwReporterNothingFound; |
588 base::test::ScopedFeatureList scoped_feature_list; | 573 base::test::ScopedFeatureList scoped_feature_list; |
589 scoped_feature_list.InitAndEnableFeature( | |
590 kSwReporterExtendedSafeBrowsingFeature); | |
591 // SBER is enabled and last time logs were sent was more than | 574 // SBER is enabled and last time logs were sent was more than |
592 // |kDaysBetweenReporterLogsSent| day ago, so we should send logs in this run. | 575 // |kDaysBetweenReporterLogsSent| day ago, so we should send logs in this run. |
593 EnableSBExtendedReporting(); | 576 EnableSBExtendedReporting(); |
594 SetLastTimeSentReport(kDaysBetweenReporterLogsSent + 3); | 577 SetLastTimeSentReport(kDaysBetweenReporterLogsSent + 3); |
595 RunReporter(); | 578 RunReporter(); |
596 TestReporterLaunchCycle({base::FilePath()}); | 579 TestReporterLaunchCycle({base::FilePath()}); |
597 ExpectLoggingSwitches(std::set<std::string>(std::begin(kExpectedSwitches), | 580 ExpectLoggingSwitches(std::set<std::string>(std::begin(kExpectedSwitches), |
598 std::end(kExpectedSwitches))); | 581 std::end(kExpectedSwitches))); |
599 ExpectLastReportSentInTheLastHour(); | 582 ExpectLastReportSentInTheLastHour(); |
600 } | 583 } |
601 | 584 |
602 IN_PROC_BROWSER_TEST_F(SRTFetcherTest, ReporterLogging_EnabledRecentlyLogged) { | 585 IN_PROC_BROWSER_TEST_F(SRTFetcherTest, ReporterLogging_EnabledRecentlyLogged) { |
603 exit_code_to_report_ = kSwReporterNothingFound; | 586 exit_code_to_report_ = kSwReporterNothingFound; |
604 base::test::ScopedFeatureList scoped_feature_list; | 587 base::test::ScopedFeatureList scoped_feature_list; |
605 scoped_feature_list.InitAndEnableFeature( | |
606 kSwReporterExtendedSafeBrowsingFeature); | |
607 // SBER is enabled, but logs have been sent less than | 588 // SBER is enabled, but logs have been sent less than |
608 // |kDaysBetweenReporterLogsSent| day ago, so we shouldn't send any logs in | 589 // |kDaysBetweenReporterLogsSent| day ago, so we shouldn't send any logs in |
609 // this run. | 590 // this run. |
610 EnableSBExtendedReporting(); | 591 EnableSBExtendedReporting(); |
611 SetLastTimeSentReport(kDaysBetweenReporterLogsSent - 1); | 592 SetLastTimeSentReport(kDaysBetweenReporterLogsSent - 1); |
612 int64_t last_time_sent_logs = GetLastTimeSentReport(); | 593 int64_t last_time_sent_logs = GetLastTimeSentReport(); |
613 RunReporter(); | 594 RunReporter(); |
614 TestReporterLaunchCycle({base::FilePath()}); | 595 TestReporterLaunchCycle({base::FilePath()}); |
615 ExpectLoggingSwitches(std::set<std::string>{/*expect no switches*/}); | 596 ExpectLoggingSwitches(std::set<std::string>{/*expect no switches*/}); |
616 EXPECT_EQ(last_time_sent_logs, GetLastTimeSentReport()); | 597 EXPECT_EQ(last_time_sent_logs, GetLastTimeSentReport()); |
617 } | 598 } |
618 | 599 |
619 } // namespace safe_browsing | 600 } // namespace safe_browsing |
OLD | NEW |