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/themes/theme_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 { |
| 35 testing::Test::SetUp(); |
| 36 extensions::ManifestHandler::Register(keys::kTheme, |
| 37 new extensions::ThemeHandler); |
| 38 } |
| 39 |
32 void SetupUnpacker(const std::string& crx_name) { | 40 void SetupUnpacker(const std::string& crx_name) { |
33 FilePath original_path; | 41 FilePath original_path; |
34 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &original_path)); | 42 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &original_path)); |
35 original_path = original_path.AppendASCII("extensions") | 43 original_path = original_path.AppendASCII("extensions") |
36 .AppendASCII("unpacker") | 44 .AppendASCII("unpacker") |
37 .AppendASCII(crx_name); | 45 .AppendASCII(crx_name); |
38 ASSERT_TRUE(file_util::PathExists(original_path)) << original_path.value(); | 46 ASSERT_TRUE(file_util::PathExists(original_path)) << original_path.value(); |
39 | 47 |
40 // Try bots won't let us write into DIR_TEST_DATA, so we have to create | 48 // Try bots won't let us write into DIR_TEST_DATA, so we have to create |
41 // a temp folder to play in. | 49 // a temp folder to play in. |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 SetupUnpacker("bad_image.crx"); | 270 SetupUnpacker("bad_image.crx"); |
263 EXPECT_FALSE(unpacker_->Run()); | 271 EXPECT_FALSE(unpacker_->Run()); |
264 EXPECT_TRUE(StartsWith(unpacker_->error_message(), | 272 EXPECT_TRUE(StartsWith(unpacker_->error_message(), |
265 ASCIIToUTF16(kExpected), | 273 ASCIIToUTF16(kExpected), |
266 false)) << "Expected prefix: \"" << kExpected | 274 false)) << "Expected prefix: \"" << kExpected |
267 << "\", actual error: \"" << unpacker_->error_message() | 275 << "\", actual error: \"" << unpacker_->error_message() |
268 << "\""; | 276 << "\""; |
269 } | 277 } |
270 | 278 |
271 } // namespace extensions | 279 } // namespace extensions |
OLD | NEW |