| 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/extension.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" |
| 14 #include "chrome/common/extensions/unpacker.h" | 15 #include "chrome/common/extensions/unpacker.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "third_party/skia/include/core/SkBitmap.h" | 17 #include "third_party/skia/include/core/SkBitmap.h" |
| 17 | 18 |
| 18 namespace errors = extension_manifest_errors; | 19 namespace errors = extension_manifest_errors; |
| 19 namespace filenames = extension_filenames; | 20 namespace filenames = extension_filenames; |
| 20 namespace keys = extension_manifest_keys; | 21 namespace keys = extension_manifest_keys; |
| 21 | 22 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 41 // a temp folder to play in. | 42 // a temp folder to play in. |
| 42 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 43 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 43 | 44 |
| 44 FilePath crx_path = temp_dir_.path().AppendASCII(crx_name); | 45 FilePath crx_path = temp_dir_.path().AppendASCII(crx_name); |
| 45 ASSERT_TRUE(file_util::CopyFile(original_path, crx_path)) << | 46 ASSERT_TRUE(file_util::CopyFile(original_path, crx_path)) << |
| 46 "Original path " << original_path.value() << | 47 "Original path " << original_path.value() << |
| 47 ", Crx path " << crx_path.value(); | 48 ", Crx path " << crx_path.value(); |
| 48 | 49 |
| 49 unpacker_.reset(new Unpacker(crx_path, | 50 unpacker_.reset(new Unpacker(crx_path, |
| 50 std::string(), | 51 std::string(), |
| 51 Extension::INTERNAL, | 52 Manifest::INTERNAL, |
| 52 Extension::NO_FLAGS)); | 53 Extension::NO_FLAGS)); |
| 53 } | 54 } |
| 54 | 55 |
| 55 protected: | 56 protected: |
| 56 base::ScopedTempDir temp_dir_; | 57 base::ScopedTempDir temp_dir_; |
| 57 scoped_ptr<Unpacker> unpacker_; | 58 scoped_ptr<Unpacker> unpacker_; |
| 58 }; | 59 }; |
| 59 | 60 |
| 60 // Crashes intermittently on Windows, see http://crbug.com/109238 | 61 // Crashes intermittently on Windows, see http://crbug.com/109238 |
| 61 #if defined(OS_WIN) | 62 #if defined(OS_WIN) |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 SetupUnpacker("bad_image.crx"); | 263 SetupUnpacker("bad_image.crx"); |
| 263 EXPECT_FALSE(unpacker_->Run()); | 264 EXPECT_FALSE(unpacker_->Run()); |
| 264 EXPECT_TRUE(StartsWith(unpacker_->error_message(), | 265 EXPECT_TRUE(StartsWith(unpacker_->error_message(), |
| 265 ASCIIToUTF16(kExpected), | 266 ASCIIToUTF16(kExpected), |
| 266 false)) << "Expected prefix: \"" << kExpected | 267 false)) << "Expected prefix: \"" << kExpected |
| 267 << "\", actual error: \"" << unpacker_->error_message() | 268 << "\", actual error: \"" << unpacker_->error_message() |
| 268 << "\""; | 269 << "\""; |
| 269 } | 270 } |
| 270 | 271 |
| 271 } // namespace extensions | 272 } // namespace extensions |
| OLD | NEW |