0

Set TestingPrefStore's read-only flag to false by default

Currently, this is set to true. This is bad because:
1. This being set to true reflects an error case in prod, which is not
realistic here for all the tests.
2. This leads to early-outs in some cases and thus doesn't let the tests
cover the actual usage.

Bug: 336776819
Change-Id: Ice7206bcd69c66cd970b753db8858a03258f2799
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5557925
Code-Coverage: findit-for-me@appspot.gserviceaccount.com <findit-for-me@appspot.gserviceaccount.com>
Commit-Queue: Ankush Singh <ankushkush@google.com>
Reviewed-by: Dominic Battre <battre@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1304992}
This commit is contained in:
Ankush Singh
2024-05-23 11:38:20 +00:00
committed by Chromium LUCI CQ
parent 68e784597b
commit 57f74e398a
2 changed files with 3 additions and 14 deletions

@ -66,7 +66,7 @@ class ChangedValueWaiter : public PrefStore::Observer {
} // namespace
TestingPrefStore::TestingPrefStore()
: read_only_(true),
: read_only_(false),
read_success_(true),
read_error_(PersistentPrefStore::PREF_READ_ERROR_NONE),
block_async_read_(false),

@ -7,21 +7,10 @@
#include "components/prefs/testing_pref_store.h"
namespace sync_preferences {
namespace {
scoped_refptr<TestingPrefStore> CreateTestingPrefStore() {
scoped_refptr<TestingPrefStore> store =
base::MakeRefCounted<TestingPrefStore>();
// TestingPrefStore is initialized with read-only flag set to true by default.
// This represents an error case in prod and is not effective for tests.
// Moreoever, this can cause early-outs which avoids testing of some cases.
store->set_read_only(false);
return store;
}
} // namespace
PrefServiceMockFactory::PrefServiceMockFactory() {
set_user_prefs(CreateTestingPrefStore());
SetAccountPrefStore(CreateTestingPrefStore());
set_user_prefs(base::MakeRefCounted<TestingPrefStore>());
SetAccountPrefStore(base::MakeRefCounted<TestingPrefStore>());
}
PrefServiceMockFactory::~PrefServiceMockFactory() = default;