OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/extensions/extension_browsertest.h" | 5 #include "chrome/browser/extensions/extension_browsertest.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 ADD_FAILURE() << "Failed to delete crx: " << crx_path.value(); | 163 ADD_FAILURE() << "Failed to delete crx: " << crx_path.value(); |
164 return FilePath(); | 164 return FilePath(); |
165 } | 165 } |
166 | 166 |
167 FilePath pem_path = crx_path.DirName().AppendASCII("temp.pem"); | 167 FilePath pem_path = crx_path.DirName().AppendASCII("temp.pem"); |
168 if (!file_util::Delete(pem_path, false)) { | 168 if (!file_util::Delete(pem_path, false)) { |
169 ADD_FAILURE() << "Failed to delete pem: " << pem_path.value(); | 169 ADD_FAILURE() << "Failed to delete pem: " << pem_path.value(); |
170 return FilePath(); | 170 return FilePath(); |
171 } | 171 } |
172 | 172 |
| 173 return PackExtensionWithOptions(dir_path, crx_path, FilePath(), pem_path); |
| 174 } |
| 175 |
| 176 FilePath ExtensionBrowserTest::PackExtensionWithOptions( |
| 177 const FilePath& dir_path, |
| 178 const FilePath& crx_path, |
| 179 const FilePath& pem_path, |
| 180 const FilePath& pem_out_path) { |
173 if (!file_util::PathExists(dir_path)) { | 181 if (!file_util::PathExists(dir_path)) { |
174 ADD_FAILURE() << "Extension dir not found: " << dir_path.value(); | 182 ADD_FAILURE() << "Extension dir not found: " << dir_path.value(); |
175 return FilePath(); | 183 return FilePath(); |
176 } | 184 } |
177 | 185 |
| 186 if (!file_util::PathExists(pem_path) && pem_out_path.empty()) { |
| 187 ADD_FAILURE() << "Must specify a PEM file or PEM output path"; |
| 188 return FilePath(); |
| 189 } |
| 190 |
178 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator()); | 191 scoped_ptr<ExtensionCreator> creator(new ExtensionCreator()); |
179 if (!creator->Run(dir_path, | 192 if (!creator->Run(dir_path, |
180 crx_path, | 193 crx_path, |
181 FilePath(), // no existing pem, use empty path | 194 pem_path, |
182 pem_path)) { | 195 pem_out_path)) { |
183 ADD_FAILURE() << "ExtensionCreator::Run() failed: " | 196 ADD_FAILURE() << "ExtensionCreator::Run() failed: " |
184 << creator->error_message(); | 197 << creator->error_message(); |
185 return FilePath(); | 198 return FilePath(); |
186 } | 199 } |
187 | 200 |
188 if (!file_util::PathExists(crx_path)) { | 201 if (!file_util::PathExists(crx_path)) { |
189 ADD_FAILURE() << crx_path.value() << " was not created."; | 202 ADD_FAILURE() << crx_path.value() << " was not created."; |
190 return FilePath(); | 203 return FilePath(); |
191 } | 204 } |
192 return crx_path; | 205 return crx_path; |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 MessageLoopForUI::current()->Quit(); | 501 MessageLoopForUI::current()->Quit(); |
489 } | 502 } |
490 break; | 503 break; |
491 } | 504 } |
492 | 505 |
493 default: | 506 default: |
494 NOTREACHED(); | 507 NOTREACHED(); |
495 break; | 508 break; |
496 } | 509 } |
497 } | 510 } |
OLD | NEW |