Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(966)

Unified Diff: chrome/browser/ui/toolbar/component_toolbar_actions_factory_unittest.cc

Issue 2693063003: Unload old Cast extensions after initializing ToolbarActionsModel (Closed)
Patch Set: Remove virtual, rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
new file mode 100644
index 0000000000000000000000000000000000000000..856a38f5c94aa4cf636199390cc2ce18b5fb72f7
--- /dev/null
+++ b/chrome/browser/ui/toolbar/component_toolbar_actions_factory_unittest.cc
@@ -0,0 +1,68 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h"
+#include "base/macros.h"
+#include "chrome/browser/extensions/extension_action_test_util.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_service_test_base.h"
+#include "extensions/browser/extension_registry.h"
+#include "extensions/common/extension.h"
+#include "extensions/common/extension_builder.h"
+#include "extensions/common/manifest_constants.h"
+#include "extensions/common/value_builder.h"
+
+class ComponentToolbarActionsFactoryTest
+ : public extensions::ExtensionServiceTestBase {
+ public:
+ ComponentToolbarActionsFactoryTest() {}
+ ~ComponentToolbarActionsFactoryTest() override {}
+
+ void SetUp() override {
+ extensions::ExtensionServiceTestBase::SetUp();
+ InitializeEmptyExtensionService();
+ }
+
+ scoped_refptr<const extensions::Extension> CreateExtensionWithId(
+ const std::string& extension_id) {
+ extensions::DictionaryBuilder manifest;
+ manifest.Set(extensions::manifest_keys::kName, "test name")
+ .Set(extensions::manifest_keys::kDescription, "test description")
+ .Set(extensions::manifest_keys::kManifestVersion, 1)
+ .Set(extensions::manifest_keys::kVersion, "1.0.0")
+ .Set(extensions::manifest_keys::kBrowserAction,
+ extensions::DictionaryBuilder().Build());
+
+ return extensions::ExtensionBuilder()
+ .SetManifest(manifest.Build())
+ .SetID(extension_id)
+ .SetLocation(extensions::Manifest::INTERNAL)
+ .Build();
+ }
+
+ // Adds |extension| and unloads migrated extensions. Returns true if
+ // |extension| was unloaded.
+ bool TestUnloadingMigratedExtensions(
+ scoped_refptr<const extensions::Extension> extension) {
+ service()->AddExtension(extension.get());
+ CHECK(registry()->enabled_extensions().Contains(extension->id()));
+ ComponentToolbarActionsFactory::GetInstance()->UnloadMigratedExtensions(
+ service(), registry());
+ return !registry()->enabled_extensions().Contains(extension->id());
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(ComponentToolbarActionsFactoryTest);
+};
+
+TEST_F(ComponentToolbarActionsFactoryTest, UnloadMigratedExtensions) {
+ EXPECT_TRUE(TestUnloadingMigratedExtensions(
+ CreateExtensionWithId(ComponentToolbarActionsFactory::kCastExtensionId)));
+ EXPECT_TRUE(TestUnloadingMigratedExtensions(CreateExtensionWithId(
+ ComponentToolbarActionsFactory::kCastBetaExtensionId)));
+ EXPECT_FALSE(TestUnloadingMigratedExtensions(
+ extensions::extension_action_test_util::CreateActionExtension(
+ "not_migrated_extension",
+ extensions::extension_action_test_util::BROWSER_ACTION)));
+}
« no previous file with comments | « chrome/browser/ui/toolbar/component_toolbar_actions_factory.cc ('k') | chrome/browser/ui/toolbar/toolbar_actions_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698