Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: chrome/common/extensions/api/url_parser/homepage_url_manifests_unittest.cc

Issue 11624036: Move the parsing of homepage_url" and "devtools_page" out of Extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/api/url_parser/homepage_url_handler.h"
6 6 #include "chrome/common/extensions/api/url_parser/url_info.h"
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 "chrome/common/extensions/manifest_handler.h"
10 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.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
14 namespace keys = extension_manifest_keys;
12 namespace errors = extension_manifest_errors; 15 namespace errors = extension_manifest_errors;
13 16
14 TEST_F(ExtensionManifestTest, ParseHomepageURLs) { 17 namespace {
18
19 class HomepageURLManifestTest : public ExtensionManifestTest {
20 virtual void SetUp() OVERRIDE {
21 ExtensionManifestTest::SetUp();
22 extensions::ManifestHandler::Register(keys::kHomepageURL,
23 new extensions::HomepageURLHandler);
24 }
25 };
26
27 TEST_F(HomepageURLManifestTest, ParseHomepageURLs) {
15 scoped_refptr<extensions::Extension> extension( 28 scoped_refptr<extensions::Extension> extension(
16 LoadAndExpectSuccess("homepage_valid.json")); 29 LoadAndExpectSuccess("homepage_valid.json"));
17 30
18 Testcase testcases[] = { 31 Testcase testcases[] = {
19 Testcase("homepage_empty.json", 32 Testcase("homepage_empty.json",
20 errors::kInvalidHomepageURL), 33 errors::kInvalidHomepageURL),
21 Testcase("homepage_invalid.json", 34 Testcase("homepage_invalid.json",
22 errors::kInvalidHomepageURL), 35 errors::kInvalidHomepageURL),
23 Testcase("homepage_bad_schema.json", 36 Testcase("homepage_bad_schema.json",
24 errors::kInvalidHomepageURL) 37 errors::kInvalidHomepageURL)
25 }; 38 };
26 RunTestcases(testcases, arraysize(testcases), 39 RunTestcases(testcases, arraysize(testcases),
27 EXPECT_TYPE_ERROR); 40 EXPECT_TYPE_ERROR);
28 } 41 }
29 42
30 TEST_F(ExtensionManifestTest, GetHomepageURL) { 43 TEST_F(HomepageURLManifestTest, GetHomepageURL) {
31 scoped_refptr<extensions::Extension> extension( 44 scoped_refptr<extensions::Extension> extension(
32 LoadAndExpectSuccess("homepage_valid.json")); 45 LoadAndExpectSuccess("homepage_valid.json"));
33 EXPECT_EQ(GURL("http://foo.com#bar"), extension->GetHomepageURL()); 46 EXPECT_EQ(GURL("http://foo.com#bar"), extensions::URLInfo::url(
47 extension, extensions::URLInfo::HOMEPAGE_URL));
34 48
35 // The Google Gallery URL ends with the id, which depends on the path, which 49 // 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. 50 // can be different in testing, so we just check the part before id.
37 extension = LoadAndExpectSuccess("homepage_google_hosted.json"); 51 extension = LoadAndExpectSuccess("homepage_google_hosted.json");
38 EXPECT_TRUE(StartsWithASCII(extension->GetHomepageURL().spec(), 52 EXPECT_TRUE(StartsWithASCII(extensions::URLInfo::url(
39 "https://chrome.google.com/webstore/detail/", 53 extension, extensions::URLInfo::HOMEPAGE_URL).spec(),
40 false)); 54 "https://chrome.google.com/webstore/detail/", false));
41 55
42 extension = LoadAndExpectSuccess("homepage_externally_hosted.json"); 56 extension = LoadAndExpectSuccess("homepage_externally_hosted.json");
43 EXPECT_EQ(GURL(), extension->GetHomepageURL()); 57 EXPECT_EQ(GURL(), extensions::URLInfo::url(
58 extension, extensions::URLInfo::HOMEPAGE_URL));
44 } 59 }
60
61 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698