persistent_pref_store_unittest.cc 949 B

1234567891011121314151617181920212223242526
  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. #include "components/prefs/persistent_pref_store.h"
  5. #include "base/bind.h"
  6. #include "base/run_loop.h"
  7. #include "base/sequence_checker_impl.h"
  8. #include "base/test/task_environment.h"
  9. #include "testing/gtest/include/gtest/gtest.h"
  10. void TestCommitPendingWriteWithCallback(
  11. PersistentPrefStore* store,
  12. base::test::TaskEnvironment* task_environment) {
  13. base::RunLoop run_loop;
  14. base::SequenceCheckerImpl sequence_checker;
  15. store->CommitPendingWrite(base::BindOnce(
  16. [](base::SequenceCheckerImpl* sequence_checker, base::RunLoop* run_loop) {
  17. EXPECT_TRUE(sequence_checker->CalledOnValidSequence());
  18. run_loop->Quit();
  19. },
  20. base::Unretained(&sequence_checker), base::Unretained(&run_loop)));
  21. task_environment->RunUntilIdle();
  22. run_loop.Run();
  23. }