blob: d297858b81258ce76b7dca6308523e5f9c6dc5ae [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"
Francois Doray5f547952017-07-25 21:02:0510#include "base/test/scoped_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,
15 base::test::ScopedTaskEnvironment* scoped_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)));
Francois Doray5f547952017-07-25 21:02:0524 scoped_task_environment->RunUntilIdle();
Francois Doray405dd2d2017-06-09 15:23:3325 run_loop.Run();
26}