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

Side by Side Diff: base/prefs/json_pref_store_unittest.cc

Issue 11411159: base/prefs: Break the dependency in chrome_paths.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/prefs/json_pref_store.h"
6
5 #include "base/file_util.h" 7 #include "base/file_util.h"
6 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
7 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
9 #include "base/path_service.h" 11 #include "base/path_service.h"
10 #include "base/prefs/json_pref_store.h" 12 #include "base/prefs/pref_paths.h"
11 #include "base/string_number_conversions.h" 13 #include "base/string_number_conversions.h"
12 #include "base/string_util.h" 14 #include "base/string_util.h"
13 #include "base/threading/sequenced_worker_pool.h" 15 #include "base/threading/sequenced_worker_pool.h"
14 #include "base/threading/thread.h" 16 #include "base/threading/thread.h"
15 #include "base/utf_string_conversions.h" 17 #include "base/utf_string_conversions.h"
16 #include "base/values.h" 18 #include "base/values.h"
17 #include "chrome/common/chrome_paths.h"
18 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
20 21
21 namespace { 22 namespace {
22 23
23 const char kHomePage[] = "homepage"; 24 const char kHomePage[] = "homepage";
24 25
25 class MockPrefStoreObserver : public PrefStore::Observer { 26 class MockPrefStoreObserver : public PrefStore::Observer {
26 public: 27 public:
27 MOCK_METHOD1(OnPrefValueChanged, void (const std::string&)); 28 MOCK_METHOD1(OnPrefValueChanged, void (const std::string&));
28 MOCK_METHOD1(OnInitializationCompleted, void (bool)); 29 MOCK_METHOD1(OnInitializationCompleted, void (bool));
29 }; 30 };
30 31
31 class MockReadErrorDelegate : public PersistentPrefStore::ReadErrorDelegate { 32 class MockReadErrorDelegate : public PersistentPrefStore::ReadErrorDelegate {
32 public: 33 public:
33 MOCK_METHOD1(OnError, void(PersistentPrefStore::PrefReadError)); 34 MOCK_METHOD1(OnError, void(PersistentPrefStore::PrefReadError));
34 }; 35 };
35 36
36 } // namespace 37 } // namespace
37 38
38 class JsonPrefStoreTest : public testing::Test { 39 class JsonPrefStoreTest : public testing::Test {
39 protected: 40 protected:
40 virtual void SetUp() OVERRIDE { 41 virtual void SetUp() OVERRIDE {
41 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 42 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
42 43
43 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_dir_)); 44 ASSERT_TRUE(PathService::Get(base::prefs::DIR_TEST_DATA, &data_dir_));
44 data_dir_ = data_dir_.AppendASCII("pref_service"); 45 data_dir_ = data_dir_.AppendASCII("pref_service");
45 ASSERT_TRUE(file_util::PathExists(data_dir_)); 46 ASSERT_TRUE(file_util::PathExists(data_dir_));
46 } 47 }
47 48
48 // The path to temporary directory used to contain the test operations. 49 // The path to temporary directory used to contain the test operations.
49 base::ScopedTempDir temp_dir_; 50 base::ScopedTempDir temp_dir_;
50 // The path to the directory where the test data is stored. 51 // The path to the directory where the test data is stored.
51 FilePath data_dir_; 52 FilePath data_dir_;
52 // A message loop that we can use as the file thread message loop. 53 // A message loop that we can use as the file thread message loop.
53 MessageLoop message_loop_; 54 MessageLoop message_loop_;
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 // Write to file. 287 // Write to file.
287 pref_store->CommitPendingWrite(); 288 pref_store->CommitPendingWrite();
288 MessageLoop::current()->RunUntilIdle(); 289 MessageLoop::current()->RunUntilIdle();
289 290
290 // Compare to expected output. 291 // Compare to expected output.
291 FilePath golden_output_file = 292 FilePath golden_output_file =
292 data_dir_.AppendASCII("write.golden.need_empty_value.json"); 293 data_dir_.AppendASCII("write.golden.need_empty_value.json");
293 ASSERT_TRUE(file_util::PathExists(golden_output_file)); 294 ASSERT_TRUE(file_util::PathExists(golden_output_file));
294 EXPECT_TRUE(file_util::TextContentsEqual(golden_output_file, pref_file)); 295 EXPECT_TRUE(file_util::TextContentsEqual(golden_output_file, pref_file));
295 } 296 }
OLDNEW
« no previous file with comments | « base/prefs/DEPS ('k') | base/prefs/pref_paths.h » ('j') | base/prefs/pref_paths.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698