| 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/strings/string_util.h" |    8 #include "base/strings/string_util.h" | 
|    9 #include "base/strings/utf_string_conversions.h" |    9 #include "base/strings/utf_string_conversions.h" | 
|   10 #include "base/values.h" |   10 #include "base/values.h" | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
|   29                  << temp_dir_.path().LossyDisplayName(); |   29                  << temp_dir_.path().LossyDisplayName(); | 
|   30     LOG(WARNING) << temp_dir_.Delete(); |   30     LOG(WARNING) << temp_dir_.Delete(); | 
|   31   } |   31   } | 
|   32  |   32  | 
|   33   void SetupUnpacker(const std::string& crx_name) { |   33   void SetupUnpacker(const std::string& crx_name) { | 
|   34     base::FilePath original_path; |   34     base::FilePath original_path; | 
|   35     ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &original_path)); |   35     ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &original_path)); | 
|   36     original_path = original_path.AppendASCII("extensions") |   36     original_path = original_path.AppendASCII("extensions") | 
|   37         .AppendASCII("unpacker") |   37         .AppendASCII("unpacker") | 
|   38         .AppendASCII(crx_name); |   38         .AppendASCII(crx_name); | 
|   39     ASSERT_TRUE(file_util::PathExists(original_path)) << original_path.value(); |   39     ASSERT_TRUE(base::PathExists(original_path)) << original_path.value(); | 
|   40  |   40  | 
|   41     // Try bots won't let us write into DIR_TEST_DATA, so we have to create |   41     // Try bots won't let us write into DIR_TEST_DATA, so we have to create | 
|   42     // a temp folder to play in. |   42     // a temp folder to play in. | 
|   43     ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |   43     ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 
|   44  |   44  | 
|   45     base::FilePath crx_path = temp_dir_.path().AppendASCII(crx_name); |   45     base::FilePath crx_path = temp_dir_.path().AppendASCII(crx_name); | 
|   46     ASSERT_TRUE(base::CopyFile(original_path, crx_path)) << |   46     ASSERT_TRUE(base::CopyFile(original_path, crx_path)) << | 
|   47         "Original path " << original_path.value() << |   47         "Original path " << original_path.value() << | 
|   48         ", Crx path " << crx_path.value(); |   48         ", Crx path " << crx_path.value(); | 
|   49  |   49  | 
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  168   SetupUnpacker("bad_image.crx"); |  168   SetupUnpacker("bad_image.crx"); | 
|  169   EXPECT_FALSE(unpacker_->Run()); |  169   EXPECT_FALSE(unpacker_->Run()); | 
|  170   EXPECT_TRUE(StartsWith(unpacker_->error_message(), |  170   EXPECT_TRUE(StartsWith(unpacker_->error_message(), | 
|  171               ASCIIToUTF16(kExpected), |  171               ASCIIToUTF16(kExpected), | 
|  172               false)) << "Expected prefix: \"" << kExpected |  172               false)) << "Expected prefix: \"" << kExpected | 
|  173                       << "\", actual error: \"" << unpacker_->error_message() |  173                       << "\", actual error: \"" << unpacker_->error_message() | 
|  174                       << "\""; |  174                       << "\""; | 
|  175 } |  175 } | 
|  176  |  176  | 
|  177 }  // namespace extensions |  177 }  // namespace extensions | 
| OLD | NEW |