| 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/browser/extensions/extension_pref_store.h" | 11 #include "chrome/browser/extensions/extension_pref_store.h" |
| 12 #include "chrome/browser/prefs/default_pref_store.h" | 12 #include "chrome/browser/prefs/in_memory_pref_store.h" |
| 13 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
| 14 #include "chrome/browser/prefs/pref_value_store.h" | 14 #include "chrome/browser/prefs/pref_value_store.h" |
| 15 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
| 16 #include "chrome/test/testing_pref_service.h" | 16 #include "chrome/test/testing_pref_service.h" |
| 17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 19 |
| 20 namespace keys = extension_manifest_keys; | 20 namespace keys = extension_manifest_keys; |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 EXPECT_EQ("val4", actual); | 329 EXPECT_EQ("val4", actual); |
| 330 EXPECT_TRUE(prefs->GetString(kPref3, &actual)); | 330 EXPECT_TRUE(prefs->GetString(kPref3, &actual)); |
| 331 EXPECT_EQ("val6", actual); | 331 EXPECT_EQ("val6", actual); |
| 332 EXPECT_FALSE(prefs->GetString(kPref4, &actual)); | 332 EXPECT_FALSE(prefs->GetString(kPref4, &actual)); |
| 333 } | 333 } |
| 334 | 334 |
| 335 TEST(ExtensionPrefStoreTest, NotifyWhenNeeded) { | 335 TEST(ExtensionPrefStoreTest, NotifyWhenNeeded) { |
| 336 using testing::Mock; | 336 using testing::Mock; |
| 337 | 337 |
| 338 TestExtensionPrefStore* eps = new TestExtensionPrefStore; | 338 TestExtensionPrefStore* eps = new TestExtensionPrefStore; |
| 339 DefaultPrefStore* dps = new DefaultPrefStore; | 339 InMemoryPrefStore* dps = new InMemoryPrefStore; |
| 340 ASSERT_TRUE(eps->ext1 != NULL); | 340 ASSERT_TRUE(eps->ext1 != NULL); |
| 341 | 341 |
| 342 // The PrefValueStore takes ownership of the PrefStores; in this case, that's | 342 // The PrefValueStore takes ownership of the PrefStores; in this case, that's |
| 343 // only an ExtensionPrefStore. Likewise, the PrefService takes ownership of | 343 // only an ExtensionPrefStore. Likewise, the PrefService takes ownership of |
| 344 // the PrefValueStore and PrefNotifier. | 344 // the PrefValueStore and PrefNotifier. |
| 345 PrefValueStore* value_store = new TestingPrefService::TestingPrefValueStore( | 345 PrefValueStore* value_store = new TestingPrefService::TestingPrefValueStore( |
| 346 NULL, NULL, eps, NULL, NULL, NULL, dps); | 346 NULL, NULL, eps, NULL, NULL, NULL, dps); |
| 347 scoped_ptr<MockPrefService> pref_service(new MockPrefService(value_store)); | 347 scoped_ptr<MockPrefService> pref_service(new MockPrefService(value_store)); |
| 348 MockPrefNotifier* pref_notifier = new MockPrefNotifier(pref_service.get(), | 348 MockPrefNotifier* pref_notifier = new MockPrefNotifier(pref_service.get(), |
| 349 value_store); | 349 value_store); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 360 EXPECT_CALL(*pref_notifier, FireObservers(kPref1)).Times(0); | 360 EXPECT_CALL(*pref_notifier, FireObservers(kPref1)).Times(0); |
| 361 eps->InstallExtensionPref(eps->ext1, kPref1, | 361 eps->InstallExtensionPref(eps->ext1, kPref1, |
| 362 Value::CreateStringValue("https://www.chromium.org")); | 362 Value::CreateStringValue("https://www.chromium.org")); |
| 363 Mock::VerifyAndClearExpectations(pref_notifier); | 363 Mock::VerifyAndClearExpectations(pref_notifier); |
| 364 | 364 |
| 365 EXPECT_CALL(*pref_notifier, FireObservers(kPref1)).Times(2); | 365 EXPECT_CALL(*pref_notifier, FireObservers(kPref1)).Times(2); |
| 366 eps->InstallExtensionPref(eps->ext1, kPref1, | 366 eps->InstallExtensionPref(eps->ext1, kPref1, |
| 367 Value::CreateStringValue("chrome://newtab")); | 367 Value::CreateStringValue("chrome://newtab")); |
| 368 eps->UninstallExtension(eps->ext1); | 368 eps->UninstallExtension(eps->ext1); |
| 369 } | 369 } |
| OLD | NEW |