Remove PrivacySandboxServiceTest as it contains no tests.
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
# Copyright 2021 The Brave Authors. All rights reserved.
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
source_set("unit_tests") {
|
||||
testonly = true
|
||||
sources = [ "privacy_sandbox_service_unittest.cc" ]
|
||||
|
||||
deps = [
|
||||
"//base",
|
||||
"//chrome/browser",
|
||||
"//chrome/common:chrome_features",
|
||||
"//chrome/test:test_support",
|
||||
"//components/browsing_topics",
|
||||
"//components/content_settings/core/browser",
|
||||
"//components/content_settings/core/common",
|
||||
"//components/content_settings/core/test:test_support",
|
||||
"//components/policy/core/common:test_support",
|
||||
"//components/privacy_sandbox:privacy_sandbox",
|
||||
"//components/privacy_sandbox:privacy_sandbox_prefs",
|
||||
"//components/privacy_sandbox:test_support",
|
||||
"//components/signin/public/identity_manager",
|
||||
"//components/signin/public/identity_manager:test_support",
|
||||
"//components/strings:components_strings",
|
||||
"//components/sync:test_support",
|
||||
"//components/sync/base",
|
||||
"//components/sync_preferences:test_support",
|
||||
"//content/public/common",
|
||||
"//content/test:test_support",
|
||||
"//testing/gtest:gtest",
|
||||
"//third_party/blink/public/common",
|
||||
"//third_party/blink/public/mojom:mojom_platform_headers",
|
||||
"//ui/base",
|
||||
"//url",
|
||||
]
|
||||
}
|
||||
@@ -1,169 +0,0 @@
|
||||
// Copyright 2021 The Chromium Authors. All rights reserved.
|
||||
// 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_service.h"
|
||||
|
||||
#include "base/test/gtest_util.h"
|
||||
#include "base/test/icu_test_util.h"
|
||||
#include "base/test/metrics/histogram_tester.h"
|
||||
#include "base/test/metrics/user_action_tester.h"
|
||||
#include "base/test/scoped_feature_list.h"
|
||||
#include "chrome/browser/content_settings/cookie_settings_factory.h"
|
||||
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
|
||||
#include "chrome/browser/privacy_sandbox/privacy_sandbox_service.h"
|
||||
#include "chrome/browser/privacy_sandbox/privacy_sandbox_settings_factory.h"
|
||||
#include "chrome/browser/signin/identity_manager_factory.h"
|
||||
#include "chrome/common/chrome_features.h"
|
||||
#include "chrome/test/base/testing_profile.h"
|
||||
#include "components/browsing_topics/browsing_topics_service.h"
|
||||
#include "components/browsing_topics/test_util.h"
|
||||
#include "components/content_settings/core/browser/cookie_settings.h"
|
||||
#include "components/content_settings/core/browser/host_content_settings_map.h"
|
||||
#include "components/content_settings/core/common/pref_names.h"
|
||||
#include "components/policy/core/common/mock_policy_service.h"
|
||||
#include "components/privacy_sandbox/privacy_sandbox_prefs.h"
|
||||
#include "components/privacy_sandbox/privacy_sandbox_settings.h"
|
||||
#include "components/privacy_sandbox/privacy_sandbox_test_util.h"
|
||||
#include "components/profile_metrics/browser_profile_type.h"
|
||||
#include "components/signin/public/identity_manager/account_info.h"
|
||||
#include "components/signin/public/identity_manager/identity_test_environment.h"
|
||||
#include "components/strings/grit/components_strings.h"
|
||||
#include "components/sync/base/user_selectable_type.h"
|
||||
#include "components/sync/test/test_sync_service.h"
|
||||
#include "components/sync_preferences/testing_pref_service_syncable.h"
|
||||
#include "content/public/browser/browsing_data_remover.h"
|
||||
#include "content/public/browser/first_party_sets_handler.h"
|
||||
#include "content/public/browser/interest_group_manager.h"
|
||||
#include "content/public/common/content_features.h"
|
||||
#include "content/public/test/browser_task_environment.h"
|
||||
#include "net/first_party_sets/first_party_set_entry.h"
|
||||
#include "net/first_party_sets/first_party_sets_context_config.h"
|
||||
#include "net/first_party_sets/global_first_party_sets.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "third_party/blink/public/common/features.h"
|
||||
#include "ui/base/l10n/l10n_util.h"
|
||||
#include "url/origin.h"
|
||||
|
||||
#if !BUILDFLAG(IS_ANDROID)
|
||||
#include "chrome/browser/ui/hats/mock_trust_safety_sentiment_service.h"
|
||||
#endif
|
||||
|
||||
namespace {
|
||||
|
||||
class TestInterestGroupManager : public content::InterestGroupManager {
|
||||
public:
|
||||
void SetInterestGroupJoiningOrigins(const std::vector<url::Origin>& origins) {
|
||||
origins_ = origins;
|
||||
}
|
||||
|
||||
// content::InterestGroupManager:
|
||||
void GetAllInterestGroupJoiningOrigins(
|
||||
base::OnceCallback<void(std::vector<url::Origin>)> callback) override {
|
||||
std::move(callback).Run(origins_);
|
||||
}
|
||||
|
||||
private:
|
||||
std::vector<url::Origin> origins_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
class PrivacySandboxServiceTest : public testing::Test {
|
||||
public:
|
||||
PrivacySandboxServiceTest()
|
||||
: browser_task_environment_(
|
||||
base::test::TaskEnvironment::TimeSource::MOCK_TIME) {}
|
||||
|
||||
void SetUp() override {
|
||||
InitializePrefsBeforeStart();
|
||||
|
||||
#if !BUILDFLAG(IS_ANDROID)
|
||||
mock_sentiment_service_ =
|
||||
std::make_unique<::testing::NiceMock<MockTrustSafetySentimentService>>(
|
||||
profile());
|
||||
#endif
|
||||
privacy_sandbox_service_ = std::make_unique<PrivacySandboxService>(
|
||||
PrivacySandboxSettingsFactory::GetForProfile(profile()),
|
||||
CookieSettingsFactory::GetForProfile(profile()).get(),
|
||||
profile()->GetPrefs(), test_interest_group_manager(),
|
||||
profile_metrics::BrowserProfileType::kRegular, browsing_data_remover(),
|
||||
#if !BUILDFLAG(IS_ANDROID)
|
||||
mock_sentiment_service(),
|
||||
#endif
|
||||
mock_browsing_topics_service(), first_party_sets_policy_service());
|
||||
|
||||
SetGlobalFirstPartySetsAndWait();
|
||||
}
|
||||
|
||||
virtual void InitializePrefsBeforeStart() {}
|
||||
|
||||
TestingProfile* profile() { return &profile_; }
|
||||
PrivacySandboxService* privacy_sandbox_service() {
|
||||
return privacy_sandbox_service_.get();
|
||||
}
|
||||
privacy_sandbox::PrivacySandboxSettings* privacy_sandbox_settings() {
|
||||
return PrivacySandboxSettingsFactory::GetForProfile(profile());
|
||||
}
|
||||
|
||||
base::test::ScopedFeatureList* feature_list() { return &feature_list_; }
|
||||
sync_preferences::TestingPrefServiceSyncable* prefs() {
|
||||
return profile()->GetTestingPrefService();
|
||||
}
|
||||
HostContentSettingsMap* host_content_settings_map() {
|
||||
return HostContentSettingsMapFactory::GetForProfile(profile());
|
||||
}
|
||||
syncer::TestSyncService* sync_service() { return &sync_service_; }
|
||||
policy::MockPolicyService* policy_service() { return &mock_policy_service_; }
|
||||
signin::IdentityTestEnvironment* identity_test_env() {
|
||||
return &identity_test_env_;
|
||||
}
|
||||
TestInterestGroupManager* test_interest_group_manager() {
|
||||
return &test_interest_group_manager_;
|
||||
}
|
||||
content::BrowsingDataRemover* browsing_data_remover() {
|
||||
return profile()->GetBrowsingDataRemover();
|
||||
}
|
||||
browsing_topics::MockBrowsingTopicsService* mock_browsing_topics_service() {
|
||||
return mock_browsing_topics_service_;
|
||||
}
|
||||
#if !BUILDFLAG(IS_ANDROID)
|
||||
MockTrustSafetySentimentService* mock_sentiment_service() {
|
||||
return mock_sentiment_service_.get();
|
||||
}
|
||||
#endif
|
||||
first_party_sets::FirstPartySetsPolicyService*
|
||||
first_party_sets_policy_service() {
|
||||
return &first_party_sets_policy_service_;
|
||||
}
|
||||
|
||||
private:
|
||||
void SetGlobalFirstPartySetsAndWait() {
|
||||
content::FirstPartySetsHandler::GetInstance()->ResetForTesting();
|
||||
content::FirstPartySetsHandler::GetInstance()->SetGlobalSetsForTesting({});
|
||||
base::RunLoop run_loop;
|
||||
first_party_sets_policy_service_.WaitForFirstInitCompleteForTesting(
|
||||
run_loop.QuitClosure());
|
||||
run_loop.Run();
|
||||
first_party_sets_policy_service_.ResetForTesting();
|
||||
}
|
||||
|
||||
content::BrowserTaskEnvironment browser_task_environment_;
|
||||
signin::IdentityTestEnvironment identity_test_env_;
|
||||
testing::NiceMock<policy::MockPolicyService> mock_policy_service_;
|
||||
|
||||
TestingProfile profile_;
|
||||
base::test::ScopedFeatureList feature_list_;
|
||||
syncer::TestSyncService sync_service_;
|
||||
TestInterestGroupManager test_interest_group_manager_;
|
||||
|
||||
std::unique_ptr<PrivacySandboxService> privacy_sandbox_service_;
|
||||
browsing_topics::MockBrowsingTopicsService* mock_browsing_topics_service_;
|
||||
first_party_sets::FirstPartySetsPolicyService
|
||||
first_party_sets_policy_service_ =
|
||||
first_party_sets::FirstPartySetsPolicyService(
|
||||
profile_.GetOriginalProfile());
|
||||
#if !BUILDFLAG(IS_ANDROID)
|
||||
std::unique_ptr<MockTrustSafetySentimentService> mock_sentiment_service_;
|
||||
#endif
|
||||
};
|
||||
@@ -181,7 +181,6 @@ test("brave_unit_tests") {
|
||||
"//brave/browser/ui/webui/new_tab_page:unit_tests",
|
||||
"//brave/browser/web_discovery:unit_tests",
|
||||
"//brave/browser/widevine:unittest",
|
||||
"//brave/chromium_src/chrome/browser/privacy_sandbox:unit_tests",
|
||||
"//brave/chromium_src/components/autofill_assistant/browser:unit_tests",
|
||||
"//brave/chromium_src/components/privacy_sandbox:unit_tests",
|
||||
"//brave/chromium_src/net/base:unit_tests",
|
||||
|
||||
Reference in New Issue
Block a user