xref: /aosp_15_r20/external/cronet/components/prefs/persistent_pref_store_unittest.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2017 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 "components/prefs/persistent_pref_store.h"
6 
7 #include "base/functional/bind.h"
8 #include "base/run_loop.h"
9 #include "base/sequence_checker_impl.h"
10 #include "base/test/task_environment.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 
TestCommitPendingWriteWithCallback(PersistentPrefStore * store,base::test::TaskEnvironment * task_environment)13 void TestCommitPendingWriteWithCallback(
14     PersistentPrefStore* store,
15     base::test::TaskEnvironment* task_environment) {
16   base::RunLoop run_loop;
17   base::SequenceCheckerImpl sequence_checker;
18   store->CommitPendingWrite(base::BindOnce(
19       [](base::SequenceCheckerImpl* sequence_checker, base::RunLoop* run_loop) {
20         EXPECT_TRUE(sequence_checker->CalledOnValidSequence());
21         run_loop->Quit();
22       },
23       base::Unretained(&sequence_checker), base::Unretained(&run_loop)));
24   task_environment->RunUntilIdle();
25   run_loop.Run();
26 }
27