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

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

Issue 9006027: Rip Out the Sidebar API (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "chrome/common/extensions/extension.h" 5 #include "chrome/common/extensions/extension.h"
6 6
7 #if defined(TOOLKIT_GTK) 7 #if defined(TOOLKIT_GTK)
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 #endif 9 #endif
10 10
11 #include "base/command_line.h" 11 #include "base/command_line.h"
12 #include "base/file_path.h" 12 #include "base/file_path.h"
13 #include "base/file_util.h" 13 #include "base/file_util.h"
14 #include "base/i18n/rtl.h" 14 #include "base/i18n/rtl.h"
15 #include "base/json/json_value_serializer.h" 15 #include "base/json/json_value_serializer.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/path_service.h" 17 #include "base/path_service.h"
18 #include "base/string_number_conversions.h" 18 #include "base/string_number_conversions.h"
19 #include "base/string_util.h" 19 #include "base/string_util.h"
20 #include "base/stringprintf.h" 20 #include "base/stringprintf.h"
21 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
22 #include "chrome/common/chrome_paths.h" 22 #include "chrome/common/chrome_paths.h"
23 #include "chrome/common/chrome_switches.h" 23 #include "chrome/common/chrome_switches.h"
24 #include "chrome/common/extensions/extension.h" 24 #include "chrome/common/extensions/extension.h"
25 #include "chrome/common/extensions/extension_constants.h" 25 #include "chrome/common/extensions/extension_constants.h"
26 #include "chrome/common/extensions/extension_error_utils.h" 26 #include "chrome/common/extensions/extension_error_utils.h"
27 #include "chrome/common/extensions/extension_sidebar_defaults.h"
28 #include "chrome/common/extensions/file_browser_handler.h" 27 #include "chrome/common/extensions/file_browser_handler.h"
29 #include "chrome/common/extensions/url_pattern.h" 28 #include "chrome/common/extensions/url_pattern.h"
30 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
31 #include "ui/base/l10n/l10n_util.h" 30 #include "ui/base/l10n/l10n_util.h"
32 #include "webkit/glue/web_intent_service_data.h" 31 #include "webkit/glue/web_intent_service_data.h"
33 32
34 namespace { 33 namespace {
35 34
36 static void AddPattern(URLPatternSet* extent, const std::string& pattern) { 35 static void AddPattern(URLPatternSet* extent, const std::string& pattern) {
37 int schemes = URLPattern::SCHEME_ALL; 36 int schemes = URLPattern::SCHEME_ALL;
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 LoadAndExpectError("devtools_extension_url_invalid_type.json", 524 LoadAndExpectError("devtools_extension_url_invalid_type.json",
526 errors::kInvalidDevToolsPage); 525 errors::kInvalidDevToolsPage);
527 526
528 scoped_refptr<Extension> extension; 527 scoped_refptr<Extension> extension;
529 extension = LoadAndExpectSuccess("devtools_extension.json"); 528 extension = LoadAndExpectSuccess("devtools_extension.json");
530 EXPECT_EQ(extension->url().spec() + "devtools.html", 529 EXPECT_EQ(extension->url().spec() + "devtools.html",
531 extension->devtools_url().spec()); 530 extension->devtools_url().spec());
532 EXPECT_TRUE(extension->HasEffectiveAccessToAllHosts()); 531 EXPECT_TRUE(extension->HasEffectiveAccessToAllHosts());
533 } 532 }
534 533
535 TEST_F(ExtensionManifestTest, Sidebar) {
536 LoadAndExpectError("sidebar.json",
537 errors::kExperimentalFlagRequired);
538
539 CommandLine::ForCurrentProcess()->AppendSwitch(
540 switches::kEnableExperimentalExtensionApis);
541
542 LoadAndExpectError("sidebar_no_permissions.json",
543 errors::kSidebarExperimental);
544
545 LoadAndExpectError("sidebar_icon_empty.json",
546 errors::kInvalidSidebarDefaultIconPath);
547 LoadAndExpectError("sidebar_icon_invalid_type.json",
548 errors::kInvalidSidebarDefaultIconPath);
549 LoadAndExpectError("sidebar_page_empty.json",
550 errors::kInvalidSidebarDefaultPage);
551 LoadAndExpectError("sidebar_page_invalid_type.json",
552 errors::kInvalidSidebarDefaultPage);
553 LoadAndExpectError("sidebar_title_invalid_type.json",
554 errors::kInvalidSidebarDefaultTitle);
555
556 scoped_refptr<Extension> extension(LoadAndExpectSuccess("sidebar.json"));
557 ASSERT_TRUE(extension->sidebar_defaults() != NULL);
558 EXPECT_EQ(extension->sidebar_defaults()->default_title(),
559 ASCIIToUTF16("Default title"));
560 EXPECT_EQ(extension->sidebar_defaults()->default_icon_path(),
561 "icon.png");
562 EXPECT_EQ(extension->url().spec() + "sidebar.html",
563 extension->sidebar_defaults()->default_page().spec());
564 }
565
566 TEST_F(ExtensionManifestTest, BackgroundPermission) { 534 TEST_F(ExtensionManifestTest, BackgroundPermission) {
567 LoadAndExpectError("background_permission.json", 535 LoadAndExpectError("background_permission.json",
568 errors::kBackgroundPermissionNeeded); 536 errors::kBackgroundPermissionNeeded);
569 } 537 }
570 538
571 TEST_F(ExtensionManifestTest, OptionsPageInApps) { 539 TEST_F(ExtensionManifestTest, OptionsPageInApps) {
572 scoped_refptr<Extension> extension; 540 scoped_refptr<Extension> extension;
573 541
574 // Allow options page with absolute URL in hosted apps. 542 // Allow options page with absolute URL in hosted apps.
575 extension = LoadAndExpectSuccess("hosted_app_absolute_options.json"); 543 extension = LoadAndExpectSuccess("hosted_app_absolute_options.json");
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 // This guy is identical to the previous but doesn't ask for any 924 // This guy is identical to the previous but doesn't ask for any
957 // platform-app-only permissions. We should be able to load him and ask 925 // platform-app-only permissions. We should be able to load him and ask
958 // questions about his permissions. 926 // questions about his permissions.
959 scoped_refptr<Extension> extension( 927 scoped_refptr<Extension> extension(
960 LoadAndExpectSuccess("not_platform_app.json")); 928 LoadAndExpectSuccess("not_platform_app.json"));
961 ExtensionAPIPermissionSet apis = extension->GetActivePermissions()->apis(); 929 ExtensionAPIPermissionSet apis = extension->GetActivePermissions()->apis();
962 for (ExtensionAPIPermissionSet::const_iterator i = apis.begin(); 930 for (ExtensionAPIPermissionSet::const_iterator i = apis.begin();
963 i != apis.end(); ++i) 931 i != apis.end(); ++i)
964 EXPECT_NE(platform_app, info->GetByID(*i)->type_restrictions()); 932 EXPECT_NE(platform_app, info->GetByID(*i)->type_restrictions());
965 } 933 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698