Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(996)

Unified Diff: base/prefs/json_pref_store_unittest.cc

Issue 1100773004: base: Remove most uses of MessageLoopProxy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added some missing includes. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/prefs/json_pref_store.h ('k') | base/prefs/pref_member_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/prefs/json_pref_store_unittest.cc
diff --git a/base/prefs/json_pref_store_unittest.cc b/base/prefs/json_pref_store_unittest.cc
index 746c72bda8a51ea46a196a9330405c60cdc455cc..728a57d3417fc4e5893c4226939f12ba1b5cc7e8 100644
--- a/base/prefs/json_pref_store_unittest.cc
+++ b/base/prefs/json_pref_store_unittest.cc
@@ -7,6 +7,7 @@
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/files/scoped_temp_dir.h"
+#include "base/location.h"
#include "base/memory/ref_counted.h"
#include "base/memory/scoped_ptr.h"
#include "base/message_loop/message_loop.h"
@@ -15,6 +16,7 @@
#include "base/path_service.h"
#include "base/prefs/pref_filter.h"
#include "base/run_loop.h"
+#include "base/single_thread_task_runner.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -106,7 +108,8 @@ class JsonPrefStoreTest : public testing::Test {
void TearDown() override {
// Make sure all pending tasks have been processed (e.g., deleting the
// JsonPrefStore may post write tasks).
- message_loop_.PostTask(FROM_HERE, MessageLoop::QuitWhenIdleClosure());
+ message_loop_.task_runner()->PostTask(FROM_HERE,
+ MessageLoop::QuitWhenIdleClosure());
message_loop_.Run();
}
@@ -127,9 +130,7 @@ TEST_F(JsonPrefStoreTest, NonExistentFile) {
base::FilePath bogus_input_file = data_dir_.AppendASCII("read.txt");
ASSERT_FALSE(PathExists(bogus_input_file));
scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
- bogus_input_file,
- message_loop_.message_loop_proxy().get(),
- scoped_ptr<PrefFilter>());
+ bogus_input_file, message_loop_.task_runner(), scoped_ptr<PrefFilter>());
EXPECT_EQ(PersistentPrefStore::PREF_READ_ERROR_NO_FILE,
pref_store->ReadPrefs());
EXPECT_FALSE(pref_store->ReadOnly());
@@ -142,11 +143,9 @@ TEST_F(JsonPrefStoreTest, NonExistentFileAndAlternateFile) {
data_dir_.AppendASCII("read_alternate.txt");
ASSERT_FALSE(PathExists(bogus_input_file));
ASSERT_FALSE(PathExists(bogus_alternate_input_file));
- scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
- bogus_input_file,
- bogus_alternate_input_file,
- message_loop_.message_loop_proxy().get(),
- scoped_ptr<PrefFilter>());
+ scoped_refptr<JsonPrefStore> pref_store =
+ new JsonPrefStore(bogus_input_file, bogus_alternate_input_file,
+ message_loop_.task_runner(), scoped_ptr<PrefFilter>());
EXPECT_EQ(PersistentPrefStore::PREF_READ_ERROR_NO_FILE,
pref_store->ReadPrefs());
EXPECT_FALSE(pref_store->ReadOnly());
@@ -157,10 +156,8 @@ TEST_F(JsonPrefStoreTest, InvalidFile) {
base::FilePath invalid_file_original = data_dir_.AppendASCII("invalid.json");
base::FilePath invalid_file = temp_dir_.path().AppendASCII("invalid.json");
ASSERT_TRUE(base::CopyFile(invalid_file_original, invalid_file));
- scoped_refptr<JsonPrefStore> pref_store =
- new JsonPrefStore(invalid_file,
- message_loop_.message_loop_proxy().get(),
- scoped_ptr<PrefFilter>());
+ scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
+ invalid_file, message_loop_.task_runner(), scoped_ptr<PrefFilter>());
EXPECT_EQ(PersistentPrefStore::PREF_READ_ERROR_JSON_PARSE,
pref_store->ReadPrefs());
EXPECT_FALSE(pref_store->ReadOnly());
@@ -246,9 +243,7 @@ TEST_F(JsonPrefStoreTest, Basic) {
base::FilePath input_file = temp_dir_.path().AppendASCII("write.json");
ASSERT_TRUE(PathExists(input_file));
scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
- input_file,
- message_loop_.message_loop_proxy().get(),
- scoped_ptr<PrefFilter>());
+ input_file, message_loop_.task_runner(), scoped_ptr<PrefFilter>());
ASSERT_EQ(PersistentPrefStore::PREF_READ_ERROR_NONE, pref_store->ReadPrefs());
EXPECT_FALSE(pref_store->ReadOnly());
EXPECT_TRUE(pref_store->IsInitializationComplete());
@@ -275,9 +270,7 @@ TEST_F(JsonPrefStoreTest, BasicAsync) {
base::FilePath input_file = temp_dir_.path().AppendASCII("write.json");
ASSERT_TRUE(PathExists(input_file));
scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
- input_file,
- message_loop_.message_loop_proxy().get(),
- scoped_ptr<PrefFilter>());
+ input_file, message_loop_.task_runner(), scoped_ptr<PrefFilter>());
{
MockPrefStoreObserver mock_observer;
@@ -314,9 +307,7 @@ TEST_F(JsonPrefStoreTest, PreserveEmptyValues) {
FilePath pref_file = temp_dir_.path().AppendASCII("empty_values.json");
scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
- pref_file,
- message_loop_.message_loop_proxy(),
- scoped_ptr<PrefFilter>());
+ pref_file, message_loop_.task_runner(), scoped_ptr<PrefFilter>());
// Set some keys with empty values.
pref_store->SetValue("list", new base::ListValue);
@@ -327,10 +318,8 @@ TEST_F(JsonPrefStoreTest, PreserveEmptyValues) {
MessageLoop::current()->RunUntilIdle();
// Reload.
- pref_store = new JsonPrefStore(
- pref_file,
- message_loop_.message_loop_proxy(),
- scoped_ptr<PrefFilter>());
+ pref_store = new JsonPrefStore(pref_file, message_loop_.task_runner(),
+ scoped_ptr<PrefFilter>());
ASSERT_EQ(PersistentPrefStore::PREF_READ_ERROR_NONE, pref_store->ReadPrefs());
ASSERT_FALSE(pref_store->ReadOnly());
@@ -348,9 +337,7 @@ TEST_F(JsonPrefStoreTest, RemoveClearsEmptyParent) {
FilePath pref_file = temp_dir_.path().AppendASCII("empty_values.json");
scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
- pref_file,
- message_loop_.message_loop_proxy(),
- scoped_ptr<PrefFilter>());
+ pref_file, message_loop_.task_runner(), scoped_ptr<PrefFilter>());
base::DictionaryValue* dict = new base::DictionaryValue;
dict->SetString("key", "value");
@@ -368,9 +355,7 @@ TEST_F(JsonPrefStoreTest, AsyncNonExistingFile) {
base::FilePath bogus_input_file = data_dir_.AppendASCII("read.txt");
ASSERT_FALSE(PathExists(bogus_input_file));
scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
- bogus_input_file,
- message_loop_.message_loop_proxy().get(),
- scoped_ptr<PrefFilter>());
+ bogus_input_file, message_loop_.task_runner(), scoped_ptr<PrefFilter>());
MockPrefStoreObserver mock_observer;
pref_store->AddObserver(&mock_observer);
@@ -398,10 +383,8 @@ TEST_F(JsonPrefStoreTest, ReadWithInterceptor) {
new InterceptingPrefFilter());
InterceptingPrefFilter* raw_intercepting_pref_filter_ =
intercepting_pref_filter.get();
- scoped_refptr<JsonPrefStore> pref_store =
- new JsonPrefStore(input_file,
- message_loop_.message_loop_proxy().get(),
- intercepting_pref_filter.Pass());
+ scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
+ input_file, message_loop_.task_runner(), intercepting_pref_filter.Pass());
ASSERT_EQ(PersistentPrefStore::PREF_READ_ERROR_ASYNCHRONOUS_TASK_INCOMPLETE,
pref_store->ReadPrefs());
@@ -445,10 +428,8 @@ TEST_F(JsonPrefStoreTest, ReadAsyncWithInterceptor) {
new InterceptingPrefFilter());
InterceptingPrefFilter* raw_intercepting_pref_filter_ =
intercepting_pref_filter.get();
- scoped_refptr<JsonPrefStore> pref_store =
- new JsonPrefStore(input_file,
- message_loop_.message_loop_proxy().get(),
- intercepting_pref_filter.Pass());
+ scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
+ input_file, message_loop_.task_runner(), intercepting_pref_filter.Pass());
MockPrefStoreObserver mock_observer;
pref_store->AddObserver(&mock_observer);
@@ -511,11 +492,9 @@ TEST_F(JsonPrefStoreTest, AlternateFile) {
temp_dir_.path().AppendASCII("alternate.json");
ASSERT_FALSE(PathExists(input_file));
ASSERT_TRUE(PathExists(alternate_input_file));
- scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
- input_file,
- alternate_input_file,
- message_loop_.message_loop_proxy().get(),
- scoped_ptr<PrefFilter>());
+ scoped_refptr<JsonPrefStore> pref_store =
+ new JsonPrefStore(input_file, alternate_input_file,
+ message_loop_.task_runner(), scoped_ptr<PrefFilter>());
ASSERT_FALSE(PathExists(input_file));
ASSERT_TRUE(PathExists(alternate_input_file));
@@ -557,11 +536,9 @@ TEST_F(JsonPrefStoreTest, AlternateFileIgnoredWhenMainFileExists) {
temp_dir_.path().AppendASCII("alternate.json");
ASSERT_TRUE(PathExists(input_file));
ASSERT_TRUE(PathExists(alternate_input_file));
- scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
- input_file,
- alternate_input_file,
- message_loop_.message_loop_proxy().get(),
- scoped_ptr<PrefFilter>());
+ scoped_refptr<JsonPrefStore> pref_store =
+ new JsonPrefStore(input_file, alternate_input_file,
+ message_loop_.task_runner(), scoped_ptr<PrefFilter>());
ASSERT_TRUE(PathExists(input_file));
ASSERT_TRUE(PathExists(alternate_input_file));
@@ -599,11 +576,9 @@ TEST_F(JsonPrefStoreTest, AlternateFileDNE) {
temp_dir_.path().AppendASCII("alternate.json");
ASSERT_TRUE(PathExists(input_file));
ASSERT_FALSE(PathExists(alternate_input_file));
- scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
- input_file,
- alternate_input_file,
- message_loop_.message_loop_proxy().get(),
- scoped_ptr<PrefFilter>());
+ scoped_refptr<JsonPrefStore> pref_store =
+ new JsonPrefStore(input_file, alternate_input_file,
+ message_loop_.task_runner(), scoped_ptr<PrefFilter>());
ASSERT_TRUE(PathExists(input_file));
ASSERT_FALSE(PathExists(alternate_input_file));
@@ -641,11 +616,9 @@ TEST_F(JsonPrefStoreTest, BasicAsyncWithAlternateFile) {
temp_dir_.path().AppendASCII("alternate.json");
ASSERT_FALSE(PathExists(input_file));
ASSERT_TRUE(PathExists(alternate_input_file));
- scoped_refptr<JsonPrefStore> pref_store = new JsonPrefStore(
- input_file,
- alternate_input_file,
- message_loop_.message_loop_proxy().get(),
- scoped_ptr<PrefFilter>());
+ scoped_refptr<JsonPrefStore> pref_store =
+ new JsonPrefStore(input_file, alternate_input_file,
+ message_loop_.task_runner(), scoped_ptr<PrefFilter>());
ASSERT_FALSE(PathExists(input_file));
ASSERT_TRUE(PathExists(alternate_input_file));
« no previous file with comments | « base/prefs/json_pref_store.h ('k') | base/prefs/pref_member_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698