Francois Doray | 405dd2d | 2017-06-09 15:23:33 | [diff] [blame] | 1 | // 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 Doray | 5f54795 | 2017-07-25 21:02:05 | [diff] [blame^] | 10 | #include "base/test/scoped_task_environment.h" |
Francois Doray | 405dd2d | 2017-06-09 15:23:33 | [diff] [blame] | 11 | #include "testing/gtest/include/gtest/gtest.h" |
| 12 | |
Francois Doray | 5f54795 | 2017-07-25 21:02:05 | [diff] [blame^] | 13 | void TestCommitPendingWriteWithCallback( |
| 14 | PersistentPrefStore* store, |
| 15 | base::test::ScopedTaskEnvironment* scoped_task_environment) { |
Francois Doray | 405dd2d | 2017-06-09 15:23:33 | [diff] [blame] | 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))); |
Francois Doray | 5f54795 | 2017-07-25 21:02:05 | [diff] [blame^] | 24 | scoped_task_environment->RunUntilIdle(); |
Francois Doray | 405dd2d | 2017-06-09 15:23:33 | [diff] [blame] | 25 | run_loop.Run(); |
| 26 | } |