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/extension.h" | 7 #include "chrome/common/extensions/extension.h" |
8 #include "chrome/common/extensions/extension_manifest_constants.h" | 8 #include "chrome/common/extensions/extension_manifest_constants.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
11 | 11 |
12 namespace errors = extension_manifest_errors; | 12 namespace errors = extension_manifest_errors; |
13 | 13 |
14 TEST_F(ExtensionManifestTest, ParseHomepageURLs) { | 14 TEST_F(ExtensionManifestTest, ParseHomepageURLs) { |
15 scoped_refptr<Extension> extension( | 15 scoped_refptr<extensions::Extension> extension( |
16 LoadAndExpectSuccess("homepage_valid.json")); | 16 LoadAndExpectSuccess("homepage_valid.json")); |
17 | 17 |
18 Testcase testcases[] = { | 18 Testcase testcases[] = { |
19 Testcase("homepage_empty.json", | 19 Testcase("homepage_empty.json", |
20 errors::kInvalidHomepageURL), | 20 errors::kInvalidHomepageURL), |
21 Testcase("homepage_invalid.json", | 21 Testcase("homepage_invalid.json", |
22 errors::kInvalidHomepageURL), | 22 errors::kInvalidHomepageURL), |
23 Testcase("homepage_bad_schema.json", | 23 Testcase("homepage_bad_schema.json", |
24 errors::kInvalidHomepageURL) | 24 errors::kInvalidHomepageURL) |
25 }; | 25 }; |
26 RunTestcases(testcases, arraysize(testcases), | 26 RunTestcases(testcases, arraysize(testcases), |
27 EXPECT_TYPE_ERROR); | 27 EXPECT_TYPE_ERROR); |
28 } | 28 } |
29 | 29 |
30 TEST_F(ExtensionManifestTest, GetHomepageURL) { | 30 TEST_F(ExtensionManifestTest, GetHomepageURL) { |
31 scoped_refptr<Extension> extension( | 31 scoped_refptr<extensions::Extension> extension( |
32 LoadAndExpectSuccess("homepage_valid.json")); | 32 LoadAndExpectSuccess("homepage_valid.json")); |
33 EXPECT_EQ(GURL("http://foo.com#bar"), extension->GetHomepageURL()); | 33 EXPECT_EQ(GURL("http://foo.com#bar"), extension->GetHomepageURL()); |
34 | 34 |
35 // The Google Gallery URL ends with the id, which depends on the path, which | 35 // 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. | 36 // can be different in testing, so we just check the part before id. |
37 extension = LoadAndExpectSuccess("homepage_google_hosted.json"); | 37 extension = LoadAndExpectSuccess("homepage_google_hosted.json"); |
38 EXPECT_TRUE(StartsWithASCII(extension->GetHomepageURL().spec(), | 38 EXPECT_TRUE(StartsWithASCII(extension->GetHomepageURL().spec(), |
39 "https://chrome.google.com/webstore/detail/", | 39 "https://chrome.google.com/webstore/detail/", |
40 false)); | 40 false)); |
41 | 41 |
42 extension = LoadAndExpectSuccess("homepage_externally_hosted.json"); | 42 extension = LoadAndExpectSuccess("homepage_externally_hosted.json"); |
43 EXPECT_EQ(GURL(), extension->GetHomepageURL()); | 43 EXPECT_EQ(GURL(), extension->GetHomepageURL()); |
44 } | 44 } |
OLD | NEW |