Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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)); | |
|
James Hawkins
2011/09/19 18:51:40
Line up params. HAE
groby-ooo-7-16
2011/09/19 21:33:59
Done.
| |
| 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(WebIntentData::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", UTF16ToUTF8(extension->intents()[0].a ction)); | |
|
James Hawkins
2011/09/19 18:51:40
80 cols.
groby-ooo-7-16
2011/09/19 21:33:59
Done.
| |
| 788 EXPECT_TRUE(extension->intents()[0].service_url.is_empty()); | |
| 789 EXPECT_EQ("", UTF16ToUTF8(extension->intents()[0].title)); | |
| 790 EXPECT_EQ(WebIntentData::DISPOSITION_WINDOW, | |
| 791 extension->intents()[0].disposition); | |
| 792 } | |
| 793 | |
| 750 TEST_F(ExtensionManifestTest, ForbidPortsInPermissions) { | 794 TEST_F(ExtensionManifestTest, ForbidPortsInPermissions) { |
| 751 // Loading as a user would shoud not trigger an error. | 795 // Loading as a user would shoud not trigger an error. |
| 752 LoadAndExpectSuccess("forbid_ports_in_permissions.json"); | 796 LoadAndExpectSuccess("forbid_ports_in_permissions.json"); |
| 753 | 797 |
| 754 // Ideally, loading as a developer would give an error. | 798 // Ideally, loading as a developer would give an error. |
| 755 // To ensure that we do not error out on a valid permission | 799 // To ensure that we do not error out on a valid permission |
| 756 // in a future version of chrome, validation is to loose | 800 // in a future version of chrome, validation is to loose |
| 757 // to flag this case. | 801 // to flag this case. |
| 758 LoadStrictAndExpectSuccess("forbid_ports_in_permissions.json"); | 802 LoadStrictAndExpectSuccess("forbid_ports_in_permissions.json"); |
| 759 } | 803 } |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 839 scoped_refptr<Extension> extension_2( | 883 scoped_refptr<Extension> extension_2( |
| 840 LoadAndExpectSuccess("offline_disabled_packaged_app.json")); | 884 LoadAndExpectSuccess("offline_disabled_packaged_app.json")); |
| 841 EXPECT_FALSE(extension_2->offline_enabled()); | 885 EXPECT_FALSE(extension_2->offline_enabled()); |
| 842 scoped_refptr<Extension> extension_3( | 886 scoped_refptr<Extension> extension_3( |
| 843 LoadAndExpectSuccess("offline_default_packaged_app.json")); | 887 LoadAndExpectSuccess("offline_default_packaged_app.json")); |
| 844 EXPECT_FALSE(extension_3->offline_enabled()); | 888 EXPECT_FALSE(extension_3->offline_enabled()); |
| 845 scoped_refptr<Extension> extension_4( | 889 scoped_refptr<Extension> extension_4( |
| 846 LoadAndExpectSuccess("offline_enabled_hosted_app.json")); | 890 LoadAndExpectSuccess("offline_enabled_hosted_app.json")); |
| 847 EXPECT_TRUE(extension_4->offline_enabled()); | 891 EXPECT_TRUE(extension_4->offline_enabled()); |
| 848 } | 892 } |
| OLD | NEW |