| 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 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 802 extension_manifest_errors::kInvalidIntentDisposition); | 802 extension_manifest_errors::kInvalidIntentDisposition); |
| 803 LoadAndExpectError("intent_invalid_5.json", | 803 LoadAndExpectError("intent_invalid_5.json", |
| 804 extension_manifest_errors::kInvalidIntentType); | 804 extension_manifest_errors::kInvalidIntentType); |
| 805 LoadAndExpectError("intent_invalid_6.json", | 805 LoadAndExpectError("intent_invalid_6.json", |
| 806 extension_manifest_errors::kInvalidIntentTitle); | 806 extension_manifest_errors::kInvalidIntentTitle); |
| 807 | 807 |
| 808 scoped_refptr<Extension> extension( | 808 scoped_refptr<Extension> extension( |
| 809 LoadAndExpectSuccess("intent_valid.json")); | 809 LoadAndExpectSuccess("intent_valid.json")); |
| 810 ASSERT_TRUE(extension.get() != NULL); | 810 ASSERT_TRUE(extension.get() != NULL); |
| 811 | 811 |
| 812 ASSERT_EQ(1u, extension->intents().size()); | 812 ASSERT_EQ(1u, extension->intents_services().size()); |
| 813 EXPECT_EQ("image/png", UTF16ToUTF8(extension->intents()[0].type)); | 813 EXPECT_EQ("image/png", UTF16ToUTF8(extension->intents_services()[0].type)); |
| 814 EXPECT_EQ("http://webintents.org/share", | 814 EXPECT_EQ("http://webintents.org/share", |
| 815 UTF16ToUTF8(extension->intents()[0].action)); | 815 UTF16ToUTF8(extension->intents_services()[0].action)); |
| 816 EXPECT_EQ("chrome-extension", extension->intents()[0].service_url.scheme()); | 816 EXPECT_EQ("chrome-extension", |
| 817 EXPECT_EQ("///services/share", extension->intents()[0].service_url.path()); | 817 extension->intents_services()[0].service_url.scheme()); |
| 818 EXPECT_EQ("///services/share", |
| 819 extension->intents_services()[0].service_url.path()); |
| 818 EXPECT_EQ("Sample Sharing Intent", | 820 EXPECT_EQ("Sample Sharing Intent", |
| 819 UTF16ToUTF8(extension->intents()[0].title)); | 821 UTF16ToUTF8(extension->intents_services()[0].title)); |
| 820 EXPECT_EQ(WebIntentServiceData::DISPOSITION_INLINE, | 822 EXPECT_EQ(webkit_glue::WebIntentServiceData::DISPOSITION_INLINE, |
| 821 extension->intents()[0].disposition); | 823 extension->intents_services()[0].disposition); |
| 822 | 824 |
| 823 // Verify that optional fields are filled with defaults. | 825 // Verify that optional fields are filled with defaults. |
| 824 extension = LoadAndExpectSuccess("intent_valid_minimal.json"); | 826 extension = LoadAndExpectSuccess("intent_valid_minimal.json"); |
| 825 ASSERT_TRUE(extension.get() != NULL); | 827 ASSERT_TRUE(extension.get() != NULL); |
| 826 | 828 |
| 827 ASSERT_EQ(1u, extension->intents().size()); | 829 ASSERT_EQ(1u, extension->intents_services().size()); |
| 828 EXPECT_EQ("", UTF16ToUTF8(extension->intents()[0].type)); | 830 EXPECT_EQ("", UTF16ToUTF8(extension->intents_services()[0].type)); |
| 829 EXPECT_EQ("http://webintents.org/share", | 831 EXPECT_EQ("http://webintents.org/share", |
| 830 UTF16ToUTF8(extension->intents()[0].action)); | 832 UTF16ToUTF8(extension->intents_services()[0].action)); |
| 831 EXPECT_TRUE(extension->intents()[0].service_url.is_empty()); | 833 EXPECT_TRUE(extension->intents_services()[0].service_url.is_empty()); |
| 832 EXPECT_EQ("", UTF16ToUTF8(extension->intents()[0].title)); | 834 EXPECT_EQ("", UTF16ToUTF8(extension->intents_services()[0].title)); |
| 833 EXPECT_EQ(WebIntentServiceData::DISPOSITION_WINDOW, | 835 EXPECT_EQ(webkit_glue::WebIntentServiceData::DISPOSITION_WINDOW, |
| 834 extension->intents()[0].disposition); | 836 extension->intents_services()[0].disposition); |
| 835 } | 837 } |
| 836 | 838 |
| 837 TEST_F(ExtensionManifestTest, ForbidPortsInPermissions) { | 839 TEST_F(ExtensionManifestTest, ForbidPortsInPermissions) { |
| 838 // Loading as a user would shoud not trigger an error. | 840 // Loading as a user would shoud not trigger an error. |
| 839 LoadAndExpectSuccess("forbid_ports_in_permissions.json"); | 841 LoadAndExpectSuccess("forbid_ports_in_permissions.json"); |
| 840 | 842 |
| 841 // Ideally, loading as a developer would give an error. | 843 // Ideally, loading as a developer would give an error. |
| 842 // To ensure that we do not error out on a valid permission | 844 // To ensure that we do not error out on a valid permission |
| 843 // in a future version of chrome, validation is to loose | 845 // in a future version of chrome, validation is to loose |
| 844 // to flag this case. | 846 // to flag this case. |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 scoped_refptr<Extension> extension_2( | 929 scoped_refptr<Extension> extension_2( |
| 928 LoadAndExpectSuccess("offline_disabled_packaged_app.json")); | 930 LoadAndExpectSuccess("offline_disabled_packaged_app.json")); |
| 929 EXPECT_FALSE(extension_2->offline_enabled()); | 931 EXPECT_FALSE(extension_2->offline_enabled()); |
| 930 scoped_refptr<Extension> extension_3( | 932 scoped_refptr<Extension> extension_3( |
| 931 LoadAndExpectSuccess("offline_default_packaged_app.json")); | 933 LoadAndExpectSuccess("offline_default_packaged_app.json")); |
| 932 EXPECT_FALSE(extension_3->offline_enabled()); | 934 EXPECT_FALSE(extension_3->offline_enabled()); |
| 933 scoped_refptr<Extension> extension_4( | 935 scoped_refptr<Extension> extension_4( |
| 934 LoadAndExpectSuccess("offline_enabled_hosted_app.json")); | 936 LoadAndExpectSuccess("offline_enabled_hosted_app.json")); |
| 935 EXPECT_TRUE(extension_4->offline_enabled()); | 937 EXPECT_TRUE(extension_4->offline_enabled()); |
| 936 } | 938 } |
| OLD | NEW |