chromium/components/privacy_sandbox/privacy_sandbox_attestations/privacy_sandbox_attestations_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/privacy_sandbox/privacy_sandbox_attestations/privacy_sandbox_attestations.h"

#include <string>
#include <string_view>

#include "base/feature_list.h"
#include "base/files/file_path.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
#include "base/scoped_observation.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/with_feature_override.h"
#include "base/version.h"
#include "components/privacy_sandbox/privacy_sandbox_attestations/privacy_sandbox_attestations_histograms.h"
#include "components/privacy_sandbox/privacy_sandbox_attestations/proto/privacy_sandbox_attestations.pb.h"
#include "components/privacy_sandbox/privacy_sandbox_attestations/scoped_privacy_sandbox_attestations.h"
#include "components/privacy_sandbox/privacy_sandbox_features.h"
#include "components/startup_metric_utils/browser/startup_metric_utils.h"
#include "content/public/browser/privacy_sandbox_attestations_observer.h"
#include "content/public/test/browser_task_environment.h"
#include "net/base/schemeful_site.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"

namespace privacy_sandbox {

namespace {

class MockAttestationsObserver
    : public content::PrivacySandboxAttestationsObserver {};

}  // namespace

class PrivacySandboxAttestationsTestBase : public testing::Test {};

TEST_F(PrivacySandboxAttestationsTestBase, AddOverride) {}

class PrivacySandboxAttestationsFeatureEnabledTest
    : public base::test::WithFeatureOverride,
      public PrivacySandboxAttestationsTestBase {};

TEST_P(PrivacySandboxAttestationsFeatureEnabledTest,
       AttestationsBehaviorWithMapBeingAbsent) {}

TEST_P(PrivacySandboxAttestationsFeatureEnabledTest,
       DefaultDenyIfAttestationsComponentNotYetReady) {}

TEST_P(PrivacySandboxAttestationsFeatureEnabledTest, AttestedIfOverridden) {}

TEST_P(PrivacySandboxAttestationsFeatureEnabledTest,
       EnrolledWithoutAttestations) {}

TEST_P(PrivacySandboxAttestationsFeatureEnabledTest, EnrolledAndAttested) {}

TEST_P(PrivacySandboxAttestationsFeatureEnabledTest,
       NonExistentAttestationsFile) {}

// The parsing progress may end up being
// `PrivacySandboxAttestations::Progress::kFinished` but there is no in-memory
// attestations map. Verify that the second attempt to parse should not crash.
TEST_P(PrivacySandboxAttestationsFeatureEnabledTest,
       TryParseNonExistentAttestationsFileTwice) {}

TEST_P(PrivacySandboxAttestationsFeatureEnabledTest,
       InvalidAttestationsFileIsNotLoaded) {}

TEST_P(PrivacySandboxAttestationsFeatureEnabledTest, LoadAttestationsFile) {}

TEST_P(PrivacySandboxAttestationsFeatureEnabledTest,
       AttestationFirstCheckTimeHistogram) {}

TEST_P(PrivacySandboxAttestationsFeatureEnabledTest,
       LoadAttestationsFilePauseDuringParsing) {}

TEST_P(PrivacySandboxAttestationsFeatureEnabledTest,
       OlderVersionAttestationsFileIsNotLoaded) {}

TEST_P(PrivacySandboxAttestationsFeatureEnabledTest,
       NewerVersionAttestationsFileIsLoaded) {}

// Test that the parsing works as expected when there are combining characters
// in the file path to the attestation list. There are exhaustive tests on this
// in `base/files/file_path_unittest.cc`.
TEST_P(PrivacySandboxAttestationsFeatureEnabledTest,
       CombiningCharacterFilePath) {}

INSTANTIATE_FEATURE_OVERRIDE_TEST_SUITE();

}  // namespace privacy_sandbox