| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/scoped_ptr.h" | 5 #include "base/scoped_ptr.h" |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "chrome/browser/configuration_policy_pref_store.h" | 8 #include "chrome/browser/configuration_policy_pref_store.h" |
| 9 #include "chrome/browser/chrome_thread.h" |
| 9 #include "chrome/browser/dummy_pref_store.h" | 10 #include "chrome/browser/dummy_pref_store.h" |
| 10 #include "chrome/browser/pref_value_store.h" | 11 #include "chrome/browser/pref_value_store.h" |
| 12 #include "chrome/test/testing_pref_service.h" |
| 11 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
| 12 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 13 | 15 |
| 14 using testing::_; | 16 using testing::_; |
| 15 using testing::Mock; | 17 using testing::Mock; |
| 16 | 18 |
| 17 // Names of the preferences used in this test program. | 19 // Names of the preferences used in this test program. |
| 18 namespace prefs { | 20 namespace prefs { |
| 19 const wchar_t kCurrentThemeID[] = L"extensions.theme.id"; | 21 const wchar_t kCurrentThemeID[] = L"extensions.theme.id"; |
| 20 const wchar_t kDeleteCache[] = L"browser.clear_data.cache"; | 22 const wchar_t kDeleteCache[] = L"browser.clear_data.cache"; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 extension_pref_store_->set_prefs(extension_prefs_); | 80 extension_pref_store_->set_prefs(extension_prefs_); |
| 79 command_line_pref_store_ = new DummyPrefStore(); | 81 command_line_pref_store_ = new DummyPrefStore(); |
| 80 command_line_pref_store_->set_prefs(command_line_prefs_); | 82 command_line_pref_store_->set_prefs(command_line_prefs_); |
| 81 user_pref_store_ = new DummyPrefStore(); | 83 user_pref_store_ = new DummyPrefStore(); |
| 82 user_pref_store_->set_read_only(false); | 84 user_pref_store_->set_read_only(false); |
| 83 user_pref_store_->set_prefs(user_prefs_); | 85 user_pref_store_->set_prefs(user_prefs_); |
| 84 recommended_pref_store_ = new DummyPrefStore(); | 86 recommended_pref_store_ = new DummyPrefStore(); |
| 85 recommended_pref_store_->set_prefs(recommended_prefs_); | 87 recommended_pref_store_->set_prefs(recommended_prefs_); |
| 86 | 88 |
| 87 // Create a new pref-value-store. | 89 // Create a new pref-value-store. |
| 88 pref_value_store_ = new PrefValueStore(enforced_pref_store_, | 90 pref_value_store_ = new TestingPrefService::TestingPrefValueStore( |
| 89 extension_pref_store_, | 91 enforced_pref_store_, |
| 90 command_line_pref_store_, | 92 extension_pref_store_, |
| 91 user_pref_store_, | 93 command_line_pref_store_, |
| 92 recommended_pref_store_); | 94 user_pref_store_, |
| 95 recommended_pref_store_); |
| 93 | 96 |
| 94 ui_thread_.reset(new ChromeThread(ChromeThread::UI, &loop_)); | 97 ui_thread_.reset(new ChromeThread(ChromeThread::UI, &loop_)); |
| 95 file_thread_.reset(new ChromeThread(ChromeThread::FILE, &loop_)); | 98 file_thread_.reset(new ChromeThread(ChromeThread::FILE, &loop_)); |
| 96 } | 99 } |
| 97 | 100 |
| 98 // Creates a new dictionary and stores some sample user preferences | 101 // Creates a new dictionary and stores some sample user preferences |
| 99 // in it. | 102 // in it. |
| 100 DictionaryValue* CreateUserPrefs() { | 103 DictionaryValue* CreateUserPrefs() { |
| 101 DictionaryValue* user_prefs = new DictionaryValue(); | 104 DictionaryValue* user_prefs = new DictionaryValue(); |
| 102 user_prefs->SetBoolean(prefs::kDeleteCache, user_pref::kDeleteCacheValue); | 105 user_prefs->SetBoolean(prefs::kDeleteCache, user_pref::kDeleteCacheValue); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 sample_list->Set(3, Value::CreateIntegerValue(3)); | 172 sample_list->Set(3, Value::CreateIntegerValue(3)); |
| 170 return sample_list; | 173 return sample_list; |
| 171 } | 174 } |
| 172 | 175 |
| 173 virtual void TearDown() { | 176 virtual void TearDown() { |
| 174 loop_.RunAllPending(); | 177 loop_.RunAllPending(); |
| 175 } | 178 } |
| 176 | 179 |
| 177 MessageLoop loop_; | 180 MessageLoop loop_; |
| 178 | 181 |
| 179 scoped_refptr<PrefValueStore> pref_value_store_; | 182 scoped_refptr<TestingPrefService::TestingPrefValueStore> pref_value_store_; |
| 180 | 183 |
| 181 // |PrefStore|s are owned by the |PrefValueStore|. | 184 // |PrefStore|s are owned by the |PrefValueStore|. |
| 182 DummyPrefStore* enforced_pref_store_; | 185 DummyPrefStore* enforced_pref_store_; |
| 183 DummyPrefStore* extension_pref_store_; | 186 DummyPrefStore* extension_pref_store_; |
| 184 DummyPrefStore* command_line_pref_store_; | 187 DummyPrefStore* command_line_pref_store_; |
| 185 DummyPrefStore* recommended_pref_store_; | 188 DummyPrefStore* recommended_pref_store_; |
| 186 DummyPrefStore* user_pref_store_; | 189 DummyPrefStore* user_pref_store_; |
| 187 | 190 |
| 188 // A vector of the preferences paths in the managed and recommended | 191 // A vector of the preferences paths in the managed and recommended |
| 189 // PrefStores that are set at the beginning of a test. Can be modified | 192 // PrefStores that are set at the beginning of a test. Can be modified |
| (...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 Mock::VerifyAndClearExpectations(&callback1); | 585 Mock::VerifyAndClearExpectations(&callback1); |
| 583 Mock::VerifyAndClearExpectations(&callback2); | 586 Mock::VerifyAndClearExpectations(&callback2); |
| 584 Mock::VerifyAndClearExpectations(&callback3); | 587 Mock::VerifyAndClearExpectations(&callback3); |
| 585 | 588 |
| 586 EXPECT_CALL(callback1, DoCallback(expected_differing_paths_)).Times(1); | 589 EXPECT_CALL(callback1, DoCallback(expected_differing_paths_)).Times(1); |
| 587 std::vector<std::string> no_differing_paths; | 590 std::vector<std::string> no_differing_paths; |
| 588 EXPECT_CALL(callback2, DoCallback(no_differing_paths)).Times(1); | 591 EXPECT_CALL(callback2, DoCallback(no_differing_paths)).Times(1); |
| 589 EXPECT_CALL(callback3, DoCallback(no_differing_paths)).Times(1); | 592 EXPECT_CALL(callback3, DoCallback(no_differing_paths)).Times(1); |
| 590 loop_.RunAllPending(); | 593 loop_.RunAllPending(); |
| 591 } | 594 } |
| OLD | NEW |