blob: 9e26bf435da93e54d539be83b9f938029f5cca21 [file] [log] [blame]
Topi Lassila782cdce2025-05-12 09:16:081// Copyright 2025 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "base/memory/raw_ptr.h"
6#include "chrome/browser/prefs/persistent_renderer_prefs_manager.h"
7#include "chrome/browser/profiles/profile.h"
8#include "chrome/common/pref_names.h"
9#include "chrome/test/base/testing_profile.h"
10#include "components/prefs/pref_service.h"
11#include "content/public/test/browser_task_environment.h"
12#include "testing/gtest/include/gtest/gtest.h"
13
14class TestPersistentRendererPrefsManager : PersistentRendererPrefsManager {
15 public:
16 explicit TestPersistentRendererPrefsManager(PrefService& pref_service)
17 : PersistentRendererPrefsManager(pref_service) {}
18 void TestSetViewSourceLineWrapping(bool value) {
19 SetViewSourceLineWrapping(value);
20 }
21};
22
23// Observe that changes made through the persistent renderer prefs service are
24// reflected in the profile backing it.
25TEST(PersistentRendererPrefsTest, ObservePrefChanges) {
26 content::BrowserTaskEnvironment task_environment;
27 TestingProfile profile;
28 TestPersistentRendererPrefsManager persistent_renderer_prefs_manager(
29 *profile.GetPrefs());
30
31 EXPECT_FALSE(
32 profile.GetPrefs()->GetBoolean(prefs::kViewSourceLineWrappingEnabled));
33
34 persistent_renderer_prefs_manager.TestSetViewSourceLineWrapping(true);
35 EXPECT_TRUE(
36 profile.GetPrefs()->GetBoolean(prefs::kViewSourceLineWrappingEnabled));
37 persistent_renderer_prefs_manager.TestSetViewSourceLineWrapping(false);
38 EXPECT_FALSE(
39 profile.GetPrefs()->GetBoolean(prefs::kViewSourceLineWrappingEnabled));
40}