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

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: add path to fix android Created 8 years 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
« no previous file with comments | « base/prefs/DEPS ('k') | base/prefs/test/data/pref_service/invalid.json » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
12 #include "base/string_util.h" 13 #include "base/string_util.h"
13 #include "base/threading/sequenced_worker_pool.h" 14 #include "base/threading/sequenced_worker_pool.h"
14 #include "base/threading/thread.h" 15 #include "base/threading/thread.h"
15 #include "base/utf_string_conversions.h" 16 #include "base/utf_string_conversions.h"
16 #include "base/values.h" 17 #include "base/values.h"
17 #include "chrome/common/chrome_paths.h"
18 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 namespace { 21 namespace {
22 22
23 const char kHomePage[] = "homepage"; 23 const char kHomePage[] = "homepage";
24 24
25 class MockPrefStoreObserver : public PrefStore::Observer { 25 class MockPrefStoreObserver : public PrefStore::Observer {
26 public: 26 public:
27 MOCK_METHOD1(OnPrefValueChanged, void (const std::string&)); 27 MOCK_METHOD1(OnPrefValueChanged, void (const std::string&));
28 MOCK_METHOD1(OnInitializationCompleted, void (bool)); 28 MOCK_METHOD1(OnInitializationCompleted, void (bool));
29 }; 29 };
30 30
31 class MockReadErrorDelegate : public PersistentPrefStore::ReadErrorDelegate { 31 class MockReadErrorDelegate : public PersistentPrefStore::ReadErrorDelegate {
32 public: 32 public:
33 MOCK_METHOD1(OnError, void(PersistentPrefStore::PrefReadError)); 33 MOCK_METHOD1(OnError, void(PersistentPrefStore::PrefReadError));
34 }; 34 };
35 35
36 } // namespace 36 } // namespace
37 37
38 class JsonPrefStoreTest : public testing::Test { 38 class JsonPrefStoreTest : public testing::Test {
39 protected: 39 protected:
40 virtual void SetUp() OVERRIDE { 40 virtual void SetUp() OVERRIDE {
41 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 41 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
42 42
43 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &data_dir_)); 43 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_dir_));
44 data_dir_ = data_dir_.AppendASCII("base");
45 data_dir_ = data_dir_.AppendASCII("prefs");
46 data_dir_ = data_dir_.AppendASCII("test");
47 data_dir_ = data_dir_.AppendASCII("data");
44 data_dir_ = data_dir_.AppendASCII("pref_service"); 48 data_dir_ = data_dir_.AppendASCII("pref_service");
49 LOG(WARNING) << data_dir_.value();
45 ASSERT_TRUE(file_util::PathExists(data_dir_)); 50 ASSERT_TRUE(file_util::PathExists(data_dir_));
46 } 51 }
47 52
48 // The path to temporary directory used to contain the test operations. 53 // The path to temporary directory used to contain the test operations.
49 base::ScopedTempDir temp_dir_; 54 base::ScopedTempDir temp_dir_;
50 // The path to the directory where the test data is stored. 55 // The path to the directory where the test data is stored.
51 FilePath data_dir_; 56 FilePath data_dir_;
52 // A message loop that we can use as the file thread message loop. 57 // A message loop that we can use as the file thread message loop.
53 MessageLoop message_loop_; 58 MessageLoop message_loop_;
54 }; 59 };
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 // Write to file. 291 // Write to file.
287 pref_store->CommitPendingWrite(); 292 pref_store->CommitPendingWrite();
288 MessageLoop::current()->RunUntilIdle(); 293 MessageLoop::current()->RunUntilIdle();
289 294
290 // Compare to expected output. 295 // Compare to expected output.
291 FilePath golden_output_file = 296 FilePath golden_output_file =
292 data_dir_.AppendASCII("write.golden.need_empty_value.json"); 297 data_dir_.AppendASCII("write.golden.need_empty_value.json");
293 ASSERT_TRUE(file_util::PathExists(golden_output_file)); 298 ASSERT_TRUE(file_util::PathExists(golden_output_file));
294 EXPECT_TRUE(file_util::TextContentsEqual(golden_output_file, pref_file)); 299 EXPECT_TRUE(file_util::TextContentsEqual(golden_output_file, pref_file));
295 } 300 }
OLDNEW
« no previous file with comments | « base/prefs/DEPS ('k') | base/prefs/test/data/pref_service/invalid.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698