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

Unified Diff: chrome/common/extensions/manifest_tests/extension_manifests_launch_unittest.cc

Issue 12316077: Move the parsing of app.launch related keys out of Extension class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/manifest_tests/extension_manifests_launch_unittest.cc
diff --git a/chrome/common/extensions/manifest_tests/extension_manifests_launch_unittest.cc b/chrome/common/extensions/manifest_tests/extension_manifests_launch_unittest.cc
index 4cf2475b7b59e298533346663f1ccc254f421ec4..342ee0b244e5175b315a139ca67f55a824a429bc 100644
--- a/chrome/common/extensions/manifest_tests/extension_manifests_launch_unittest.cc
+++ b/chrome/common/extensions/manifest_tests/extension_manifests_launch_unittest.cc
@@ -2,37 +2,52 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
-
#include "base/command_line.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/extensions/app_launch_manifest_handler.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_manifest_constants.h"
+#include "chrome/common/extensions/manifest_handler.h"
+#include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
#include "extensions/common/error_utils.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace errors = extension_manifest_errors;
namespace keys = extension_manifest_keys;
-using extensions::ErrorUtils;
+namespace extensions {
-TEST_F(ExtensionManifestTest, AppLaunchContainer) {
- scoped_refptr<extensions::Extension> extension;
+class AppLaunchManifestTest : public ExtensionManifestTest {
+ virtual void SetUp() OVERRIDE {
+ ExtensionManifestTest::SetUp();
+ std::vector<std::string> app_launch_keys(AppLaunchManifestHandler::keys());
+ linked_ptr<AppLaunchManifestHandler> app_launch_handler(
+ new AppLaunchManifestHandler);
+ for (size_t i = 0; i < app_launch_keys.size(); ++i)
+ ManifestHandler::Register(app_launch_keys[i], app_launch_handler);
+ }
+};
+
+TEST_F(AppLaunchManifestTest, AppLaunchContainer) {
+ scoped_refptr<Extension> extension;
extension = LoadAndExpectSuccess("launch_tab.json");
- EXPECT_EQ(extension_misc::LAUNCH_TAB, extension->launch_container());
+ EXPECT_EQ(extension_misc::LAUNCH_TAB,
+ AppLaunchInfo::GetLaunchContainer(extension));
extension = LoadAndExpectSuccess("launch_panel.json");
- EXPECT_EQ(extension_misc::LAUNCH_PANEL, extension->launch_container());
+ EXPECT_EQ(extension_misc::LAUNCH_PANEL,
+ AppLaunchInfo::GetLaunchContainer(extension));
extension = LoadAndExpectSuccess("launch_default.json");
- EXPECT_EQ(extension_misc::LAUNCH_TAB, extension->launch_container());
+ EXPECT_EQ(extension_misc::LAUNCH_TAB,
+ AppLaunchInfo::GetLaunchContainer(extension));
extension = LoadAndExpectSuccess("launch_width.json");
- EXPECT_EQ(640, extension->launch_width());
+ EXPECT_EQ(640, AppLaunchInfo::GetLaunchWidth(extension));
extension = LoadAndExpectSuccess("launch_height.json");
- EXPECT_EQ(480, extension->launch_height());
+ EXPECT_EQ(480, AppLaunchInfo::GetLaunchHeight(extension));
Testcase testcases[] = {
Testcase("launch_window.json", errors::kInvalidLaunchContainer),
@@ -63,7 +78,7 @@ TEST_F(ExtensionManifestTest, AppLaunchContainer) {
EXPECT_TYPE_ERROR);
}
-TEST_F(ExtensionManifestTest, AppLaunchURL) {
+TEST_F(AppLaunchManifestTest, AppLaunchURL) {
Testcase testcases[] = {
Testcase("launch_path_and_url.json",
errors::kLaunchPathAndURLAreExclusive),
@@ -101,14 +116,14 @@ TEST_F(ExtensionManifestTest, AppLaunchURL) {
RunTestcases(testcases, arraysize(testcases),
EXPECT_TYPE_ERROR);
- scoped_refptr<extensions::Extension> extension;
+ scoped_refptr<Extension> extension;
extension = LoadAndExpectSuccess("launch_local_path.json");
EXPECT_EQ(extension->url().spec() + "launch.html",
- extension->GetFullLaunchURL().spec());
+ AppLaunchInfo::GetFullLaunchURL(extension).spec());
extension = LoadAndExpectSuccess("launch_local_path_localized.json");
EXPECT_EQ(extension->url().spec() + "launch.html",
- extension->GetFullLaunchURL().spec());
+ AppLaunchInfo::GetFullLaunchURL(extension).spec());
LoadAndExpectError("launch_web_url_relative.json",
ErrorUtils::FormatErrorMessage(
@@ -117,8 +132,10 @@ TEST_F(ExtensionManifestTest, AppLaunchURL) {
extension = LoadAndExpectSuccess("launch_web_url_absolute.json");
EXPECT_EQ(GURL("http://www.google.com/launch.html"),
- extension->GetFullLaunchURL());
+ AppLaunchInfo::GetFullLaunchURL(extension));
extension = LoadAndExpectSuccess("launch_web_url_localized.json");
EXPECT_EQ(GURL("http://www.google.com/launch.html"),
- extension->GetFullLaunchURL());
+ AppLaunchInfo::GetFullLaunchURL(extension));
}
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698