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

Side by Side Diff: chrome/common/extensions/manifest_tests/extension_manifests_options_unittest.cc

Issue 11726002: Move the parsing of 'update_url' & 'options_page' URLs out of Extension. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@url_parse
Patch Set: fixed HomepageURLManifestTest.GetHomepageURL 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/extension_manifest_constants.h"
6 #include "chrome/common/extensions/manifest_handler.h"
5 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h" 7 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
6 8 #include "chrome/common/extensions/manifest_url_handler.h"
7 #include "chrome/common/extensions/extension_manifest_constants.h"
8 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
9 10
10 namespace errors = extension_manifest_errors; 11 namespace errors = extension_manifest_errors;
11 12
12 TEST_F(ExtensionManifestTest, OptionsPageInApps) { 13 class OptionsPageManifestTest : public ExtensionManifestTest {
14 virtual void SetUp() OVERRIDE {
15 ExtensionManifestTest::SetUp();
16 extensions::ManifestHandler::Register(extension_manifest_keys::kOptionsPage,
17 new extensions::OptionsPageHandler);
18 }
19 };
20
21 TEST_F(OptionsPageManifestTest, OptionsPageInApps) {
13 scoped_refptr<extensions::Extension> extension; 22 scoped_refptr<extensions::Extension> extension;
14 23
15 // Allow options page with absolute URL in hosted apps. 24 // Allow options page with absolute URL in hosted apps.
16 extension = LoadAndExpectSuccess("hosted_app_absolute_options.json"); 25 extension = LoadAndExpectSuccess("hosted_app_absolute_options.json");
17 EXPECT_STREQ("http", 26 EXPECT_STREQ(
18 extension->options_url().scheme().c_str()); 27 "http",
19 EXPECT_STREQ("example.com", 28 extensions::ManifestURL::GetOptionsPage(extension).scheme().c_str());
20 extension->options_url().host().c_str()); 29 EXPECT_STREQ(
21 EXPECT_STREQ("options.html", 30 "example.com",
22 extension->options_url().ExtractFileName().c_str()); 31 extensions::ManifestURL::GetOptionsPage(extension).host().c_str());
32 EXPECT_STREQ(
33 "options.html",
34 extensions::ManifestURL::
35 GetOptionsPage(extension).ExtractFileName().c_str());
23 36
24 Testcase testcases[] = { 37 Testcase testcases[] = {
25 // Forbid options page with relative URL in hosted apps. 38 // Forbid options page with relative URL in hosted apps.
26 Testcase("hosted_app_relative_options.json", 39 Testcase("hosted_app_relative_options.json",
27 errors::kInvalidOptionsPageInHostedApp), 40 errors::kInvalidOptionsPageInHostedApp),
28 41
29 // Forbid options page with non-(http|https) scheme in hosted app. 42 // Forbid options page with non-(http|https) scheme in hosted app.
30 Testcase("hosted_app_file_options.json", 43 Testcase("hosted_app_file_options.json",
31 errors::kInvalidOptionsPageInHostedApp), 44 errors::kInvalidOptionsPageInHostedApp),
32 45
33 // Forbid absolute URL for options page in packaged apps. 46 // Forbid absolute URL for options page in packaged apps.
34 Testcase("packaged_app_absolute_options.json", 47 Testcase("packaged_app_absolute_options.json",
35 errors::kInvalidOptionsPageExpectUrlInPackage) 48 errors::kInvalidOptionsPageExpectUrlInPackage)
36 }; 49 };
37 RunTestcases(testcases, arraysize(testcases), 50 RunTestcases(testcases, arraysize(testcases),
38 EXPECT_TYPE_ERROR); 51 EXPECT_TYPE_ERROR);
39 } 52 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698