blob: 83a767acaad13c76c588e125bab98ff5058a1854 [file] [log] [blame]
Mikel Astizd848587f2023-10-02 09:28:031// Copyright 2023 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 "chrome/browser/prefs/browser_prefs.h"
6
7#include "build/build_config.h"
8#include "components/sync/base/pref_names.h"
9#include "components/sync_preferences/testing_pref_service_syncable.h"
10#include "testing/gtest/include/gtest/gtest.h"
11
12namespace {
13
14constexpr char kSyncRequested[] = "sync.requested";
15
16class BrowserPrefsTest : public testing::Test {
17 protected:
18 BrowserPrefsTest() { RegisterUserProfilePrefs(prefs_.registry()); }
19
20 sync_preferences::TestingPrefServiceSyncable prefs_;
21};
22
23TEST_F(BrowserPrefsTest, MigrateObsoleteProfilePrefSyncRequestedDefaultValue) {
24 MigrateObsoleteProfilePrefs(&prefs_);
25 EXPECT_EQ(nullptr, prefs_.GetUserPrefValue(kSyncRequested));
26
27#if BUILDFLAG(IS_CHROMEOS_ASH)
28 EXPECT_EQ(nullptr, prefs_.GetUserPrefValue(
29 syncer::prefs::internal::kSyncDisabledViaDashboard));
30#endif
31}
32
33TEST_F(BrowserPrefsTest, MigrateObsoleteProfilePrefSyncRequestedSetToTrue) {
34 prefs_.SetBoolean(kSyncRequested, true);
35 MigrateObsoleteProfilePrefs(&prefs_);
36 EXPECT_EQ(nullptr, prefs_.GetUserPrefValue(kSyncRequested));
37
38#if BUILDFLAG(IS_CHROMEOS_ASH)
39 EXPECT_EQ(nullptr, prefs_.GetUserPrefValue(
40 syncer::prefs::internal::kSyncDisabledViaDashboard));
41#endif
42}
43
44TEST_F(BrowserPrefsTest, MigrateObsoleteProfilePrefSyncRequestedSetToFalse) {
45 prefs_.SetBoolean(kSyncRequested, false);
46 MigrateObsoleteProfilePrefs(&prefs_);
47 EXPECT_EQ(nullptr, prefs_.GetUserPrefValue(kSyncRequested));
48
49#if BUILDFLAG(IS_CHROMEOS_ASH)
50 EXPECT_NE(nullptr, prefs_.GetUserPrefValue(
51 syncer::prefs::internal::kSyncDisabledViaDashboard));
52 EXPECT_TRUE(
53 prefs_.GetBoolean(syncer::prefs::internal::kSyncDisabledViaDashboard));
54#endif
55}
56
57} // namespace