blob: 9ea3f988c5b14aaee6fd3f1396aa2c3361fa19c2 [file] [log] [blame]
Francois Doray405dd2d2017-06-09 15:23:331// Copyright 2017 The Chromium Authors. All rights reserved.
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/bind.h"
8#include "base/run_loop.h"
9#include "base/sequence_checker_impl.h"
Gabriel Charettec7108742019-08-23 03:31:4010#include "base/test/task_environment.h"
Francois Doray405dd2d2017-06-09 15:23:3311#include "testing/gtest/include/gtest/gtest.h"
12
Francois Doray5f547952017-07-25 21:02:0513void TestCommitPendingWriteWithCallback(
14 PersistentPrefStore* store,
Gabriel Charettedfa36042019-08-19 17:30:1115 base::test::TaskEnvironment* task_environment) {
Francois Doray405dd2d2017-06-09 15:23:3316 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)));
Gabriel Charettedfa36042019-08-19 17:30:1124 task_environment->RunUntilIdle();
Francois Doray405dd2d2017-06-09 15:23:3325 run_loop.Run();
26}