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

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

Issue 7917006: Extension loading extracts intents from Manifest data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed includes for moved headers Created 9 years, 3 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) 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
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 scoped_refptr<Extension> extension( 740 scoped_refptr<Extension> extension(
741 LoadAndExpectSuccess("tts_engine_valid.json")); 741 LoadAndExpectSuccess("tts_engine_valid.json"));
742 742
743 ASSERT_EQ(1u, extension->tts_voices().size()); 743 ASSERT_EQ(1u, extension->tts_voices().size());
744 EXPECT_EQ("name", extension->tts_voices()[0].voice_name); 744 EXPECT_EQ("name", extension->tts_voices()[0].voice_name);
745 EXPECT_EQ("en-US", extension->tts_voices()[0].lang); 745 EXPECT_EQ("en-US", extension->tts_voices()[0].lang);
746 EXPECT_EQ("female", extension->tts_voices()[0].gender); 746 EXPECT_EQ("female", extension->tts_voices()[0].gender);
747 EXPECT_EQ(3U, extension->tts_voices()[0].event_types.size()); 747 EXPECT_EQ(3U, extension->tts_voices()[0].event_types.size());
748 } 748 }
749 749
750 TEST_F(ExtensionManifestTest, WebIntents) {
751 CommandLine::ForCurrentProcess()->AppendSwitch("--enable-web-intents");
752
753 LoadAndExpectError("intent_invalid_1.json",
754 extension_manifest_errors::kInvalidIntents);
755 LoadAndExpectError("intent_invalid_2.json",
756 extension_manifest_errors::kInvalidIntent);
757 LoadAndExpectError("intent_invalid_3.json",
758 extension_manifest_errors::kInvalidIntentPath);
759 LoadAndExpectError("intent_invalid_4.json",
760 extension_manifest_errors::kInvalidIntentDisposition);
761 LoadAndExpectError("intent_invalid_5.json",
762 extension_manifest_errors::kInvalidIntentType);
763 LoadAndExpectError("intent_invalid_6.json",
764 extension_manifest_errors::kInvalidIntentTitle);
765
766 scoped_refptr<Extension> extension(
767 LoadAndExpectSuccess("intent_valid.json"));
768 ASSERT_TRUE(extension.get() != NULL);
769
770 ASSERT_EQ(1u, extension->intents().size());
771 EXPECT_EQ("image/png", UTF16ToUTF8(extension->intents()[0].type));
772 EXPECT_EQ("http://webintents.org/share",
773 UTF16ToUTF8(extension->intents()[0].action));
774 EXPECT_EQ("chrome-extension", extension->intents()[0].service_url.scheme());
775 EXPECT_EQ("///services/share", extension->intents()[0].service_url.path());
776 EXPECT_EQ("Sample Sharing Intent",
777 UTF16ToUTF8(extension->intents()[0].title));
778 EXPECT_EQ(WebIntentServiceData::DISPOSITION_INLINE,
779 extension->intents()[0].disposition);
780
781 // Verify that optional fields are filled with defaults.
782 extension = LoadAndExpectSuccess("intent_valid_minimal.json");
783 ASSERT_TRUE(extension.get() != NULL);
784
785 ASSERT_EQ(1u, extension->intents().size());
786 EXPECT_EQ("", UTF16ToUTF8(extension->intents()[0].type));
787 EXPECT_EQ("http://webintents.org/share",
788 UTF16ToUTF8(extension->intents()[0].action));
789 EXPECT_TRUE(extension->intents()[0].service_url.is_empty());
790 EXPECT_EQ("", UTF16ToUTF8(extension->intents()[0].title));
791 EXPECT_EQ(WebIntentServiceData::DISPOSITION_WINDOW,
792 extension->intents()[0].disposition);
793 }
794
750 TEST_F(ExtensionManifestTest, ForbidPortsInPermissions) { 795 TEST_F(ExtensionManifestTest, ForbidPortsInPermissions) {
751 // Loading as a user would shoud not trigger an error. 796 // Loading as a user would shoud not trigger an error.
752 LoadAndExpectSuccess("forbid_ports_in_permissions.json"); 797 LoadAndExpectSuccess("forbid_ports_in_permissions.json");
753 798
754 // Ideally, loading as a developer would give an error. 799 // Ideally, loading as a developer would give an error.
755 // To ensure that we do not error out on a valid permission 800 // To ensure that we do not error out on a valid permission
756 // in a future version of chrome, validation is to loose 801 // in a future version of chrome, validation is to loose
757 // to flag this case. 802 // to flag this case.
758 LoadStrictAndExpectSuccess("forbid_ports_in_permissions.json"); 803 LoadStrictAndExpectSuccess("forbid_ports_in_permissions.json");
759 } 804 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 scoped_refptr<Extension> extension_2( 884 scoped_refptr<Extension> extension_2(
840 LoadAndExpectSuccess("offline_disabled_packaged_app.json")); 885 LoadAndExpectSuccess("offline_disabled_packaged_app.json"));
841 EXPECT_FALSE(extension_2->offline_enabled()); 886 EXPECT_FALSE(extension_2->offline_enabled());
842 scoped_refptr<Extension> extension_3( 887 scoped_refptr<Extension> extension_3(
843 LoadAndExpectSuccess("offline_default_packaged_app.json")); 888 LoadAndExpectSuccess("offline_default_packaged_app.json"));
844 EXPECT_FALSE(extension_3->offline_enabled()); 889 EXPECT_FALSE(extension_3->offline_enabled());
845 scoped_refptr<Extension> extension_4( 890 scoped_refptr<Extension> extension_4(
846 LoadAndExpectSuccess("offline_enabled_hosted_app.json")); 891 LoadAndExpectSuccess("offline_enabled_hosted_app.json"));
847 EXPECT_TRUE(extension_4->offline_enabled()); 892 EXPECT_TRUE(extension_4->offline_enabled());
848 } 893 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/extension_constants.cc ('k') | chrome/test/data/extensions/manifest_tests/intent_invalid_1.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698