| Index: chrome/browser/ui/toolbar/component_toolbar_actions_factory_unittest.cc
|
| diff --git a/chrome/browser/ui/toolbar/component_toolbar_actions_factory_unittest.cc b/chrome/browser/ui/toolbar/component_toolbar_actions_factory_unittest.cc
|
| index 35ffdb42217934ddc050cb976b03bf0ef84d6221..90f5cc7f08515a5240c72597ffcefb9fdc35255f 100644
|
| --- a/chrome/browser/ui/toolbar/component_toolbar_actions_factory_unittest.cc
|
| +++ b/chrome/browser/ui/toolbar/component_toolbar_actions_factory_unittest.cc
|
| @@ -26,9 +26,7 @@ class ComponentToolbarActionsFactoryTest
|
| extensions::ExtensionServiceTestBase::SetUp();
|
| InitializeEmptyExtensionService();
|
| actions_factory_ =
|
| - extensions::extension_action_test_util::
|
| - CreateToolbarModelForProfileWithoutWaitingForReady(profile())
|
| - ->component_actions_factory();
|
| + base::MakeUnique<ComponentToolbarActionsFactory>(profile());
|
| }
|
|
|
| protected:
|
| @@ -51,28 +49,54 @@ class ComponentToolbarActionsFactoryTest
|
|
|
| // Adds |extension| and unloads migrated extensions. Returns true if
|
| // |extension| was unloaded.
|
| - bool TestUnloadingMigratedExtensions(
|
| + bool TestUnloadingEnabledMigratedExtension(
|
| scoped_refptr<const extensions::Extension> extension) {
|
| service()->AddExtension(extension.get());
|
| CHECK(registry()->enabled_extensions().Contains(extension->id()));
|
| - actions_factory_->UnloadMigratedExtensions(service(), registry());
|
| - return !registry()->enabled_extensions().Contains(extension->id());
|
| + actions_factory_->UnloadMigratedExtensions();
|
| + return !registry()->GenerateInstalledExtensionsSet()->Contains(
|
| + extension->id());
|
| }
|
|
|
| - ComponentToolbarActionsFactory* actions_factory_ = nullptr;
|
| + // Adds |extension|, disables it, and unloads migrated extensions. Returns
|
| + // true if |extension| was unloaded.
|
| + bool TestUnloadingDisabledMigratedExtension(
|
| + scoped_refptr<const extensions::Extension> extension) {
|
| + service()->AddExtension(extension.get());
|
| + service()->DisableExtension(extension->id(),
|
| + extensions::Extension::DISABLE_USER_ACTION);
|
| + CHECK(!registry()->enabled_extensions().Contains(extension->id()));
|
| + actions_factory_->UnloadMigratedExtensions();
|
| + return !registry()->GenerateInstalledExtensionsSet()->Contains(
|
| + extension->id());
|
| + }
|
| +
|
| + std::unique_ptr<ComponentToolbarActionsFactory> actions_factory_;
|
|
|
| private:
|
| DISALLOW_COPY_AND_ASSIGN(ComponentToolbarActionsFactoryTest);
|
| };
|
|
|
| TEST_F(ComponentToolbarActionsFactoryTest, UnloadMigratedExtensions) {
|
| - EXPECT_TRUE(TestUnloadingMigratedExtensions(
|
| + const std::string non_migrated_extension_id = "not_migrated_extension";
|
| +
|
| + EXPECT_TRUE(TestUnloadingEnabledMigratedExtension(
|
| + CreateExtensionWithId(ComponentToolbarActionsFactory::kCastExtensionId)));
|
| + EXPECT_TRUE(TestUnloadingEnabledMigratedExtension(CreateExtensionWithId(
|
| + ComponentToolbarActionsFactory::kCastBetaExtensionId)));
|
| + EXPECT_FALSE(TestUnloadingEnabledMigratedExtension(
|
| + extensions::extension_action_test_util::CreateActionExtension(
|
| + non_migrated_extension_id,
|
| + extensions::extension_action_test_util::BROWSER_ACTION)));
|
| +
|
| + // The behavior should be the same even when the extensions are disabled.
|
| + EXPECT_TRUE(TestUnloadingDisabledMigratedExtension(
|
| CreateExtensionWithId(ComponentToolbarActionsFactory::kCastExtensionId)));
|
| - EXPECT_TRUE(TestUnloadingMigratedExtensions(CreateExtensionWithId(
|
| + EXPECT_TRUE(TestUnloadingDisabledMigratedExtension(CreateExtensionWithId(
|
| ComponentToolbarActionsFactory::kCastBetaExtensionId)));
|
| - EXPECT_FALSE(TestUnloadingMigratedExtensions(
|
| + EXPECT_FALSE(TestUnloadingDisabledMigratedExtension(
|
| extensions::extension_action_test_util::CreateActionExtension(
|
| - "not_migrated_extension",
|
| + non_migrated_extension_id,
|
| extensions::extension_action_test_util::BROWSER_ACTION)));
|
| }
|
|
|
|
|