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/api/i18n/default_locale_handler.h" |
| 13 #include "chrome/common/extensions/extension.h" |
13 #include "chrome/common/extensions/extension_constants.h" | 14 #include "chrome/common/extensions/extension_constants.h" |
14 #include "chrome/common/extensions/extension_manifest_constants.h" | 15 #include "chrome/common/extensions/extension_manifest_constants.h" |
15 #include "chrome/common/extensions/manifest_handler.h" | 16 #include "chrome/common/extensions/manifest_handler.h" |
16 #include "chrome/common/extensions/unpacker.h" | 17 #include "chrome/common/extensions/unpacker.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "third_party/skia/include/core/SkBitmap.h" | 19 #include "third_party/skia/include/core/SkBitmap.h" |
19 | 20 |
20 namespace errors = extension_manifest_errors; | 21 namespace errors = extension_manifest_errors; |
21 namespace filenames = extension_filenames; | 22 namespace filenames = extension_filenames; |
22 namespace keys = extension_manifest_keys; | 23 namespace keys = extension_manifest_keys; |
(...skipping 26 matching lines...) Expand all Loading... |
49 // a temp folder to play in. | 50 // a temp folder to play in. |
50 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 51 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
51 | 52 |
52 FilePath crx_path = temp_dir_.path().AppendASCII(crx_name); | 53 FilePath crx_path = temp_dir_.path().AppendASCII(crx_name); |
53 ASSERT_TRUE(file_util::CopyFile(original_path, crx_path)) << | 54 ASSERT_TRUE(file_util::CopyFile(original_path, crx_path)) << |
54 "Original path " << original_path.value() << | 55 "Original path " << original_path.value() << |
55 ", Crx path " << crx_path.value(); | 56 ", Crx path " << crx_path.value(); |
56 | 57 |
57 unpacker_.reset(new Unpacker(crx_path, | 58 unpacker_.reset(new Unpacker(crx_path, |
58 std::string(), | 59 std::string(), |
59 Extension::INTERNAL, | 60 Manifest::INTERNAL, |
60 Extension::NO_FLAGS)); | 61 Extension::NO_FLAGS)); |
61 } | 62 } |
62 | 63 |
63 protected: | 64 protected: |
64 base::ScopedTempDir temp_dir_; | 65 base::ScopedTempDir temp_dir_; |
65 scoped_ptr<Unpacker> unpacker_; | 66 scoped_ptr<Unpacker> unpacker_; |
66 }; | 67 }; |
67 | 68 |
68 // Crashes intermittently on Windows, see http://crbug.com/109238 | 69 // Crashes intermittently on Windows, see http://crbug.com/109238 |
69 #if defined(OS_WIN) | 70 #if defined(OS_WIN) |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 SetupUnpacker("bad_image.crx"); | 271 SetupUnpacker("bad_image.crx"); |
271 EXPECT_FALSE(unpacker_->Run()); | 272 EXPECT_FALSE(unpacker_->Run()); |
272 EXPECT_TRUE(StartsWith(unpacker_->error_message(), | 273 EXPECT_TRUE(StartsWith(unpacker_->error_message(), |
273 ASCIIToUTF16(kExpected), | 274 ASCIIToUTF16(kExpected), |
274 false)) << "Expected prefix: \"" << kExpected | 275 false)) << "Expected prefix: \"" << kExpected |
275 << "\", actual error: \"" << unpacker_->error_message() | 276 << "\", actual error: \"" << unpacker_->error_message() |
276 << "\""; | 277 << "\""; |
277 } | 278 } |
278 | 279 |
279 } // namespace extensions | 280 } // namespace extensions |
OLD | NEW |