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

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

Powered by Google App Engine
This is Rietveld 408576698