#include <stddef.h>
#include <stdint.h>
#include <string>
#include "base/functional/callback_helpers.h"
#include "base/time/time.h"
#include "base/values.h"
#include "components/prefs/json_pref_store.h"
#include "components/prefs/mock_pref_change_callback.h"
#include "components/prefs/pref_change_registrar.h"
#include "components/prefs/pref_notifier_impl.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service_factory.h"
#include "components/prefs/pref_value_store.h"
#include "components/prefs/testing_pref_service.h"
#include "components/prefs/testing_pref_store.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
_;
Mock;
namespace {
const char kPrefName[] = …;
const char kStandaloneBrowserPref[] = …;
}
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST(PrefServiceUtilTest, GetAllDottedPaths) {
using pref_service_util::GetAllDottedPaths;
base::Value::Dict dict;
std::vector<std::string> paths;
GetAllDottedPaths(dict, paths);
EXPECT_EQ(paths.size(), std::size_t(0));
dict.SetByDottedPath("one.two", base::Value(12));
GetAllDottedPaths(dict, paths);
EXPECT_THAT(paths, testing::UnorderedElementsAre("one.two"));
paths.clear();
dict.SetByDottedPath("one.three", base::Value(13));
GetAllDottedPaths(dict, paths);
EXPECT_THAT(paths, testing::UnorderedElementsAre("one.two", "one.three"));
paths.clear();
dict.SetByDottedPath("key", "value");
GetAllDottedPaths(dict, paths);
EXPECT_THAT(paths,
testing::UnorderedElementsAre("one.two", "one.three", "key"));
}
#endif
TEST(PrefServiceTest, NoObserverFire) { … }
TEST(PrefServiceTest, HasPrefPath) { … }
TEST(PrefServiceTest, Observers) { … }
TEST(PrefServiceTest, GetValueChangedType) { … }
TEST(PrefServiceTest, GetValueAndGetRecommendedValue) { … }
TEST(PrefServiceTest, SetTimeValue_RegularTime) { … }
TEST(PrefServiceTest, SetTimeValue_NullTime) { … }
TEST(PrefServiceTest, SetTimeDeltaValue_RegularTimeDelta) { … }
TEST(PrefServiceTest, SetTimeDeltaValue_ZeroTimeDelta) { … }
class WriteFlagChecker : public TestingPrefStore { … };
TEST(PrefServiceTest, WriteablePrefStoreFlags) { … }
class PrefServiceSetValueTest : public testing::Test { … };
const char PrefServiceSetValueTest::kName[] = …;
const char PrefServiceSetValueTest::kValue[] = …;
TEST_F(PrefServiceSetValueTest, SetStringValue) { … }
TEST_F(PrefServiceSetValueTest, SetDictionaryValue) { … }
TEST_F(PrefServiceSetValueTest, SetListValue) { … }
class PrefStandaloneBrowserPrefsTest : public testing::Test { … };
TEST_F(PrefStandaloneBrowserPrefsTest, CheckStandaloneBrowserPref) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH)
TEST_F(PrefStandaloneBrowserPrefsTest, RemoveAllStandaloneBrowserPrefs) {
const char int_pref_name[] = "int.name";
const char str_pref_name[] = "str.pref.name";
pref_registry_->RegisterIntegerPref(int_pref_name, 0);
pref_registry_->RegisterStringPref(str_pref_name, "");
pref_service_->SetStandaloneBrowserPref(int_pref_name, base::Value(4));
pref_service_->SetStandaloneBrowserPref(str_pref_name, base::Value("value"));
EXPECT_EQ(base::Value(4), pref_service_->GetValue(int_pref_name));
EXPECT_EQ(base::Value("value"), pref_service_->GetValue(str_pref_name));
pref_service_->RemoveAllStandaloneBrowserPrefs();
EXPECT_EQ(base::Value(0), pref_service_->GetValue(int_pref_name));
EXPECT_EQ(base::Value(""), pref_service_->GetValue(str_pref_name));
}
#endif