Update CrOS OOBE throbber to MD throbber; delete old asset
[chromium-blink-merge.git] / chrome / common / extensions / manifest_tests / extension_manifests_launch_unittest.cc
blobd8e31ebfade6f1872cd39388fb804109a9c9e861
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
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "chrome/common/chrome_switches.h"
7 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h"
8 #include "chrome/common/extensions/manifest_tests/chrome_manifest_test.h"
9 #include "extensions/common/error_utils.h"
10 #include "extensions/common/extension.h"
11 #include "extensions/common/manifest_constants.h"
12 #include "testing/gtest/include/gtest/gtest.h"
14 namespace extensions {
16 namespace errors = manifest_errors;
17 namespace keys = manifest_keys;
19 class AppLaunchManifestTest : public ChromeManifestTest {
22 TEST_F(AppLaunchManifestTest, AppLaunchContainer) {
23 scoped_refptr<Extension> extension;
25 extension = LoadAndExpectSuccess("launch_tab.json");
26 EXPECT_EQ(LAUNCH_CONTAINER_TAB,
27 AppLaunchInfo::GetLaunchContainer(extension.get()));
29 extension = LoadAndExpectSuccess("launch_panel.json");
30 EXPECT_EQ(LAUNCH_CONTAINER_PANEL,
31 AppLaunchInfo::GetLaunchContainer(extension.get()));
33 extension = LoadAndExpectSuccess("launch_default.json");
34 EXPECT_EQ(LAUNCH_CONTAINER_TAB,
35 AppLaunchInfo::GetLaunchContainer(extension.get()));
37 extension = LoadAndExpectSuccess("launch_width.json");
38 EXPECT_EQ(640, AppLaunchInfo::GetLaunchWidth(extension.get()));
40 extension = LoadAndExpectSuccess("launch_height.json");
41 EXPECT_EQ(480, AppLaunchInfo::GetLaunchHeight(extension.get()));
43 Testcase testcases[] = {
44 Testcase("launch_window.json", errors::kInvalidLaunchContainer),
45 Testcase("launch_container_invalid_type.json",
46 errors::kInvalidLaunchContainer),
47 Testcase("launch_container_invalid_value.json",
48 errors::kInvalidLaunchContainer),
49 Testcase("launch_container_without_launch_url.json",
50 errors::kLaunchURLRequired),
51 Testcase("launch_width_invalid.json",
52 ErrorUtils::FormatErrorMessage(
53 errors::kInvalidLaunchValueContainer,
54 keys::kLaunchWidth)),
55 Testcase("launch_width_negative.json",
56 ErrorUtils::FormatErrorMessage(
57 errors::kInvalidLaunchValue,
58 keys::kLaunchWidth)),
59 Testcase("launch_height_invalid.json",
60 ErrorUtils::FormatErrorMessage(
61 errors::kInvalidLaunchValueContainer,
62 keys::kLaunchHeight)),
63 Testcase("launch_height_negative.json",
64 ErrorUtils::FormatErrorMessage(
65 errors::kInvalidLaunchValue,
66 keys::kLaunchHeight))
68 RunTestcases(testcases, arraysize(testcases),
69 EXPECT_TYPE_ERROR);
72 TEST_F(AppLaunchManifestTest, AppLaunchURL) {
73 Testcase testcases[] = {
74 Testcase("launch_path_and_url.json",
75 errors::kLaunchPathAndURLAreExclusive),
76 Testcase("launch_path_and_extent.json",
77 errors::kLaunchPathAndExtentAreExclusive),
78 Testcase("launch_path_invalid_type.json",
79 ErrorUtils::FormatErrorMessage(
80 errors::kInvalidLaunchValue,
81 keys::kLaunchLocalPath)),
82 Testcase("launch_path_invalid_value.json",
83 ErrorUtils::FormatErrorMessage(
84 errors::kInvalidLaunchValue,
85 keys::kLaunchLocalPath)),
86 Testcase("launch_path_invalid_localized.json",
87 ErrorUtils::FormatErrorMessage(
88 errors::kInvalidLaunchValue,
89 keys::kLaunchLocalPath)),
90 Testcase("launch_url_invalid_type_1.json",
91 ErrorUtils::FormatErrorMessage(
92 errors::kInvalidLaunchValue,
93 keys::kLaunchWebURL)),
94 Testcase("launch_url_invalid_type_2.json",
95 ErrorUtils::FormatErrorMessage(
96 errors::kInvalidLaunchValue,
97 keys::kLaunchWebURL)),
98 Testcase("launch_url_invalid_type_3.json",
99 ErrorUtils::FormatErrorMessage(
100 errors::kInvalidLaunchValue,
101 keys::kLaunchWebURL)),
102 Testcase("launch_url_invalid_localized.json",
103 ErrorUtils::FormatErrorMessage(
104 errors::kInvalidLaunchValue,
105 keys::kLaunchWebURL))
107 RunTestcases(testcases, arraysize(testcases),
108 EXPECT_TYPE_ERROR);
110 scoped_refptr<Extension> extension;
111 extension = LoadAndExpectSuccess("launch_local_path.json");
112 EXPECT_EQ(extension->url().spec() + "launch.html",
113 AppLaunchInfo::GetFullLaunchURL(extension.get()).spec());
115 extension = LoadAndExpectSuccess("launch_local_path_localized.json");
116 EXPECT_EQ(extension->url().spec() + "launch.html",
117 AppLaunchInfo::GetFullLaunchURL(extension.get()).spec());
119 LoadAndExpectError("launch_web_url_relative.json",
120 ErrorUtils::FormatErrorMessage(
121 errors::kInvalidLaunchValue,
122 keys::kLaunchWebURL));
124 extension = LoadAndExpectSuccess("launch_web_url_absolute.json");
125 EXPECT_EQ(GURL("http://www.google.com/launch.html"),
126 AppLaunchInfo::GetFullLaunchURL(extension.get()));
127 extension = LoadAndExpectSuccess("launch_web_url_localized.json");
128 EXPECT_EQ(GURL("http://www.google.com/launch.html"),
129 AppLaunchInfo::GetFullLaunchURL(extension.get()));
132 } // namespace extensions