#include "components/safe_browsing/core/browser/safe_browsing_metrics_collector.h"
#include <memory>
#include <optional>
#include <utility>
#include "base/base64.h"
#include "base/json/values_util.h"
#include "base/memory/scoped_refptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/task_environment.h"
#include "components/password_manager/core/common/password_manager_pref_names.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/testing_pref_service.h"
#include "components/safe_browsing/core/common/features.h"
#include "components/safe_browsing/core/common/safe_browsing_prefs.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace safe_browsing {
EventType;
UserState;
class SafeBrowsingMetricsCollectorTest : public ::testing::Test { … };
TEST_F(SafeBrowsingMetricsCollectorTest,
StartLogging_LastLoggingIntervalLongerThanScheduleInterval) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
StartLogging_LastLoggingIntervalShorterThanScheduleInterval) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
StartLogging_PrefChangeBetweenLogging) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
AddSafeBrowsingEventToPref_OldestTsRemoved) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
AddSafeBrowsingEventToPref_SafeBrowsingManaged) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
LogEnhancedProtectionDisabledMetrics_GetLastBypassEventType) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
LogEnhancedProtectionDisabledMetrics_GetLastSecuritySensitiveEventType) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
LogEnhancedProtectionDisabledMetrics_GetLastEnabledInterval) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
LogEnhancedProtectionDisabledMetrics_TimesDisabledLast28Days_Suffixes) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
LogEnhancedProtectionDisabledMetrics_TimesDisabledLast28Days_Resets) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
LogEnhancedProtectionDisabledMetrics_NotLoggedIfNoEvent) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
LogEnhancedProtectionDisabledMetrics_NotLoggedIfHitQuotaLimit) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
LogEnhancedProtectionDisabledMetrics_NotLoggedIfManaged) { … }
TEST_F(SafeBrowsingMetricsCollectorTest, LogDailyEventMetrics_LoggedDaily) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
LogDailyEventMetrics_DoesNotCountOldEvent) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
LogDailyEventMetrics_SwitchBetweenDifferentUserState) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
RemoveOldEventsFromPref_OldEventsRemoved) { … }
TEST_F(SafeBrowsingMetricsCollectorTest, GetUserState) { … }
TEST_F(SafeBrowsingMetricsCollectorTest, GetLatestEventTimestamp) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
GetLatestSecuritySensitiveEventTimestamp) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
ProtegoRequestIsNotLoggedWhenEsbIsNotEnabled) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
ProtegoRequestLogsNoneIfNotRecordedBeforeFirstRunOfCollector) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
ProtegoRequestLogsWithTokenWhenPingSincePreviousLogTime) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
ProtegoRequestLogsWithoutTokenWhenPingSincePreviousLogTime) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
ProtegoRequestLogsWithTokenWhenPingMoreRecentThanWithoutToken) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
ProtegoRequestLogsWithoutTokenWhenPingMoreRecentThanWithToken) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
ProtegoRequestLogsNoneWhenNoPingWithTokenSincePreviousLogTime) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
ProtegoRequestLogsNoneWhenNoPingWithoutTokenSincePreviousLogTime) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
ProtegoRequestLogsWithTokenWhenPingBeforeCollectorHasEverRun) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
ProtegoRequestLogsWithoutTokenWhenPingBeforeCollectorHasEverRun) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
NewProtegoRequestLogsWithTokenWhenWithTokenWasSendWithinLast24HRS) { … }
TEST_F(
SafeBrowsingMetricsCollectorTest,
NewProtegoRequestLogsWithoutTokenWhenWithoutTokenWasSendWithinLast24HRS) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
NewProtegoRequestLogsWithTokenWhenNoPingWasSendWithinLast24HRS) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
ProtegoRequestLogsWithTokenWhenWithTokenWasSentWithinLast7Days) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
ProtegoRequestLogsWithoutTokenWhenWithoutTokenWasSentWithinLast7Days) { … }
TEST_F(SafeBrowsingMetricsCollectorTest,
ProtegoRequestLogsNoneWhenNoPingWasSentWithinLast7Days) { … }
}