Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.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/api/i18n/default_locale_handler.h" | |
| 12 #include "chrome/common/extensions/extension_constants.h" | 13 #include "chrome/common/extensions/extension_constants.h" |
| 13 #include "chrome/common/extensions/extension_manifest_constants.h" | 14 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 15 #include "chrome/common/extensions/manifest_handler.h" | |
| 14 #include "chrome/common/extensions/unpacker.h" | 16 #include "chrome/common/extensions/unpacker.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "third_party/skia/include/core/SkBitmap.h" | 18 #include "third_party/skia/include/core/SkBitmap.h" |
| 17 | 19 |
| 18 namespace errors = extension_manifest_errors; | 20 namespace errors = extension_manifest_errors; |
| 19 namespace filenames = extension_filenames; | 21 namespace filenames = extension_filenames; |
| 20 namespace keys = extension_manifest_keys; | 22 namespace keys = extension_manifest_keys; |
| 21 | 23 |
| 22 namespace extensions { | 24 namespace extensions { |
| 23 | 25 |
| 24 class UnpackerTest : public testing::Test { | 26 class UnpackerTest : public testing::Test { |
| 25 public: | 27 public: |
| 26 ~UnpackerTest() { | 28 ~UnpackerTest() { |
| 27 LOG(WARNING) << "Deleting temp dir: " | 29 LOG(WARNING) << "Deleting temp dir: " |
| 28 << temp_dir_.path().LossyDisplayName(); | 30 << temp_dir_.path().LossyDisplayName(); |
| 29 LOG(WARNING) << temp_dir_.Delete(); | 31 LOG(WARNING) << temp_dir_.Delete(); |
| 30 } | 32 } |
| 31 | 33 |
| 34 virtual void SetUp() OVERRIDE { | |
|
Devlin
2013/01/18 21:08:46
Call the super's SetUp().
Joe Thomas
2013/01/18 22:16:57
Done.
| |
| 35 extensions::ManifestHandler::Register(keys::kDefaultLocale, | |
| 36 new extensions::DefaultLocaleHandler); | |
| 37 } | |
| 38 | |
| 32 void SetupUnpacker(const std::string& crx_name) { | 39 void SetupUnpacker(const std::string& crx_name) { |
| 33 FilePath original_path; | 40 FilePath original_path; |
| 34 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &original_path)); | 41 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &original_path)); |
| 35 original_path = original_path.AppendASCII("extensions") | 42 original_path = original_path.AppendASCII("extensions") |
| 36 .AppendASCII("unpacker") | 43 .AppendASCII("unpacker") |
| 37 .AppendASCII(crx_name); | 44 .AppendASCII(crx_name); |
| 38 ASSERT_TRUE(file_util::PathExists(original_path)) << original_path.value(); | 45 ASSERT_TRUE(file_util::PathExists(original_path)) << original_path.value(); |
| 39 | 46 |
| 40 // Try bots won't let us write into DIR_TEST_DATA, so we have to create | 47 // Try bots won't let us write into DIR_TEST_DATA, so we have to create |
| 41 // a temp folder to play in. | 48 // a temp folder to play in. |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 262 SetupUnpacker("bad_image.crx"); | 269 SetupUnpacker("bad_image.crx"); |
| 263 EXPECT_FALSE(unpacker_->Run()); | 270 EXPECT_FALSE(unpacker_->Run()); |
| 264 EXPECT_TRUE(StartsWith(unpacker_->error_message(), | 271 EXPECT_TRUE(StartsWith(unpacker_->error_message(), |
| 265 ASCIIToUTF16(kExpected), | 272 ASCIIToUTF16(kExpected), |
| 266 false)) << "Expected prefix: \"" << kExpected | 273 false)) << "Expected prefix: \"" << kExpected |
| 267 << "\", actual error: \"" << unpacker_->error_message() | 274 << "\", actual error: \"" << unpacker_->error_message() |
| 268 << "\""; | 275 << "\""; |
| 269 } | 276 } |
| 270 | 277 |
| 271 } // namespace extensions | 278 } // namespace extensions |
| OLD | NEW |