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
3 // found in the LICENSE file.
5 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
6 #include "chrome/common/extensions/manifest_url_handler.h"
7 #include "extensions/common/extension.h"
8 #include "extensions/common/manifest_constants.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "ui/base/l10n/l10n_util.h"
12 namespace errors
= extensions::manifest_errors
;
14 class HomepageURLManifestTest
: public ExtensionManifestTest
{
17 TEST_F(HomepageURLManifestTest
, ParseHomepageURLs
) {
18 scoped_refptr
<extensions::Extension
> extension(
19 LoadAndExpectSuccess("homepage_valid.json"));
21 Testcase testcases
[] = {
22 Testcase("homepage_empty.json",
23 errors::kInvalidHomepageURL
),
24 Testcase("homepage_invalid.json",
25 errors::kInvalidHomepageURL
),
26 Testcase("homepage_bad_schema.json",
27 errors::kInvalidHomepageURL
)
29 RunTestcases(testcases
, arraysize(testcases
),
33 TEST_F(HomepageURLManifestTest
, GetHomepageURL
) {
34 scoped_refptr
<extensions::Extension
> extension(
35 LoadAndExpectSuccess("homepage_valid.json"));
36 EXPECT_EQ(GURL("http://foo.com#bar"),
37 extensions::ManifestURL::GetHomepageURL(extension
.get()));
39 // The Google Gallery URL ends with the id, which depends on the path, which
40 // can be different in testing, so we just check the part before id.
41 extension
= LoadAndExpectSuccess("homepage_google_hosted.json");
42 EXPECT_TRUE(StartsWithASCII(
43 extensions::ManifestURL::GetHomepageURL(extension
.get()).spec(),
44 "https://chrome.google.com/webstore/detail/",
47 extension
= LoadAndExpectSuccess("homepage_externally_hosted.json");
48 EXPECT_EQ(GURL(), extensions::ManifestURL::GetHomepageURL(extension
.get()));