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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 EXPECT_TRUE(unpacker_->Run()); | 129 EXPECT_TRUE(unpacker_->Run()); |
130 EXPECT_TRUE(unpacker_->error_message().empty()); | 130 EXPECT_TRUE(unpacker_->error_message().empty()); |
131 EXPECT_EQ(0U, unpacker_->parsed_catalogs()->size()); | 131 EXPECT_EQ(0U, unpacker_->parsed_catalogs()->size()); |
132 } | 132 } |
133 | 133 |
134 TEST_F(UnpackerTest, UnzipDirectoryError) { | 134 TEST_F(UnpackerTest, UnzipDirectoryError) { |
135 const char* kExpected = "Could not create directory for unzipping: "; | 135 const char* kExpected = "Could not create directory for unzipping: "; |
136 SetupUnpacker("good_package.crx"); | 136 SetupUnpacker("good_package.crx"); |
137 base::FilePath path = | 137 base::FilePath path = |
138 temp_dir_.path().AppendASCII(kTempExtensionName); | 138 temp_dir_.path().AppendASCII(kTempExtensionName); |
139 ASSERT_TRUE(file_util::WriteFile(path, "foo", 3)); | 139 ASSERT_TRUE(base::WriteFile(path, "foo", 3)); |
140 EXPECT_FALSE(unpacker_->Run()); | 140 EXPECT_FALSE(unpacker_->Run()); |
141 EXPECT_TRUE(StartsWith(unpacker_->error_message(), | 141 EXPECT_TRUE(StartsWith(unpacker_->error_message(), |
142 ASCIIToUTF16(kExpected), | 142 ASCIIToUTF16(kExpected), |
143 false)) << "Expected prefix: \"" << kExpected | 143 false)) << "Expected prefix: \"" << kExpected |
144 << "\", actual error: \"" << unpacker_->error_message() | 144 << "\", actual error: \"" << unpacker_->error_message() |
145 << "\""; | 145 << "\""; |
146 } | 146 } |
147 | 147 |
148 TEST_F(UnpackerTest, UnzipError) { | 148 TEST_F(UnpackerTest, UnzipError) { |
149 const char* kExpected = "Could not unzip extension"; | 149 const char* kExpected = "Could not unzip extension"; |
(...skipping 19 matching lines...) Expand all Loading... |
169 SetupUnpacker("bad_image.crx"); | 169 SetupUnpacker("bad_image.crx"); |
170 EXPECT_FALSE(unpacker_->Run()); | 170 EXPECT_FALSE(unpacker_->Run()); |
171 EXPECT_TRUE(StartsWith(unpacker_->error_message(), | 171 EXPECT_TRUE(StartsWith(unpacker_->error_message(), |
172 ASCIIToUTF16(kExpected), | 172 ASCIIToUTF16(kExpected), |
173 false)) << "Expected prefix: \"" << kExpected | 173 false)) << "Expected prefix: \"" << kExpected |
174 << "\", actual error: \"" << unpacker_->error_message() | 174 << "\", actual error: \"" << unpacker_->error_message() |
175 << "\""; | 175 << "\""; |
176 } | 176 } |
177 | 177 |
178 } // namespace extensions | 178 } // namespace extensions |
OLD | NEW |