| 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_service_unittest.h" | 5 #include "chrome/browser/extensions/extension_service_unittest.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 class ExtensionServiceTest | 456 class ExtensionServiceTest |
| 457 : public ExtensionServiceTestBase, public NotificationObserver { | 457 : public ExtensionServiceTestBase, public NotificationObserver { |
| 458 public: | 458 public: |
| 459 ExtensionServiceTest() : installed_(NULL) { | 459 ExtensionServiceTest() : installed_(NULL) { |
| 460 registrar_.Add(this, NotificationType::EXTENSION_LOADED, | 460 registrar_.Add(this, NotificationType::EXTENSION_LOADED, |
| 461 NotificationService::AllSources()); | 461 NotificationService::AllSources()); |
| 462 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, | 462 registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, |
| 463 NotificationService::AllSources()); | 463 NotificationService::AllSources()); |
| 464 registrar_.Add(this, NotificationType::EXTENSION_INSTALLED, | 464 registrar_.Add(this, NotificationType::EXTENSION_INSTALLED, |
| 465 NotificationService::AllSources()); | 465 NotificationService::AllSources()); |
| 466 registrar_.Add(this, NotificationType::THEME_INSTALLED, | |
| 467 NotificationService::AllSources()); | |
| 468 } | 466 } |
| 469 | 467 |
| 470 virtual void Observe(NotificationType type, | 468 virtual void Observe(NotificationType type, |
| 471 const NotificationSource& source, | 469 const NotificationSource& source, |
| 472 const NotificationDetails& details) { | 470 const NotificationDetails& details) { |
| 473 switch (type.value) { | 471 switch (type.value) { |
| 474 case NotificationType::EXTENSION_LOADED: { | 472 case NotificationType::EXTENSION_LOADED: { |
| 475 const Extension* extension = Details<const Extension>(details).ptr(); | 473 const Extension* extension = Details<const Extension>(details).ptr(); |
| 476 loaded_.push_back(make_scoped_refptr(extension)); | 474 loaded_.push_back(make_scoped_refptr(extension)); |
| 477 // The tests rely on the errors being in a certain order, which can vary | 475 // The tests rely on the errors being in a certain order, which can vary |
| 478 // depending on how filesystem iteration works. | 476 // depending on how filesystem iteration works. |
| 479 std::stable_sort(loaded_.begin(), loaded_.end(), ExtensionsOrder()); | 477 std::stable_sort(loaded_.begin(), loaded_.end(), ExtensionsOrder()); |
| 480 break; | 478 break; |
| 481 } | 479 } |
| 482 | 480 |
| 483 case NotificationType::EXTENSION_UNLOADED: { | 481 case NotificationType::EXTENSION_UNLOADED: { |
| 484 const Extension* e = | 482 const Extension* e = |
| 485 Details<UnloadedExtensionInfo>(details)->extension; | 483 Details<UnloadedExtensionInfo>(details)->extension; |
| 486 unloaded_id_ = e->id(); | 484 unloaded_id_ = e->id(); |
| 487 ExtensionList::iterator i = | 485 ExtensionList::iterator i = |
| 488 std::find(loaded_.begin(), loaded_.end(), e); | 486 std::find(loaded_.begin(), loaded_.end(), e); |
| 489 // TODO(erikkay) fix so this can be an assert. Right now the tests | 487 // TODO(erikkay) fix so this can be an assert. Right now the tests |
| 490 // are manually calling clear() on loaded_, so this isn't doable. | 488 // are manually calling clear() on loaded_, so this isn't doable. |
| 491 if (i == loaded_.end()) | 489 if (i == loaded_.end()) |
| 492 return; | 490 return; |
| 493 loaded_.erase(i); | 491 loaded_.erase(i); |
| 494 break; | 492 break; |
| 495 } | 493 } |
| 496 case NotificationType::EXTENSION_INSTALLED: | 494 case NotificationType::EXTENSION_INSTALLED: |
| 497 case NotificationType::THEME_INSTALLED: | |
| 498 installed_ = Details<const Extension>(details).ptr(); | 495 installed_ = Details<const Extension>(details).ptr(); |
| 499 break; | 496 break; |
| 500 | 497 |
| 501 default: | 498 default: |
| 502 DCHECK(false); | 499 DCHECK(false); |
| 503 } | 500 } |
| 504 } | 501 } |
| 505 | 502 |
| 506 void AddMockExternalProvider(ExternalExtensionProviderInterface* provider) { | 503 void AddMockExternalProvider(ExternalExtensionProviderInterface* provider) { |
| 507 service_->AddProviderForTesting(provider); | 504 service_->AddProviderForTesting(provider); |
| (...skipping 2905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3413 // Component extensions shouldn't get recourded in the prefs. | 3410 // Component extensions shouldn't get recourded in the prefs. |
| 3414 ValidatePrefKeyCount(0); | 3411 ValidatePrefKeyCount(0); |
| 3415 | 3412 |
| 3416 // Reload all extensions, and make sure it comes back. | 3413 // Reload all extensions, and make sure it comes back. |
| 3417 std::string extension_id = service_->extensions()->at(0)->id(); | 3414 std::string extension_id = service_->extensions()->at(0)->id(); |
| 3418 loaded_.clear(); | 3415 loaded_.clear(); |
| 3419 service_->ReloadExtensions(); | 3416 service_->ReloadExtensions(); |
| 3420 ASSERT_EQ(1u, service_->extensions()->size()); | 3417 ASSERT_EQ(1u, service_->extensions()->size()); |
| 3421 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); | 3418 EXPECT_EQ(extension_id, service_->extensions()->at(0)->id()); |
| 3422 } | 3419 } |
| OLD | NEW |