| 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 "chrome/common/extensions/manifest_tests/extension_manifest_test.h" | 5 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" |
| 6 | 6 |
| 7 #include "chrome/common/extensions/api/extension_urls/extension_urls_handler.h" |
| 7 #include "chrome/common/extensions/extension.h" | 8 #include "chrome/common/extensions/extension.h" |
| 8 #include "chrome/common/extensions/extension_manifest_constants.h" | 9 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 10 #include "chrome/common/extensions/manifest_handler.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/base/l10n/l10n_util.h" | 12 #include "ui/base/l10n/l10n_util.h" |
| 11 | 13 |
| 12 namespace errors = extension_manifest_errors; | 14 namespace extensions { |
| 13 | 15 |
| 14 TEST_F(ExtensionManifestTest, ParseHomepageURLs) { | 16 class HomepageManifestTest : public ExtensionManifestTest { |
| 15 scoped_refptr<extensions::Extension> extension( | 17 protected: |
| 18 virtual void SetUp() OVERRIDE { |
| 19 ExtensionManifestTest::SetUp(); |
| 20 ManifestHandler::Register(extension_manifest_keys::kHomepageURL, |
| 21 new HomepageURLHandler); |
| 22 } |
| 23 }; |
| 24 |
| 25 TEST_F(HomepageManifestTest, ParseHomepageURLs) { |
| 26 scoped_refptr<Extension> extension( |
| 16 LoadAndExpectSuccess("homepage_valid.json")); | 27 LoadAndExpectSuccess("homepage_valid.json")); |
| 17 | 28 |
| 18 Testcase testcases[] = { | 29 Testcase testcases[] = { |
| 19 Testcase("homepage_empty.json", | 30 Testcase("homepage_empty.json", |
| 20 errors::kInvalidHomepageURL), | 31 extension_manifest_errors::kInvalidHomepageURL), |
| 21 Testcase("homepage_invalid.json", | 32 Testcase("homepage_invalid.json", |
| 22 errors::kInvalidHomepageURL), | 33 extension_manifest_errors::kInvalidHomepageURL), |
| 23 Testcase("homepage_bad_schema.json", | 34 Testcase("homepage_bad_schema.json", |
| 24 errors::kInvalidHomepageURL) | 35 extension_manifest_errors::kInvalidHomepageURL) |
| 25 }; | 36 }; |
| 26 RunTestcases(testcases, arraysize(testcases), | 37 RunTestcases(testcases, arraysize(testcases), |
| 27 EXPECT_TYPE_ERROR); | 38 EXPECT_TYPE_ERROR); |
| 28 } | 39 } |
| 29 | 40 |
| 30 TEST_F(ExtensionManifestTest, GetHomepageURL) { | 41 TEST_F(HomepageManifestTest, GetHomepageURL) { |
| 31 scoped_refptr<extensions::Extension> extension( | 42 scoped_refptr<Extension> extension( |
| 32 LoadAndExpectSuccess("homepage_valid.json")); | 43 LoadAndExpectSuccess("homepage_valid.json")); |
| 33 EXPECT_EQ(GURL("http://foo.com#bar"), extension->GetHomepageURL()); | 44 EXPECT_EQ(GURL("http://foo.com#bar"), |
| 45 ExtensionURL::GetHomepageURL(extension)); |
| 34 | 46 |
| 35 // The Google Gallery URL ends with the id, which depends on the path, which | 47 // The Google Gallery URL ends with the id, which depends on the path, which |
| 36 // can be different in testing, so we just check the part before id. | 48 // can be different in testing, so we just check the part before id. |
| 37 extension = LoadAndExpectSuccess("homepage_google_hosted.json"); | 49 extension = LoadAndExpectSuccess("homepage_google_hosted.json"); |
| 38 EXPECT_TRUE(StartsWithASCII(extension->GetHomepageURL().spec(), | 50 EXPECT_TRUE(StartsWithASCII(ExtensionURL::GetHomepageURL(extension).spec(), |
| 39 "https://chrome.google.com/webstore/detail/", | 51 "https://chrome.google.com/webstore/detail/", |
| 40 false)); | 52 false)); |
| 41 | 53 |
| 42 extension = LoadAndExpectSuccess("homepage_externally_hosted.json"); | 54 extension = LoadAndExpectSuccess("homepage_externally_hosted.json"); |
| 43 EXPECT_EQ(GURL(), extension->GetHomepageURL()); | 55 EXPECT_EQ(GURL(), ExtensionURL::GetHomepageURL(extension)); |
| 44 } | 56 } |
| 57 |
| 58 } // namespace extensions |
| OLD | NEW |