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

Side by Side Diff: chrome/common/extensions/unpacker_unittest.cc

Issue 10868050: Remove "theme" in extension/app unpacker error messages, make those messages localizable, and add u… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Applied suggestions in patch set 2 comments and added paths in errors. Created 8 years, 3 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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/scoped_temp_dir.h" 7 #include "base/scoped_temp_dir.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/common/chrome_paths.h" 11 #include "chrome/common/chrome_paths.h"
12 #include "chrome/common/extensions/extension_constants.h"
12 #include "chrome/common/extensions/extension_manifest_constants.h" 13 #include "chrome/common/extensions/extension_manifest_constants.h"
13 #include "chrome/common/extensions/unpacker.h" 14 #include "chrome/common/extensions/unpacker.h"
14 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
15 #include "third_party/skia/include/core/SkBitmap.h" 16 #include "third_party/skia/include/core/SkBitmap.h"
16 17
17 namespace errors = extension_manifest_errors; 18 namespace errors = extension_manifest_errors;
19 namespace filenames = extension_filenames;
18 namespace keys = extension_manifest_keys; 20 namespace keys = extension_manifest_keys;
19 21
20 namespace extensions { 22 namespace extensions {
21 23
22 class UnpackerTest : public testing::Test { 24 class UnpackerTest : public testing::Test {
23 public: 25 public:
24 ~UnpackerTest() { 26 ~UnpackerTest() {
25 LOG(WARNING) << "Deleting temp dir: " 27 LOG(WARNING) << "Deleting temp dir: "
26 << temp_dir_.path().LossyDisplayName(); 28 << temp_dir_.path().LossyDisplayName();
27 LOG(WARNING) << temp_dir_.Delete(); 29 LOG(WARNING) << temp_dir_.Delete();
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 #else 186 #else
185 #define MAYBE_NoL10n NoL10n 187 #define MAYBE_NoL10n NoL10n
186 #endif 188 #endif
187 TEST_F(UnpackerTest, MAYBE_NoL10n) { 189 TEST_F(UnpackerTest, MAYBE_NoL10n) {
188 SetupUnpacker("no_l10n.crx"); 190 SetupUnpacker("no_l10n.crx");
189 EXPECT_TRUE(unpacker_->Run()); 191 EXPECT_TRUE(unpacker_->Run());
190 EXPECT_TRUE(unpacker_->error_message().empty()); 192 EXPECT_TRUE(unpacker_->error_message().empty());
191 EXPECT_EQ(0U, unpacker_->parsed_catalogs()->size()); 193 EXPECT_EQ(0U, unpacker_->parsed_catalogs()->size());
192 } 194 }
193 195
196 // Disabled on Windows because it probably crashes intermittently as described
197 // in <http://crbug.com/109238>. However, because the logic being testing here
198 // is platform-independant, this test should still provide good coverage.
199 #if defined(OS_WIN)
200 #define MAYBE_UnzipDirectoryError DISABLED_UnzipDirectoryError
201 #else
202 #define MAYBE_UnzipDirectoryError UnzipDirectoryError
203 #endif
204 TEST_F(UnpackerTest, MAYBE_UnzipDirectoryError) {
205 const char* kExpected = "Could not create directory for unzipping: ";
206 SetupUnpacker("good_package.crx");
207 FilePath path = temp_dir_.path().AppendASCII(filenames::kTempExtensionName);
208 ASSERT_TRUE(file_util::WriteFile(path, "foo", 3));
209 EXPECT_FALSE(unpacker_->Run());
210 EXPECT_TRUE(StartsWith(unpacker_->error_message(),
211 ASCIIToUTF16(kExpected),
212 false)) << "Expected prefix: \"" << kExpected
213 << "\", actual error: \"" << unpacker_->error_message()
214 << "\"";
dharcourt 2012/08/27 17:55:55 Corrected formatting (<< at the beginning of lines
215 }
216
217 // Disabled on Windows because it probably crashes intermittently as described
218 // in <http://crbug.com/109238>. However, because the logic being testing here
219 // is platform-independant, this test should still provide good coverage.
220 #if defined(OS_WIN)
221 #define MAYBE_UnzipError DISABLED_UnzipError
222 #else
223 #define MAYBE_UnzipError UnzipError
224 #endif
225 TEST_F(UnpackerTest, MAYBE_UnzipError) {
226 const char* kExpected = "Could not unzip extension";
227 SetupUnpacker("bad_zip.crx");
228 EXPECT_FALSE(unpacker_->Run());
229 EXPECT_EQ(ASCIIToUTF16(kExpected), unpacker_->error_message());
230 }
231
232 // Disabled on Windows because it probably crashes intermittently as described
233 // in <http://crbug.com/109238>. However, because the logic being testing here
234 // is platform-independant, this test should still provide good coverage.
235 #if defined(OS_WIN)
236 #define MAYBE_BadPathError DISABLED_BadPathError
237 #else
238 #define MAYBE_BadPathError BadPathError
239 #endif
240 TEST_F(UnpackerTest, MAYBE_BadPathError) {
241 const char* kExpected = "Illegal path (absolute or relative with '..'): ";
dharcourt 2012/08/27 17:55:55 Tweaked the message to make it more compatible wit
242 SetupUnpacker("bad_path.crx");
243 EXPECT_FALSE(unpacker_->Run());
244 EXPECT_TRUE(StartsWith(unpacker_->error_message(),
245 ASCIIToUTF16(kExpected),
246 false)) << "Expected prefix: \"" << kExpected
247 << "\", actual error: \"" << unpacker_->error_message()
248 << "\"";
249 }
250
251
252 // Disabled on Windows because it probably crashes intermittently as described
253 // in <http://crbug.com/109238>. However, because the logic being testing here
254 // is platform-independant, this test should still provide good coverage.
255 #if defined(OS_WIN)
256 #define MAYBE_ImageDecodingError DISABLED_ImageDecodingError
257 #else
258 #define MAYBE_ImageDecodingError ImageDecodingError
259 #endif
260 TEST_F(UnpackerTest, MAYBE_ImageDecodingError) {
261 const char* kExpected = "Could not decode image: ";
262 SetupUnpacker("bad_image.crx");
263 EXPECT_FALSE(unpacker_->Run());
264 EXPECT_TRUE(StartsWith(unpacker_->error_message(),
265 ASCIIToUTF16(kExpected),
266 false)) << "Expected prefix: \"" << kExpected
267 << "\", actual error: \"" << unpacker_->error_message()
268 << "\"";
dharcourt 2012/08/27 17:55:55 Moved the ImageDecodingError test in this patch to
269 }
270
194 } // namespace extensions 271 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698