chromium/chrome/browser/tpcd/experiment/experiment_manager_impl_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 "chrome/browser/tpcd/experiment/experiment_manager_impl.h"

#include "base/test/bind.h"
#include "base/test/mock_callback.h"
#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "build/buildflag.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/tpcd/experiment/tpcd_experiment_features.h"
#include "chrome/test/base/scoped_testing_local_state.h"
#include "chrome/test/base/testing_browser_process.h"
#include "chrome/test/base/testing_profile_manager.h"
#include "components/prefs/testing_pref_service.h"
#include "components/privacy_sandbox/tpcd_pref_names.h"
#include "components/privacy_sandbox/tpcd_utils.h"
#include "content/public/common/content_features.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chromeos/ash/components/browser_context_helper/browser_context_types.h"
#endif  // BUILDFLAG(IS_CHROMEOS_ASH)

namespace tpcd::experiment {
namespace {

class TestingExperimentManagerImpl : public ExperimentManagerImpl {};

InSequence;
Optional;

Checkpoint;

}  // namespace

class ExperimentManagerImplTestBase : public testing::Test {};

TEST_F(ExperimentManagerImplTestBase, Version) {}

TEST_F(ExperimentManagerImplTestBase, ForceEligibleForTesting) {}

class ExperimentManagerImplTest : public ExperimentManagerImplTestBase {};

TEST_F(ExperimentManagerImplTest,
       ExperimentManager_OneEligibleProfileCallSetsPrefEligible) {}

TEST_F(
    ExperimentManagerImplTest,
    ExperimentManager_OneIneligibleProfileCallSetsPrefIneligibleAndReturnsEarly) {}

TEST_F(
    ExperimentManagerImplTest,
    ExperimentManager_OneEligibleOneIneligibleProfileCallSetsPrefIneligible) {}

TEST_F(
    ExperimentManagerImplTest,
    ExperimentManager_OneIneligibleOneEligibleProfileCallSetsPrefIneligible) {}

TEST_F(ExperimentManagerImplTest,
       ExperimentManager_SetIneligibleAfterDecisionCallDoesNothing) {}

TEST_F(ExperimentManagerImplTest,
       ExperimentManager_SetEligibleAfterDecisionCallDoesNothing) {}

TEST_F(ExperimentManagerImplTest,
       ExperimentManager_PrefUnsetBeforeFinalDecisionIsMade) {}

TEST_F(ExperimentManagerImplTest, PrefIneligibleReturnsEarly) {}

TEST_F(ExperimentManagerImplTest, IsClientEligible_PrefIsEligibleReturnsTrue) {}

TEST_F(ExperimentManagerImplTest,
       IsClientEligible_PrefIsIneligibleReturnsFalse) {}

TEST_F(ExperimentManagerImplTest, IsClientEligible_PrefIsUnknownReturnsEmpty) {}

#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(ExperimentManagerImplTest, AshInternalProfile_NotCreated) {
  auto* internal_profile =
      profile_manager_.CreateTestingProfile(ash::kSigninBrowserContextBaseName);
  EXPECT_FALSE(ExperimentManagerImpl::GetForProfile(internal_profile));
}
#endif  // BUILDFLAG(IS_CHROMEOS_ASH)

// The parameter indicates whether to disable 3pcs.
class ExperimentManagerImplSyntheticTrialTest
    : public ExperimentManagerImplTestBase,
      public testing::WithParamInterface<bool> {};

TEST_P(ExperimentManagerImplSyntheticTrialTest, ProfileOnboardedSetsPref) {}

TEST_P(ExperimentManagerImplSyntheticTrialTest, CanRegister) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace tpcd::experiment