OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 }; | 143 }; |
144 | 144 |
145 class ExtensionMessageBubbleTest : public BrowserWithTestWindowTest { | 145 class ExtensionMessageBubbleTest : public BrowserWithTestWindowTest { |
146 public: | 146 public: |
147 ExtensionMessageBubbleTest() {} | 147 ExtensionMessageBubbleTest() {} |
148 | 148 |
149 testing::AssertionResult LoadGenericExtension(const std::string& index, | 149 testing::AssertionResult LoadGenericExtension(const std::string& index, |
150 const std::string& id, | 150 const std::string& id, |
151 Manifest::Location location) { | 151 Manifest::Location location) { |
152 ExtensionBuilder builder; | 152 ExtensionBuilder builder; |
153 builder.SetManifest( | 153 builder.SetManifest(DictionaryBuilder() |
154 std::move(DictionaryBuilder() | 154 .Set("name", std::string("Extension " + index)) |
155 .Set("name", std::string("Extension " + index)) | 155 .Set("version", "1.0") |
156 .Set("version", "1.0") | 156 .Set("manifest_version", 2) |
157 .Set("manifest_version", 2))); | 157 .Build()); |
158 builder.SetLocation(location); | 158 builder.SetLocation(location); |
159 builder.SetID(id); | 159 builder.SetID(id); |
160 service_->AddExtension(builder.Build().get()); | 160 service_->AddExtension(builder.Build().get()); |
161 | 161 |
162 if (ExtensionRegistry::Get(profile())->enabled_extensions().GetByID(id)) | 162 if (ExtensionRegistry::Get(profile())->enabled_extensions().GetByID(id)) |
163 return testing::AssertionSuccess(); | 163 return testing::AssertionSuccess(); |
164 return testing::AssertionFailure() << "Could not install extension: " << id; | 164 return testing::AssertionFailure() << "Could not install extension: " << id; |
165 } | 165 } |
166 | 166 |
167 testing::AssertionResult LoadExtensionWithAction( | 167 testing::AssertionResult LoadExtensionWithAction( |
168 const std::string& index, | 168 const std::string& index, |
169 const std::string& id, | 169 const std::string& id, |
170 Manifest::Location location) { | 170 Manifest::Location location) { |
171 ExtensionBuilder builder; | 171 ExtensionBuilder builder; |
172 builder.SetManifest(std::move( | 172 builder.SetManifest( |
173 DictionaryBuilder() | 173 DictionaryBuilder() |
174 .Set("name", std::string("Extension " + index)) | 174 .Set("name", std::string("Extension " + index)) |
175 .Set("version", "1.0") | 175 .Set("version", "1.0") |
176 .Set("manifest_version", 2) | 176 .Set("manifest_version", 2) |
177 .Set("browser_action", std::move(DictionaryBuilder().Set( | 177 .Set("browser_action", DictionaryBuilder() |
178 "default_title", "Default title"))))); | 178 .Set("default_title", "Default title") |
| 179 .Build()) |
| 180 .Build()); |
179 builder.SetLocation(location); | 181 builder.SetLocation(location); |
180 builder.SetID(id); | 182 builder.SetID(id); |
181 service_->AddExtension(builder.Build().get()); | 183 service_->AddExtension(builder.Build().get()); |
182 | 184 |
183 if (ExtensionRegistry::Get(profile())->enabled_extensions().GetByID(id)) | 185 if (ExtensionRegistry::Get(profile())->enabled_extensions().GetByID(id)) |
184 return testing::AssertionSuccess(); | 186 return testing::AssertionSuccess(); |
185 return testing::AssertionFailure() << "Could not install extension: " << id; | 187 return testing::AssertionFailure() << "Could not install extension: " << id; |
186 } | 188 } |
187 | 189 |
188 testing::AssertionResult LoadExtensionOverridingHome( | 190 testing::AssertionResult LoadExtensionOverridingHome( |
189 const std::string& index, | 191 const std::string& index, |
190 const std::string& id, | 192 const std::string& id, |
191 Manifest::Location location) { | 193 Manifest::Location location) { |
192 ExtensionBuilder builder; | 194 ExtensionBuilder builder; |
193 builder.SetManifest( | 195 builder.SetManifest(DictionaryBuilder() |
194 std::move(DictionaryBuilder() | 196 .Set("name", std::string("Extension " + index)) |
195 .Set("name", std::string("Extension " + index)) | 197 .Set("version", "1.0") |
196 .Set("version", "1.0") | 198 .Set("manifest_version", 2) |
197 .Set("manifest_version", 2) | 199 .Set("chrome_settings_overrides", |
198 .Set("chrome_settings_overrides", | 200 DictionaryBuilder() |
199 std::move(DictionaryBuilder().Set( | 201 .Set("homepage", "http://www.google.com") |
200 "homepage", "http://www.google.com"))))); | 202 .Build()) |
| 203 .Build()); |
201 builder.SetLocation(location); | 204 builder.SetLocation(location); |
202 builder.SetID(id); | 205 builder.SetID(id); |
203 service_->AddExtension(builder.Build().get()); | 206 service_->AddExtension(builder.Build().get()); |
204 | 207 |
205 if (ExtensionRegistry::Get(profile())->enabled_extensions().GetByID(id)) | 208 if (ExtensionRegistry::Get(profile())->enabled_extensions().GetByID(id)) |
206 return testing::AssertionSuccess(); | 209 return testing::AssertionSuccess(); |
207 return testing::AssertionFailure() << "Could not install extension: " << id; | 210 return testing::AssertionFailure() << "Could not install extension: " << id; |
208 } | 211 } |
209 | 212 |
210 testing::AssertionResult LoadExtensionOverridingStart( | 213 testing::AssertionResult LoadExtensionOverridingStart( |
211 const std::string& index, | 214 const std::string& index, |
212 const std::string& id, | 215 const std::string& id, |
213 Manifest::Location location) { | 216 Manifest::Location location) { |
214 ExtensionBuilder builder; | 217 ExtensionBuilder builder; |
215 builder.SetManifest(std::move( | 218 builder.SetManifest( |
216 DictionaryBuilder() | 219 DictionaryBuilder() |
217 .Set("name", std::string("Extension " + index)) | 220 .Set("name", std::string("Extension " + index)) |
218 .Set("version", "1.0") | 221 .Set("version", "1.0") |
219 .Set("manifest_version", 2) | 222 .Set("manifest_version", 2) |
220 .Set("chrome_settings_overrides", | 223 .Set("chrome_settings_overrides", |
221 std::move(DictionaryBuilder().Set( | 224 DictionaryBuilder() |
222 "startup_pages", std::move(ListBuilder().Append( | 225 .Set("startup_pages", |
223 "http://www.google.com"))))))); | 226 ListBuilder().Append("http://www.google.com").Build()) |
| 227 .Build()) |
| 228 .Build()); |
224 builder.SetLocation(location); | 229 builder.SetLocation(location); |
225 builder.SetID(id); | 230 builder.SetID(id); |
226 service_->AddExtension(builder.Build().get()); | 231 service_->AddExtension(builder.Build().get()); |
227 | 232 |
228 if (ExtensionRegistry::Get(profile())->enabled_extensions().GetByID(id)) | 233 if (ExtensionRegistry::Get(profile())->enabled_extensions().GetByID(id)) |
229 return testing::AssertionSuccess(); | 234 return testing::AssertionSuccess(); |
230 return testing::AssertionFailure() << "Could not install extension: " << id; | 235 return testing::AssertionFailure() << "Could not install extension: " << id; |
231 } | 236 } |
232 | 237 |
233 testing::AssertionResult LoadExtensionOverridingNtp( | 238 testing::AssertionResult LoadExtensionOverridingNtp( |
234 const std::string& index, | 239 const std::string& index, |
235 const std::string& id, | 240 const std::string& id, |
236 Manifest::Location location) { | 241 Manifest::Location location) { |
237 ExtensionBuilder builder; | 242 ExtensionBuilder builder; |
238 builder.SetManifest(std::move( | 243 builder.SetManifest( |
239 DictionaryBuilder() | 244 DictionaryBuilder() |
240 .Set("name", std::string("Extension " + index)) | 245 .Set("name", std::string("Extension " + index)) |
241 .Set("version", "1.0") | 246 .Set("version", "1.0") |
242 .Set("manifest_version", 2) | 247 .Set("manifest_version", 2) |
243 .Set("chrome_url_overrides", std::move(DictionaryBuilder().Set( | 248 .Set("chrome_url_overrides", |
244 "newtab", "Default.html"))))); | 249 DictionaryBuilder().Set("newtab", "Default.html").Build()) |
| 250 .Build()); |
245 | 251 |
246 builder.SetLocation(location); | 252 builder.SetLocation(location); |
247 builder.SetID(id); | 253 builder.SetID(id); |
248 service_->AddExtension(builder.Build().get()); | 254 service_->AddExtension(builder.Build().get()); |
249 | 255 |
250 if (ExtensionRegistry::Get(profile())->enabled_extensions().GetByID(id)) | 256 if (ExtensionRegistry::Get(profile())->enabled_extensions().GetByID(id)) |
251 return testing::AssertionSuccess(); | 257 return testing::AssertionSuccess(); |
252 return testing::AssertionFailure() << "Could not install extension: " << id; | 258 return testing::AssertionFailure() << "Could not install extension: " << id; |
253 } | 259 } |
254 | 260 |
255 testing::AssertionResult LoadExtensionOverridingProxy( | 261 testing::AssertionResult LoadExtensionOverridingProxy( |
256 const std::string& index, | 262 const std::string& index, |
257 const std::string& id, | 263 const std::string& id, |
258 Manifest::Location location) { | 264 Manifest::Location location) { |
259 ExtensionBuilder builder; | 265 ExtensionBuilder builder; |
260 builder.SetManifest(std::move( | 266 builder.SetManifest( |
261 DictionaryBuilder() | 267 DictionaryBuilder() |
262 .Set("name", std::string("Extension " + index)) | 268 .Set("name", std::string("Extension " + index)) |
263 .Set("version", "1.0") | 269 .Set("version", "1.0") |
264 .Set("manifest_version", 2) | 270 .Set("manifest_version", 2) |
265 .Set("permissions", std::move(ListBuilder().Append("proxy"))))); | 271 .Set("permissions", ListBuilder().Append("proxy").Build()) |
| 272 .Build()); |
266 | 273 |
267 builder.SetLocation(location); | 274 builder.SetLocation(location); |
268 builder.SetID(id); | 275 builder.SetID(id); |
269 service_->AddExtension(builder.Build().get()); | 276 service_->AddExtension(builder.Build().get()); |
270 | 277 |
271 // The proxy check relies on ExtensionPrefValueMap being up to date as to | 278 // The proxy check relies on ExtensionPrefValueMap being up to date as to |
272 // specifying which extension is controlling the proxy, but unfortunately | 279 // specifying which extension is controlling the proxy, but unfortunately |
273 // that Map is not updated automatically for unit tests, so we simulate the | 280 // that Map is not updated automatically for unit tests, so we simulate the |
274 // update here to avoid test failures. | 281 // update here to avoid test failures. |
275 ExtensionPrefValueMap* extension_prefs_value_map = | 282 ExtensionPrefValueMap* extension_prefs_value_map = |
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
971 extensions::UNINSTALL_REASON_FOR_TESTING, | 978 extensions::UNINSTALL_REASON_FOR_TESTING, |
972 base::Bind(&base::DoNothing), | 979 base::Bind(&base::DoNothing), |
973 NULL); | 980 NULL); |
974 service_->UninstallExtension(kId3, | 981 service_->UninstallExtension(kId3, |
975 extensions::UNINSTALL_REASON_FOR_TESTING, | 982 extensions::UNINSTALL_REASON_FOR_TESTING, |
976 base::Bind(&base::DoNothing), | 983 base::Bind(&base::DoNothing), |
977 NULL); | 984 NULL); |
978 } | 985 } |
979 | 986 |
980 } // namespace extensions | 987 } // namespace extensions |
OLD | NEW |