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" |
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 DefaultPrefStore* dps = new DefaultPrefStore; |
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, 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); |
350 pref_service->SetPrefNotifier(pref_notifier); | 350 pref_service->SetPrefNotifier(pref_notifier); |
351 | 351 |
352 eps->SetPrefService(pref_service.get()); | 352 eps->SetPrefService(pref_service.get()); |
353 pref_service->RegisterStringPref(kPref1, std::string()); | 353 pref_service->RegisterStringPref(kPref1, std::string()); |
354 | 354 |
355 EXPECT_CALL(*pref_notifier, FireObservers(kPref1)); | 355 EXPECT_CALL(*pref_notifier, FireObservers(kPref1)); |
356 eps->InstallExtensionPref(eps->ext1, kPref1, | 356 eps->InstallExtensionPref(eps->ext1, kPref1, |
357 Value::CreateStringValue("https://www.chromium.org")); | 357 Value::CreateStringValue("https://www.chromium.org")); |
358 Mock::VerifyAndClearExpectations(pref_notifier); | 358 Mock::VerifyAndClearExpectations(pref_notifier); |
359 | 359 |
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 |