chromium/chrome/browser/ui/user_education/recent_session_policy_unittest.cc

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/user_education/recent_session_policy.h"

#include <sstream>
#include <vector>

#include "base/containers/map_util.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/field_trial_params.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "chrome/browser/user_education/browser_feature_promo_storage_service.h"
#include "chrome/browser/user_education/user_education_service.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace {

// Arbitrary date not too far from the current date.
// Use a time that will not be exactly midnight in any locale.
constexpr base::Time kNow =;

// Calculates a set of start times in terms of time before kNow.
// The most recent time will always be kNow; the other times are
// added after and should be in increasing order of time interval.
RecentSessionData CreateSessionData(
    const std::initializer_list<base::TimeDelta>& before_now,
    const std::optional<base::TimeDelta>& since_enabled = base::Days(30)) {}

Constraint;
ConstraintInfo;
ConstraintInfos;

constexpr char kTestHistogramName[] =;
constexpr char kTestHistogramName2[] =;

class MockConstraint : public Constraint {};

StrictMockConstraint;
StrictMockConstraintPtr;

// Creates a constraint info with a StrictMockConstraint, which is output via
// `constraint`. Callers will need to set any expectations on the mock.
ConstraintInfo CreateMockConstraintInfo(StrictMockConstraintPtr& constraint,
                                        std::string histogram_name,
                                        std::optional<int> histogram_max,
                                        std::optional<int> low_usage) {}

}  // namespace

class RecentSessionPolicyTest : public testing::Test {};

TEST_F(RecentSessionPolicyTest,
       ShouldEnableLowUsagePromoMode_SingleConstraint) {}

TEST_F(RecentSessionPolicyTest,
       ShouldEnableLowUsagePromoMode_MultipleConstraints) {}

TEST_F(RecentSessionPolicyTest,
       ShouldEnableLowUsagePromoMode_HistogramOnlyConstraint) {}

TEST_F(RecentSessionPolicyTest, RecordRecentUsageMetrics_SingleHistogram) {}

TEST_F(RecentSessionPolicyTest, RecordRecentUsageMetrics_TwoHistograms) {}

TEST_F(RecentSessionPolicyTest, SessionCountConstraint) {}

TEST_F(RecentSessionPolicyTest, ActiveDaysConstraint) {}

TEST_F(RecentSessionPolicyTest, ActiveWeeksConstraint) {}

TEST_F(RecentSessionPolicyTest, ActiveWeeksConstraintWithThreshold) {}

TEST_F(RecentSessionPolicyTest,
       ShouldEnableLowUsagePromoMode_OffWhenNotEnabledForLongEnough) {}

TEST_F(RecentSessionPolicyTest,
       ShouldEnableLowUsagePromoMode_OffMoreThanTwoActiveDays) {}

TEST_F(RecentSessionPolicyTest, RecordRecentUsageMetrics_LessThanOneWeek) {}

TEST_F(RecentSessionPolicyTest, RecordRecentUsageMetrics_MoreThanOneWeek) {}

TEST_F(RecentSessionPolicyTest, RecordRecentUsageMetrics_FullPeriod) {}

TEST_F(RecentSessionPolicyTest,
       RecordRecentUsageMetrics_SuperActiveCountsDaysNotSessions) {}

TEST_F(RecentSessionPolicyTest, RecordRecentUsageMetrics_DailyLimit) {}

class RecentSessionPolicyFinchTest : public RecentSessionPolicyTest {};

TEST_F(RecentSessionPolicyFinchTest, ChangeExistingThresholds) {}

TEST_F(RecentSessionPolicyFinchTest, SwitchToNewThresholds) {}

TEST_F(RecentSessionPolicyFinchTest, EnableSuperActiveThreshold) {}