| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/strings/string_number_conversions.h" |
| 6 #include "chrome/common/extensions/app_launch_manifest_handler.h" |
| 7 #include "chrome/common/extensions/extension.h" |
| 8 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 9 #include "chrome/common/extensions/manifest_handler.h" |
| 5 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" | 10 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" |
| 6 | |
| 7 #include "base/strings/string_number_conversions.h" | |
| 8 #include "base/utf_string_conversions.h" | |
| 9 #include "chrome/common/extensions/extension_manifest_constants.h" | |
| 10 #include "extensions/common/error_utils.h" | 11 #include "extensions/common/error_utils.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 13 |
| 13 using extensions::ErrorUtils; | 14 using extensions::ErrorUtils; |
| 14 using extensions::Extension; | 15 using extensions::Extension; |
| 15 | 16 |
| 16 namespace errors = extension_manifest_errors; | 17 namespace errors = extension_manifest_errors; |
| 17 | 18 |
| 18 TEST_F(ExtensionManifestTest, AppWebUrls) { | 19 class WebManifestTest : public ExtensionManifestTest { |
| 20 virtual void SetUp() OVERRIDE { |
| 21 ExtensionManifestTest::SetUp(); |
| 22 std::vector<std::string> app_launch_keys( |
| 23 extensions::AppLaunchManifestHandler::keys()); |
| 24 linked_ptr<extensions::AppLaunchManifestHandler> app_launch_handler( |
| 25 new extensions::AppLaunchManifestHandler); |
| 26 for (size_t i = 0; i < app_launch_keys.size(); ++i) { |
| 27 extensions::ManifestHandler::Register(app_launch_keys[i], |
| 28 app_launch_handler); |
| 29 } |
| 30 } |
| 31 }; |
| 32 |
| 33 TEST_F(WebManifestTest, AppWebUrls) { |
| 19 Testcase testcases[] = { | 34 Testcase testcases[] = { |
| 20 Testcase("web_urls_wrong_type.json", errors::kInvalidWebURLs), | 35 Testcase("web_urls_wrong_type.json", errors::kInvalidWebURLs), |
| 21 Testcase("web_urls_invalid_1.json", | 36 Testcase("web_urls_invalid_1.json", |
| 22 ErrorUtils::FormatErrorMessage( | 37 ErrorUtils::FormatErrorMessage( |
| 23 errors::kInvalidWebURL, | 38 errors::kInvalidWebURL, |
| 24 base::IntToString(0), | 39 base::IntToString(0), |
| 25 errors::kExpectString)), | 40 errors::kExpectString)), |
| 26 Testcase("web_urls_invalid_2.json", | 41 Testcase("web_urls_invalid_2.json", |
| 27 ErrorUtils::FormatErrorMessage( | 42 ErrorUtils::FormatErrorMessage( |
| 28 errors::kInvalidWebURL, | 43 errors::kInvalidWebURL, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 49 EXPECT_TYPE_ERROR); | 64 EXPECT_TYPE_ERROR); |
| 50 | 65 |
| 51 LoadAndExpectSuccess("web_urls_has_port.json"); | 66 LoadAndExpectSuccess("web_urls_has_port.json"); |
| 52 | 67 |
| 53 scoped_refptr<Extension> extension( | 68 scoped_refptr<Extension> extension( |
| 54 LoadAndExpectSuccess("web_urls_default.json")); | 69 LoadAndExpectSuccess("web_urls_default.json")); |
| 55 ASSERT_EQ(1u, extension->web_extent().patterns().size()); | 70 ASSERT_EQ(1u, extension->web_extent().patterns().size()); |
| 56 EXPECT_EQ("*://www.google.com/*", | 71 EXPECT_EQ("*://www.google.com/*", |
| 57 extension->web_extent().patterns().begin()->GetAsString()); | 72 extension->web_extent().patterns().begin()->GetAsString()); |
| 58 } | 73 } |
| OLD | NEW |