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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/toolbar/component_toolbar_actions_factory.h"
6 #include "base/macros.h"
7 #include "chrome/browser/extensions/extension_action_test_util.h"
8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_service_test_base.h"
10 #include "extensions/browser/extension_registry.h"
11 #include "extensions/common/extension.h"
12 #include "extensions/common/extension_builder.h"
13 #include "extensions/common/manifest_constants.h"
14 #include "extensions/common/value_builder.h"
15
16 class ComponentToolbarActionsFactoryTest
17 : public extensions::ExtensionServiceTestBase {
18 public:
19 ComponentToolbarActionsFactoryTest() {}
20 ~ComponentToolbarActionsFactoryTest() override {}
21
22 void SetUp() override {
23 extensions::ExtensionServiceTestBase::SetUp();
24 InitializeEmptyExtensionService();
25 }
26
27 scoped_refptr<const extensions::Extension> CreateExtensionWithId(
28 const std::string& extension_id) {
29 extensions::DictionaryBuilder manifest;
30 manifest.Set(extensions::manifest_keys::kName, "test name")
31 .Set(extensions::manifest_keys::kDescription, "test description")
32 .Set(extensions::manifest_keys::kManifestVersion, 1)
33 .Set(extensions::manifest_keys::kVersion, "1.0.0")
34 .Set(extensions::manifest_keys::kBrowserAction,
35 extensions::DictionaryBuilder().Build());
36
37 return extensions::ExtensionBuilder()
38 .SetManifest(manifest.Build())
39 .SetID(extension_id)
40 .SetLocation(extensions::Manifest::INTERNAL)
41 .Build();
42 }
43
44 // Adds |extension| and unloads migrated extensions. Returns true if
45 // |extension| was unloaded.
46 bool TestUnloadingMigratedExtensions(
47 scoped_refptr<const extensions::Extension> extension) {
48 service()->AddExtension(extension.get());
49 CHECK(registry()->enabled_extensions().Contains(extension->id()));
50 ComponentToolbarActionsFactory::GetInstance()->UnloadMigratedExtensions(
51 service(), registry());
52 return !registry()->enabled_extensions().Contains(extension->id());
53 }
54
55 private:
56 DISALLOW_COPY_AND_ASSIGN(ComponentToolbarActionsFactoryTest);
57 };
58
59 TEST_F(ComponentToolbarActionsFactoryTest, UnloadMigratedExtensions) {
60 EXPECT_TRUE(TestUnloadingMigratedExtensions(
61 CreateExtensionWithId(ComponentToolbarActionsFactory::kCastExtensionId)));
62 EXPECT_TRUE(TestUnloadingMigratedExtensions(CreateExtensionWithId(
63 ComponentToolbarActionsFactory::kCastBetaExtensionId)));
64 EXPECT_FALSE(TestUnloadingMigratedExtensions(
65 extensions::extension_action_test_util::CreateActionExtension(
66 "not_migrated_extension",
67 extensions::extension_action_test_util::BROWSER_ACTION)));
68 }
OLDNEW
« 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