0

[media_effects] Switch to user_prefs::TestBrowserContextWithPrefs

This deletes the local implementation and switches to a common
implementation.

Bug: 1479195
Change-Id: Ic6f1142f11d9a0c3b3e6acee79d34bd0822584c4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4853185
Commit-Queue: Piotr Bialecki <bialpio@chromium.org>
Reviewed-by: Piotr Bialecki <bialpio@chromium.org>
Auto-Submit: Bryant Chandler <bryantchandler@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1196571}
This commit is contained in:
Bryant Chandler
2023-09-14 14:23:43 +00:00
committed by Chromium LUCI CQ
parent 02dd59c63c
commit 2c84a6c039
6 changed files with 7 additions and 86 deletions

@ -22,8 +22,8 @@ source_set("unit_tests") {
deps = [
":media_effects",
"//base",
"//components/media_effects/test",
"//components/prefs:test_support",
"//components/user_prefs/test:test_support",
"//content/test:test_support",
"//testing/gtest",
]

@ -4,15 +4,15 @@
#include "components/media_effects/media_effects_service_factory.h"
#include "components/media_effects/test/test_browser_context_with_prefs.h"
#include "components/user_prefs/test/test_browser_context_with_prefs.h"
#include "content/public/test/browser_task_environment.h"
#include "testing/gtest/include/gtest/gtest.h"
class MediaEffectsServiceFactoryTest : public testing::Test {
protected:
content::BrowserTaskEnvironment task_environment_;
media_effects::TestBrowserContextWithPrefs profile1_;
media_effects::TestBrowserContextWithPrefs profile2_;
user_prefs::TestBrowserContextWithPrefs profile1_;
user_prefs::TestBrowserContextWithPrefs profile2_;
};
TEST_F(MediaEffectsServiceFactoryTest,
@ -33,7 +33,7 @@ TEST_F(MediaEffectsServiceFactoryTest,
TEST_F(MediaEffectsServiceFactoryTest,
GetForBrowserContext_IncognitoProfileReturnsDifferentService) {
media_effects::TestBrowserContextWithPrefs incognito_profile2;
user_prefs::TestBrowserContextWithPrefs incognito_profile2;
incognito_profile2.set_is_off_the_record(true);
ASSERT_NE(&profile2_, &incognito_profile2);
EXPECT_NE(

@ -6,10 +6,8 @@
#include "base/run_loop.h"
#include "base/test/test_future.h"
#include "components/media_effects/test/test_browser_context_with_prefs.h"
#include "components/prefs/testing_pref_service.h"
#include "components/user_prefs/test/test_browser_context_with_prefs.h"
#include "content/public/test/browser_task_environment.h"
#include "content/public/test/test_browser_context.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/insets_f.h"
@ -44,7 +42,7 @@ void SetFramingSync(
class MediaEffectsServiceTest : public testing::Test {
protected:
content::BrowserTaskEnvironment task_environment_;
media_effects::TestBrowserContextWithPrefs browser_context_;
user_prefs::TestBrowserContextWithPrefs browser_context_;
MediaEffectsService service_{browser_context_.prefs()};
};

@ -1,19 +0,0 @@
# 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.
source_set("test") {
testonly = true
sources = [
"test_browser_context_with_prefs.cc",
"test_browser_context_with_prefs.h",
]
deps = [
"//components/keyed_service/content",
"//components/prefs:test_support",
"//components/user_prefs:user_prefs",
"//content/test:test_support",
]
}

@ -1,22 +0,0 @@
// 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/media_effects/test/test_browser_context_with_prefs.h"
#include "components/user_prefs/user_prefs.h"
namespace media_effects {
TestBrowserContextWithPrefs::TestBrowserContextWithPrefs()
: browser_context_dependency_manager_(
BrowserContextDependencyManager::GetInstance()) {
browser_context_dependency_manager_->MarkBrowserContextLive(this);
user_prefs::UserPrefs::Set(this, &prefs_);
}
TestBrowserContextWithPrefs::~TestBrowserContextWithPrefs() {
browser_context_dependency_manager_->DestroyBrowserContextServices(this);
}
} // namespace media_effects

@ -1,36 +0,0 @@
// 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.
#ifndef COMPONENTS_MEDIA_EFFECTS_TEST_TEST_BROWSER_CONTEXT_WITH_PREFS_H_
#define COMPONENTS_MEDIA_EFFECTS_TEST_TEST_BROWSER_CONTEXT_WITH_PREFS_H_
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/prefs/testing_pref_service.h"
#include "content/public/test/test_browser_context.h"
namespace media_effects {
// TODO(crbug.com/1479195): Find a more re-usable place for this to live.
class TestBrowserContextWithPrefs : public content::TestBrowserContext {
public:
TestBrowserContextWithPrefs();
TestBrowserContextWithPrefs(const TestBrowserContextWithPrefs&) = delete;
TestBrowserContextWithPrefs& operator=(const TestBrowserContextWithPrefs&) =
delete;
~TestBrowserContextWithPrefs() override;
PrefService* prefs() { return &prefs_; }
PrefRegistrySimple* pref_registry() { return prefs_.registry(); }
private:
const raw_ptr<BrowserContextDependencyManager>
browser_context_dependency_manager_;
TestingPrefServiceSimple prefs_;
};
} // namespace media_effects
#endif // COMPONENTS_MEDIA_EFFECTS_TEST_TEST_BROWSER_CONTEXT_WITH_PREFS_H_