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