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

Side by Side Diff: chrome/common/extensions/extension_manifests_unittest.cc

Issue 6321006: Add "sidebar" section to extension manifest:... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months 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) 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "base/utf_string_conversions.h"
11 #include "chrome/common/chrome_paths.h" 12 #include "chrome/common/chrome_paths.h"
12 #include "chrome/common/chrome_switches.h" 13 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/extensions/extension.h" 14 #include "chrome/common/extensions/extension.h"
14 #include "chrome/common/extensions/extension_constants.h" 15 #include "chrome/common/extensions/extension_constants.h"
15 #include "chrome/common/extensions/extension_error_utils.h" 16 #include "chrome/common/extensions/extension_error_utils.h"
17 #include "chrome/common/extensions/extension_sidebar_defaults.h"
16 #include "chrome/common/json_value_serializer.h" 18 #include "chrome/common/json_value_serializer.h"
17 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
18 20
19 namespace errors = extension_manifest_errors; 21 namespace errors = extension_manifest_errors;
20 namespace keys = extension_manifest_keys; 22 namespace keys = extension_manifest_keys;
21 23
22 class ExtensionManifestTest : public testing::Test { 24 class ExtensionManifestTest : public testing::Test {
23 public: 25 public:
24 ExtensionManifestTest() : enable_apps_(true) {} 26 ExtensionManifestTest() : enable_apps_(true) {}
25 27
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 CommandLine::ForCurrentProcess()->AppendSwitch( 266 CommandLine::ForCurrentProcess()->AppendSwitch(
265 switches::kEnableExperimentalExtensionApis); 267 switches::kEnableExperimentalExtensionApis);
266 268
267 scoped_refptr<Extension> extension; 269 scoped_refptr<Extension> extension;
268 extension = LoadAndExpectSuccess("devtools_extension.json"); 270 extension = LoadAndExpectSuccess("devtools_extension.json");
269 EXPECT_EQ(extension->url().spec() + "devtools.html", 271 EXPECT_EQ(extension->url().spec() + "devtools.html",
270 extension->devtools_url().spec()); 272 extension->devtools_url().spec());
271 *CommandLine::ForCurrentProcess() = old_command_line; 273 *CommandLine::ForCurrentProcess() = old_command_line;
272 } 274 }
273 275
276 TEST_F(ExtensionManifestTest, Sidebar) {
277 LoadAndExpectError("sidebar.json",
278 errors::kExperimentalFlagRequired);
279
280 CommandLine old_command_line = *CommandLine::ForCurrentProcess();
281 CommandLine::ForCurrentProcess()->AppendSwitch(
282 switches::kEnableExperimentalExtensionApis);
283
284 LoadAndExpectError("sidebar_no_permissions.json",
285 errors::kSidebarExperimental);
286
287 LoadAndExpectError("sidebar_icon_empty.json",
288 errors::kInvalidSidebarDefaultIconPath);
289 LoadAndExpectError("sidebar_icon_invalid_type.json",
290 errors::kInvalidSidebarDefaultIconPath);
291 LoadAndExpectError("sidebar_title_invalid_type.json",
292 errors::kInvalidSidebarDefaultTitle);
293 LoadAndExpectError("sidebar_url_invalid.json",
294 errors::kInvalidSidebarDefaultUrl);
295 LoadAndExpectError("sidebar_url_invalid_type.json",
296 errors::kInvalidSidebarDefaultUrl);
297 LoadAndExpectError("sidebar_url_no_permissions.json",
298 extension_manifest_errors::kCannotAccessPage);
299
300 scoped_refptr<Extension> extension(LoadAndExpectSuccess("sidebar.json"));
301 ASSERT_TRUE(extension->sidebar_defaults() != NULL);
302 EXPECT_EQ(extension->sidebar_defaults()->default_title(),
303 ASCIIToUTF16("Default title"));
304 EXPECT_EQ(extension->sidebar_defaults()->default_icon_path(),
305 "icon.png");
306 EXPECT_EQ(extension->url().spec() + "sidebar.html",
307 extension->sidebar_defaults()->default_url().spec());
308
309 scoped_refptr<Extension> extension_external_url(
310 LoadAndExpectSuccess("sidebar_external_url.json"));
311 EXPECT_EQ("http://sidebar.url/sidebar.html",
312 extension_external_url->sidebar_defaults()->default_url().spec());
313
314 *CommandLine::ForCurrentProcess() = old_command_line;
315 }
316
274 TEST_F(ExtensionManifestTest, DisallowHybridApps) { 317 TEST_F(ExtensionManifestTest, DisallowHybridApps) {
275 LoadAndExpectError("disallow_hybrid_1.json", 318 LoadAndExpectError("disallow_hybrid_1.json",
276 errors::kHostedAppsCannotIncludeExtensionFeatures); 319 errors::kHostedAppsCannotIncludeExtensionFeatures);
277 LoadAndExpectError("disallow_hybrid_2.json", 320 LoadAndExpectError("disallow_hybrid_2.json",
278 errors::kHostedAppsCannotIncludeExtensionFeatures); 321 errors::kHostedAppsCannotIncludeExtensionFeatures);
279 } 322 }
280 323
281 TEST_F(ExtensionManifestTest, OptionsPageInApps) { 324 TEST_F(ExtensionManifestTest, OptionsPageInApps) {
282 scoped_refptr<Extension> extension; 325 scoped_refptr<Extension> extension;
283 326
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 extension_manifest_errors::kInvalidTtsVoicesGender); 444 extension_manifest_errors::kInvalidTtsVoicesGender);
402 445
403 scoped_refptr<Extension> extension( 446 scoped_refptr<Extension> extension(
404 LoadAndExpectSuccess("tts_provider_valid.json")); 447 LoadAndExpectSuccess("tts_provider_valid.json"));
405 448
406 ASSERT_EQ(1u, extension->tts_voices().size()); 449 ASSERT_EQ(1u, extension->tts_voices().size());
407 EXPECT_EQ("name", extension->tts_voices()[0].voice_name); 450 EXPECT_EQ("name", extension->tts_voices()[0].voice_name);
408 EXPECT_EQ("en-US", extension->tts_voices()[0].locale); 451 EXPECT_EQ("en-US", extension->tts_voices()[0].locale);
409 EXPECT_EQ("female", extension->tts_voices()[0].gender); 452 EXPECT_EQ("female", extension->tts_voices()[0].gender);
410 } 453 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_constants.cc ('k') | chrome/common/extensions/extension_sidebar_defaults.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698