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

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

Issue 10544059: Change the platform app manifest structure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update for getDisplayPath, implement restrictions via _manifest_features.json Created 8 years, 6 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 | Annotate | Revision Log
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" 5 #include "chrome/common/extensions/manifest_tests/extension_manifest_test.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "base/json/json_file_value_serializer.h" 10 #include "base/json/json_file_value_serializer.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 return extension; 109 return extension;
110 } 110 }
111 111
112 scoped_refptr<Extension> ExtensionManifestTest::LoadAndExpectSuccess( 112 scoped_refptr<Extension> ExtensionManifestTest::LoadAndExpectSuccess(
113 char const* manifest_name, 113 char const* manifest_name,
114 Extension::Location location, 114 Extension::Location location,
115 int flags) { 115 int flags) {
116 return LoadAndExpectSuccess(Manifest(manifest_name), location, flags); 116 return LoadAndExpectSuccess(Manifest(manifest_name), location, flags);
117 } 117 }
118 118
119 scoped_refptr<Extension> ExtensionManifestTest::LoadAndExpectWarning(
120 const Manifest& manifest,
121 const std::string& expected_warning,
122 Extension::Location location,
123 int flags) {
124 std::string error;
125 scoped_refptr<Extension> extension =
126 LoadExtension(manifest, &error, location, flags);
127 EXPECT_TRUE(extension) << manifest.name();
128 EXPECT_EQ("", error) << manifest.name();
129 EXPECT_EQ(1u, extension->install_warnings().size());
130 EXPECT_EQ(expected_warning, extension->install_warnings()[0]);
131 return extension;
132 }
133
134 scoped_refptr<Extension> ExtensionManifestTest::LoadAndExpectWarning(
135 char const* manifest_name,
136 const std::string& expected_warning,
137 Extension::Location location,
138 int flags) {
139 return LoadAndExpectWarning(
140 Manifest(manifest_name), expected_warning, location, flags);
141 }
142
119 void ExtensionManifestTest::VerifyExpectedError( 143 void ExtensionManifestTest::VerifyExpectedError(
120 Extension* extension, 144 Extension* extension,
121 const std::string& name, 145 const std::string& name,
122 const std::string& error, 146 const std::string& error,
123 const std::string& expected_error) { 147 const std::string& expected_error) {
124 EXPECT_FALSE(extension) << 148 EXPECT_FALSE(extension) <<
125 "Expected failure loading extension '" << name << 149 "Expected failure loading extension '" << name <<
126 "', but didn't get one."; 150 "', but didn't get one.";
127 EXPECT_TRUE(MatchPattern(error, expected_error)) << name << 151 EXPECT_TRUE(MatchPattern(error, expected_error)) << name <<
128 " expected '" << expected_error << "' but got '" << error << "'"; 152 " expected '" << expected_error << "' but got '" << error << "'";
(...skipping 13 matching lines...) Expand all
142 166
143 void ExtensionManifestTest::LoadAndExpectError( 167 void ExtensionManifestTest::LoadAndExpectError(
144 char const* manifest_name, 168 char const* manifest_name,
145 const std::string& expected_error, 169 const std::string& expected_error,
146 Extension::Location location, 170 Extension::Location location,
147 int flags) { 171 int flags) {
148 return LoadAndExpectError( 172 return LoadAndExpectError(
149 Manifest(manifest_name), expected_error, location, flags); 173 Manifest(manifest_name), expected_error, location, flags);
150 } 174 }
151 175
152
153 void ExtensionManifestTest::AddPattern(URLPatternSet* extent, 176 void ExtensionManifestTest::AddPattern(URLPatternSet* extent,
154 const std::string& pattern) { 177 const std::string& pattern) {
155 int schemes = URLPattern::SCHEME_ALL; 178 int schemes = URLPattern::SCHEME_ALL;
156 extent->AddPattern(URLPattern(schemes, pattern)); 179 extent->AddPattern(URLPattern(schemes, pattern));
157 } 180 }
158 181
159 ExtensionManifestTest::Testcase::Testcase(std::string manifest_filename, 182 ExtensionManifestTest::Testcase::Testcase(std::string manifest_filename,
160 std::string expected_error, 183 std::string expected_error,
161 Extension::Location location, 184 Extension::Location location,
162 int flags) 185 int flags)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 EXPECT_TYPE type) { 217 EXPECT_TYPE type) {
195 switch (type) { 218 switch (type) {
196 case EXPECT_TYPE_ERROR: 219 case EXPECT_TYPE_ERROR:
197 for (size_t i = 0; i < num_testcases; ++i) { 220 for (size_t i = 0; i < num_testcases; ++i) {
198 LoadAndExpectError(testcases[i].manifest_filename_.c_str(), 221 LoadAndExpectError(testcases[i].manifest_filename_.c_str(),
199 testcases[i].expected_error_, 222 testcases[i].expected_error_,
200 testcases[i].location_, 223 testcases[i].location_,
201 testcases[i].flags_); 224 testcases[i].flags_);
202 } 225 }
203 break; 226 break;
227 case EXPECT_TYPE_WARNING:
228 for (size_t i = 0; i < num_testcases; ++i) {
229 LoadAndExpectWarning(testcases[i].manifest_filename_.c_str(),
230 testcases[i].expected_error_,
231 testcases[i].location_,
232 testcases[i].flags_);
233 }
234 break;
204 case EXPECT_TYPE_SUCCESS: 235 case EXPECT_TYPE_SUCCESS:
205 for (size_t i = 0; i < num_testcases; ++i) { 236 for (size_t i = 0; i < num_testcases; ++i) {
206 LoadAndExpectSuccess(testcases[i].manifest_filename_.c_str(), 237 LoadAndExpectSuccess(testcases[i].manifest_filename_.c_str(),
207 testcases[i].location_, 238 testcases[i].location_,
208 testcases[i].flags_); 239 testcases[i].flags_);
209 } 240 }
210 break; 241 break;
211 } 242 }
212 } 243 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698