chromium/components/user_education/common/feature_promo_session_manager_unittest.cc

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

#include "components/user_education/common/feature_promo_session_manager.h"

#include <memory>
#include <optional>

#include "base/functional/callback_forward.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/test/simple_test_clock.h"
#include "base/time/time.h"
#include "components/user_education/common/feature_promo_data.h"
#include "components/user_education/common/feature_promo_idle_observer.h"
#include "components/user_education/common/feature_promo_idle_policy.h"
#include "components/user_education/test/feature_promo_session_mocks.h"
#include "components/user_education/test/test_feature_promo_storage_service.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/base/interaction/expect_call_in_scope.h"

namespace user_education {

// Base class that uses a test idle observer to test basic functionality of a
// FeaturePromoSessionManager.
class FeaturePromoSessionManagerTest : public testing::Test {};

TEST_F(FeaturePromoSessionManagerTest, CreateVanillaSessionManager) {}

TEST_F(FeaturePromoSessionManagerTest, CheckIdlePolicyDefaults) {}

TEST_F(FeaturePromoSessionManagerTest, CheckCallbackNoInitialSession) {}

TEST_F(FeaturePromoSessionManagerTest, CheckCallbackWithInitialSession) {}

TEST_F(FeaturePromoSessionManagerTest, CheckCallbackCalledOnNewSession) {}

// Base test for more advanced tests; provides the ability to simulate idle
// state updates and uses a test clock.
class FeaturePromoSessionManagerWithMockManagerTest
    : public FeaturePromoSessionManagerTest {};

// These tests ensure that the correct methods on IdlePolicy get called with the
// expected parameters.
class FeaturePromoSessionManagerWithMockPolicyTest
    : public FeaturePromoSessionManagerWithMockManagerTest {};

TEST_F(FeaturePromoSessionManagerWithMockPolicyTest,
       StartJustAfterLastActive_NoNewSession) {}

TEST_F(FeaturePromoSessionManagerWithMockPolicyTest,
       StartWellAfterLastActive_NewSession) {}

TEST_F(FeaturePromoSessionManagerWithMockPolicyTest,
       StartApplicationInactive_NoNewSession) {}

TEST_F(FeaturePromoSessionManagerWithMockPolicyTest, SystemInactiveNoUpdate) {}

TEST_F(FeaturePromoSessionManagerWithMockPolicyTest, NoNewSession) {}

TEST_F(FeaturePromoSessionManagerWithMockPolicyTest, NewSession) {}

// Class that tests the functionality of the IdlePolicy in conjunction with the
// FeaturePromoSessionManager.
class FeaturePromoIdlePolicyTest
    : public FeaturePromoSessionManagerWithMockManagerTest {};

TEST_F(FeaturePromoIdlePolicyTest, InitApplicationNotActive) {}

TEST_F(FeaturePromoIdlePolicyTest, InitApplicationActiveNoNewSession) {}

TEST_F(FeaturePromoIdlePolicyTest, InitApplicationActiveNewSession) {}

TEST_F(FeaturePromoIdlePolicyTest,
       StateUpdatedActiveNoNewSessionDueToMinimumSessionLength) {}

TEST_F(FeaturePromoIdlePolicyTest, StateUpdatedActiveNewSession) {}

TEST_F(FeaturePromoIdlePolicyTest, StateUpdatedInactiveNoNewSession) {}

TEST_F(FeaturePromoIdlePolicyTest,
       StateUpdatedInsideThenOutsideMinimumSession_NewSession) {}

TEST_F(FeaturePromoIdlePolicyTest,
       StateUpdatedInsideThenOutsideMinimumSession_NoNewSession) {}

// Regression test for a case where on some computers, returning from sleep and
// then leaving the locked state would first update the most recent active time,
// then fail to register the new session when the program became active, which
// meant some users would not experience any new sessions.
TEST_F(FeaturePromoIdlePolicyTest, ReturnFromLockedNewSession) {}

TEST_F(FeaturePromoIdlePolicyTest, ReturnFromLockedNoNewSession) {}

TEST_F(FeaturePromoIdlePolicyTest, MaybeUpdateSessionStateNoNewSession) {}

TEST_F(FeaturePromoIdlePolicyTest, MaybeUpdateSessionStateNewSession) {}

}  // namespace user_education