OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_service_test_with_install.h" | 5 #include "chrome/browser/extensions/extension_service_test_with_install.h" |
6 | 6 |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/extensions/crx_installer.h" | 9 #include "chrome/browser/extensions/crx_installer.h" |
10 #include "chrome/browser/extensions/extension_creator.h" | 10 #include "chrome/browser/extensions/extension_creator.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 return VerifyCrxInstall(path, install_state, std::string()); | 190 return VerifyCrxInstall(path, install_state, std::string()); |
191 } | 191 } |
192 | 192 |
193 const Extension* ExtensionServiceTestWithInstall::VerifyCrxInstall( | 193 const Extension* ExtensionServiceTestWithInstall::VerifyCrxInstall( |
194 const base::FilePath& path, | 194 const base::FilePath& path, |
195 InstallState install_state, | 195 InstallState install_state, |
196 const std::string& expected_old_name) { | 196 const std::string& expected_old_name) { |
197 std::vector<base::string16> errors = GetErrors(); | 197 std::vector<base::string16> errors = GetErrors(); |
198 const Extension* extension = nullptr; | 198 const Extension* extension = nullptr; |
199 if (install_state != INSTALL_FAILED) { | 199 if (install_state != INSTALL_FAILED) { |
200 if (install_state == INSTALL_NEW) | 200 if (install_state == INSTALL_NEW || install_state == INSTALL_WITHOUT_LOAD) |
201 ++expected_extensions_count_; | 201 ++expected_extensions_count_; |
202 | 202 |
203 EXPECT_TRUE(installed_) << path.value(); | 203 EXPECT_TRUE(installed_) << path.value(); |
204 // If and only if INSTALL_UPDATED, it should have the is_update flag. | 204 // If and only if INSTALL_UPDATED, it should have the is_update flag. |
205 EXPECT_EQ(install_state == INSTALL_UPDATED, was_update_) | 205 EXPECT_EQ(install_state == INSTALL_UPDATED, was_update_) |
206 << path.value(); | 206 << path.value(); |
207 // If INSTALL_UPDATED, old_name_ should match the given string. | 207 // If INSTALL_UPDATED, old_name_ should match the given string. |
208 if (install_state == INSTALL_UPDATED && !expected_old_name.empty()) | 208 if (install_state == INSTALL_UPDATED && !expected_old_name.empty()) |
209 EXPECT_EQ(expected_old_name, old_name_); | 209 EXPECT_EQ(expected_old_name, old_name_); |
210 EXPECT_EQ(0u, errors.size()) << path.value(); | 210 EXPECT_EQ(0u, errors.size()) << path.value(); |
211 | 211 |
212 if (install_state == INSTALL_WITHOUT_LOAD) { | 212 if (install_state == INSTALL_WITHOUT_LOAD) { |
213 EXPECT_EQ(0u, loaded_.size()) << path.value(); | 213 EXPECT_EQ(0u, loaded_.size()) << path.value(); |
| 214 extension = installed_; |
214 } else { | 215 } else { |
215 EXPECT_EQ(1u, loaded_.size()) << path.value(); | 216 EXPECT_EQ(1u, loaded_.size()) << path.value(); |
216 size_t actual_extension_count = | 217 size_t actual_extension_count = |
217 registry()->enabled_extensions().size() + | 218 registry()->enabled_extensions().size() + |
218 registry()->disabled_extensions().size(); | 219 registry()->disabled_extensions().size(); |
219 EXPECT_EQ(expected_extensions_count_, actual_extension_count) << | 220 EXPECT_EQ(expected_extensions_count_, actual_extension_count) << |
220 path.value(); | 221 path.value(); |
221 extension = loaded_[0].get(); | 222 extension = loaded_[0].get(); |
222 EXPECT_TRUE(service()->GetExtensionById(extension->id(), false)) | 223 EXPECT_TRUE(service()->GetExtensionById(extension->id(), false)) |
223 << path.value(); | 224 << path.value(); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 content::WindowedNotificationObserver observer( | 423 content::WindowedNotificationObserver observer( |
423 extensions::NOTIFICATION_CRX_INSTALLER_DONE, | 424 extensions::NOTIFICATION_CRX_INSTALLER_DONE, |
424 content::Source<extensions::CrxInstaller>(installer.get())); | 425 content::Source<extensions::CrxInstaller>(installer.get())); |
425 | 426 |
426 installer->InstallCrx(crx_path); | 427 installer->InstallCrx(crx_path); |
427 | 428 |
428 observer.Wait(); | 429 observer.Wait(); |
429 } | 430 } |
430 | 431 |
431 } // namespace extensions | 432 } // namespace extensions |
OLD | NEW |