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

Side by Side Diff: chrome/browser/extensions/extension_pref_store_unittest.cc

Issue 5204006: Renamed DefaultPrefStore into InMemoryPrefStore because it can be used in further contexts. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Rebased Created 10 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 | « no previous file | chrome/browser/prefs/default_pref_store.cc » ('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) 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 "chrome/test/testing_pref_value_store.h" 17 #include "chrome/test/testing_pref_value_store.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 keys = extension_manifest_keys; 21 namespace keys = extension_manifest_keys;
22 22
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 EXPECT_EQ("val4", actual); 330 EXPECT_EQ("val4", actual);
331 EXPECT_TRUE(prefs->GetString(kPref3, &actual)); 331 EXPECT_TRUE(prefs->GetString(kPref3, &actual));
332 EXPECT_EQ("val6", actual); 332 EXPECT_EQ("val6", actual);
333 EXPECT_FALSE(prefs->GetString(kPref4, &actual)); 333 EXPECT_FALSE(prefs->GetString(kPref4, &actual));
334 } 334 }
335 335
336 TEST(ExtensionPrefStoreTest, NotifyWhenNeeded) { 336 TEST(ExtensionPrefStoreTest, NotifyWhenNeeded) {
337 using testing::Mock; 337 using testing::Mock;
338 338
339 TestExtensionPrefStore* eps = new TestExtensionPrefStore; 339 TestExtensionPrefStore* eps = new TestExtensionPrefStore;
340 DefaultPrefStore* dps = new DefaultPrefStore; 340 InMemoryPrefStore* dps = new InMemoryPrefStore;
341 ASSERT_TRUE(eps->ext1 != NULL); 341 ASSERT_TRUE(eps->ext1 != NULL);
342 342
343 // The PrefValueStore takes ownership of the PrefStores; in this case, that's 343 // The PrefValueStore takes ownership of the PrefStores; in this case, that's
344 // only an ExtensionPrefStore. Likewise, the PrefService takes ownership of 344 // only an ExtensionPrefStore. Likewise, the PrefService takes ownership of
345 // the PrefValueStore and PrefNotifier. 345 // the PrefValueStore and PrefNotifier.
346 PrefValueStore* value_store = 346 PrefValueStore* value_store =
347 new TestingPrefValueStore(NULL, NULL, eps, NULL, NULL, NULL, dps); 347 new TestingPrefValueStore(NULL, NULL, eps, NULL, NULL, NULL, dps);
348 scoped_ptr<MockPrefService> pref_service(new MockPrefService(value_store)); 348 scoped_ptr<MockPrefService> pref_service(new MockPrefService(value_store));
349 MockPrefNotifier* pref_notifier = new MockPrefNotifier(pref_service.get(), 349 MockPrefNotifier* pref_notifier = new MockPrefNotifier(pref_service.get(),
350 value_store); 350 value_store);
(...skipping 10 matching lines...) Expand all
361 EXPECT_CALL(*pref_notifier, FireObservers(kPref1)).Times(0); 361 EXPECT_CALL(*pref_notifier, FireObservers(kPref1)).Times(0);
362 eps->InstallExtensionPref(eps->ext1, kPref1, 362 eps->InstallExtensionPref(eps->ext1, kPref1,
363 Value::CreateStringValue("https://www.chromium.org")); 363 Value::CreateStringValue("https://www.chromium.org"));
364 Mock::VerifyAndClearExpectations(pref_notifier); 364 Mock::VerifyAndClearExpectations(pref_notifier);
365 365
366 EXPECT_CALL(*pref_notifier, FireObservers(kPref1)).Times(2); 366 EXPECT_CALL(*pref_notifier, FireObservers(kPref1)).Times(2);
367 eps->InstallExtensionPref(eps->ext1, kPref1, 367 eps->InstallExtensionPref(eps->ext1, kPref1,
368 Value::CreateStringValue("chrome://newtab")); 368 Value::CreateStringValue("chrome://newtab"));
369 eps->UninstallExtension(eps->ext1); 369 eps->UninstallExtension(eps->ext1);
370 } 370 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/prefs/default_pref_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698