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

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

Powered by Google App Engine
This is Rietveld 408576698