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

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

Issue 11570009: Split PrefService into PrefService, PrefServiceSimple and PrefServiceSyncable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. 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
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 <string> 5 #include <string>
6 6
7 #include "chrome/browser/extensions/component_loader.h" 7 #include "chrome/browser/extensions/component_loader.h"
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 68
69 } // namespace 69 } // namespace
70 70
71 namespace extensions { 71 namespace extensions {
72 72
73 class ComponentLoaderTest : public testing::Test { 73 class ComponentLoaderTest : public testing::Test {
74 public: 74 public:
75 ComponentLoaderTest() : 75 ComponentLoaderTest() :
76 // Note: we pass the same pref service here, to stand in for both 76 // Note: we pass the same pref service here, to stand in for both
77 // user prefs and local state. 77 // user prefs and local state.
78 component_loader_(&extension_service_, &prefs_, &prefs_) { 78 component_loader_(&extension_service_, &prefs_, &local_state_) {
79 } 79 }
80 80
81 void SetUp() { 81 void SetUp() {
82 extension_path_ = 82 extension_path_ =
83 GetBasePath().AppendASCII("good") 83 GetBasePath().AppendASCII("good")
84 .AppendASCII("Extensions") 84 .AppendASCII("Extensions")
85 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 85 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
86 .AppendASCII("1.0.0.0"); 86 .AppendASCII("1.0.0.0");
87 87
88 // Read in the extension manifest. 88 // Read in the extension manifest.
89 ASSERT_TRUE(file_util::ReadFileToString( 89 ASSERT_TRUE(file_util::ReadFileToString(
90 extension_path_.Append(Extension::kManifestFilename), 90 extension_path_.Append(Extension::kManifestFilename),
91 &manifest_contents_)); 91 &manifest_contents_));
92 92
93 // Register the user prefs that ComponentLoader will read. 93 // Register the user prefs that ComponentLoader will read.
94 prefs_.RegisterStringPref(prefs::kEnterpriseWebStoreURL, std::string()); 94 prefs_.RegisterStringPref(prefs::kEnterpriseWebStoreURL,
95 prefs_.RegisterStringPref(prefs::kEnterpriseWebStoreName, std::string()); 95 std::string(),
96 PrefServiceSyncable::UNSYNCABLE_PREF);
97 prefs_.RegisterStringPref(prefs::kEnterpriseWebStoreName,
98 std::string(),
99 PrefServiceSyncable::UNSYNCABLE_PREF);
96 100
97 // Register the local state prefs. 101 // Register the local state prefs.
98 #if defined(OS_CHROMEOS) 102 #if defined(OS_CHROMEOS)
99 prefs_.RegisterBooleanPref(prefs::kSpokenFeedbackEnabled, false); 103 local_state_.RegisterBooleanPref(prefs::kSpokenFeedbackEnabled, false);
100 #endif 104 #endif
101 } 105 }
102 106
103 protected: 107 protected:
104 MockExtensionService extension_service_; 108 MockExtensionService extension_service_;
105 TestingPrefService prefs_; 109 TestingPrefServiceSyncable prefs_;
110 TestingPrefServiceSimple local_state_;
106 ComponentLoader component_loader_; 111 ComponentLoader component_loader_;
107 112
108 // The root directory of the text extension. 113 // The root directory of the text extension.
109 FilePath extension_path_; 114 FilePath extension_path_;
110 115
111 // The contents of the text extension's manifest file. 116 // The contents of the text extension's manifest file.
112 std::string manifest_contents_; 117 std::string manifest_contents_;
113 118
114 FilePath GetBasePath() { 119 FilePath GetBasePath() {
115 FilePath test_data_dir; 120 FilePath test_data_dir;
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 EXPECT_EQ(default_count + 1, extension_service_.extensions()->size()); 303 EXPECT_EQ(default_count + 1, extension_service_.extensions()->size());
299 EXPECT_EQ(0u, extension_service_.unloaded_count()); 304 EXPECT_EQ(0u, extension_service_.unloaded_count());
300 305
301 // replace loaded component extension. 306 // replace loaded component extension.
302 component_loader_.AddOrReplace(known_extension); 307 component_loader_.AddOrReplace(known_extension);
303 EXPECT_EQ(default_count + 1, extension_service_.extensions()->size()); 308 EXPECT_EQ(default_count + 1, extension_service_.extensions()->size());
304 EXPECT_EQ(1u, extension_service_.unloaded_count()); 309 EXPECT_EQ(1u, extension_service_.unloaded_count());
305 } 310 }
306 311
307 } // namespace extensions 312 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698