chromium/chrome/browser/privacy_sandbox/privacy_sandbox_settings_delegate_unittest.cc

// Copyright 2022 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/privacy_sandbox/privacy_sandbox_settings_delegate.h"

#include <stddef.h>

#include <memory>
#include <optional>
#include <string>
#include <vector>

#include "base/test/scoped_feature_list.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/buildflag.h"
#include "chrome/browser/content_settings/cookie_settings_factory.h"
#include "chrome/browser/privacy_sandbox/tracking_protection_onboarding_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_test_environment_profile_adaptor.h"
#include "chrome/browser/supervised_user/supervised_user_test_util.h"
#include "chrome/browser/tpcd/experiment/mock_experiment_manager.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.h"
#include "components/content_settings/core/browser/cookie_settings.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/pref_names.h"
#include "components/metrics/metrics_pref_names.h"
#include "components/privacy_sandbox/privacy_sandbox_features.h"
#include "components/privacy_sandbox/privacy_sandbox_prefs.h"
#include "components/privacy_sandbox/tpcd_experiment_eligibility.h"
#include "components/privacy_sandbox/tracking_protection_onboarding.h"
#include "components/privacy_sandbox/tracking_protection_prefs.h"
#include "components/signin/public/identity_manager/account_capabilities_test_mutator.h"
#include "components/signin/public/identity_manager/identity_test_environment.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_ANDROID)
#include "chrome/browser/android/webapps/webapp_registry.h"
#endif

namespace {

TrackingProtectionOnboardingStatus;

constexpr char kTestEmail[] =;

class PrivacySandboxSettingsDelegateTest : public testing::Test {};

TEST_F(PrivacySandboxSettingsDelegateTest,
       CapabilityRestrictionForSignedInUser) {}

TEST_F(PrivacySandboxSettingsDelegateTest,
       CapabilityRestrictionForSignedOutUser) {}

TEST_F(PrivacySandboxSettingsDelegateTest,
       RestrictedNoticeRequiredForSignedInUser) {}

TEST_F(PrivacySandboxSettingsDelegateTest,
       RestrictedNoticeRequiredWithoutAccountToken) {}

TEST_F(PrivacySandboxSettingsDelegateTest,
       RestrictedNoticeRequiredForSignedOutUser) {}

TEST_F(PrivacySandboxSettingsDelegateTest,
       RestrictedNoticeRequiredFeatureDisabled) {}

TEST_F(PrivacySandboxSettingsDelegateTest,
       AppropriateTopicsConsent_ConsentNotRequired) {}

TEST_F(PrivacySandboxSettingsDelegateTest,
       AppropriateTopicsConsent_ConsentRequired) {}

TEST_F(PrivacySandboxSettingsDelegateTest,
       CapabilityRestrictionWhenForcedRestictedUser) {}

namespace {

TpcdExperimentEligibility;

const base::Time kCurrentTime =;
const base::Time kValidInstallDate =;

#if BUILDFLAG(IS_ANDROID)
class MockWebappRegistry : public WebappRegistry {
 public:
  // WebappRegistry:
  MOCK_METHOD(std::vector<std::string>,
              GetOriginsWithInstalledApp,
              (),
              (override));
};
#endif

struct CookieDeprecationExperimentEligibilityTestCase {};

const CookieDeprecationExperimentEligibilityTestCase
    kCookieDeprecationExperimentEligibilityTestCases[] =;

class CookieDeprecationExperimentEligibilityTest
    : public PrivacySandboxSettingsDelegateTest,
      public ::testing::WithParamInterface<
          CookieDeprecationExperimentEligibilityTestCase> {};

// The parameter indicates whether to use per-profile filtering.
class CookieDeprecationExperimentEligibilityOTRProfileTest
    : public PrivacySandboxSettingsDelegateTest,
      public testing::WithParamInterface<bool> {};

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

}  // namespace

TEST_F(PrivacySandboxSettingsDelegateTest, IsEligible) {}

TEST_P(CookieDeprecationExperimentEligibilityTest, IsEligible) {}

INSTANTIATE_TEST_SUITE_P();

TEST_P(CookieDeprecationExperimentEligibilityOTRProfileTest, IsEligible) {}

INSTANTIATE_TEST_SUITE_P();

TEST_P(CookieDeprecationLabelAllowedTest, IsClientEligibleChecked) {}

TEST_P(CookieDeprecationLabelAllowedTest, OnboardingStatusChecked) {}

INSTANTIATE_TEST_SUITE_P();

namespace {

struct ThirdPartyCookiesBlockedByCookieDeprecationExperimentTestCase {};

const ThirdPartyCookiesBlockedByCookieDeprecationExperimentTestCase
    kThirdPartyCookiesBlockedByCookieDeprecationExperimentTestCases[] =;

class ThirdPartyCookiesBlockedByCookieDeprecationExperimentTest
    : public PrivacySandboxSettingsDelegateTest,
      public ::testing::WithParamInterface<
          ThirdPartyCookiesBlockedByCookieDeprecationExperimentTestCase> {};

}  // namespace

TEST_P(ThirdPartyCookiesBlockedByCookieDeprecationExperimentTest,
       AreThirdPartyCookiesBlockedByExperiment) {}

INSTANTIATE_TEST_SUITE_P();

}  // namespace