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

Side by Side Diff: chrome/browser/extensions/extension_toolbar_model_unittest.cc

Issue 481433005: Extensions: Move id_util functions to crx_file component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update GN build Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/macros.h" 5 #include "base/macros.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_service_test_base.h" 9 #include "chrome/browser/extensions/extension_service_test_base.h"
10 #include "chrome/browser/extensions/extension_toolbar_model.h" 10 #include "chrome/browser/extensions/extension_toolbar_model.h"
11 #include "chrome/browser/extensions/test_extension_system.h" 11 #include "chrome/browser/extensions/test_extension_system.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/extensions/api/extension_action/action_info.h" 13 #include "chrome/common/extensions/api/extension_action/action_info.h"
14 #include "components/crx_file/id_util.h"
14 #include "extensions/browser/extension_registry.h" 15 #include "extensions/browser/extension_registry.h"
15 #include "extensions/browser/extension_system.h" 16 #include "extensions/browser/extension_system.h"
16 #include "extensions/common/extension.h" 17 #include "extensions/common/extension.h"
17 #include "extensions/common/extension_builder.h" 18 #include "extensions/common/extension_builder.h"
18 #include "extensions/common/feature_switch.h" 19 #include "extensions/common/feature_switch.h"
19 #include "extensions/common/id_util.h"
20 #include "extensions/common/manifest_constants.h" 20 #include "extensions/common/manifest_constants.h"
21 #include "extensions/common/value_builder.h" 21 #include "extensions/common/value_builder.h"
22 22
23 namespace extensions { 23 namespace extensions {
24 24
25 namespace { 25 namespace {
26 26
27 // Create an extension. If |action_key| is non-NULL, it should point to either 27 // Create an extension. If |action_key| is non-NULL, it should point to either
28 // kBrowserAction or kPageAction, and the extension will have the associated 28 // kBrowserAction or kPageAction, and the extension will have the associated
29 // action. 29 // action.
30 scoped_refptr<const Extension> GetActionExtension(const std::string& name, 30 scoped_refptr<const Extension> GetActionExtension(const std::string& name,
31 const char* action_key) { 31 const char* action_key) {
32 DictionaryBuilder manifest; 32 DictionaryBuilder manifest;
33 manifest.Set("name", name) 33 manifest.Set("name", name)
34 .Set("description", "An extension") 34 .Set("description", "An extension")
35 .Set("manifest_version", 2) 35 .Set("manifest_version", 2)
36 .Set("version", "1.0.0"); 36 .Set("version", "1.0.0");
37 if (action_key) 37 if (action_key)
38 manifest.Set(action_key, DictionaryBuilder().Pass()); 38 manifest.Set(action_key, DictionaryBuilder().Pass());
39 39
40 return ExtensionBuilder().SetManifest(manifest.Pass()) 40 return ExtensionBuilder().SetManifest(manifest.Pass())
41 .SetID(id_util::GenerateId(name)) 41 .SetID(crx_file::id_util::GenerateId(name))
42 .Build(); 42 .Build();
43 } 43 }
44 44
45 } // namespace 45 } // namespace
46 46
47 // TODO(devlin): Experiment with moving (some of the) 47 // TODO(devlin): Experiment with moving (some of the)
48 // ExtensionToolbarModelBrowserTests into here? 48 // ExtensionToolbarModelBrowserTests into here?
49 class ExtensionToolbarModelUnitTest : public ExtensionServiceTestBase { 49 class ExtensionToolbarModelUnitTest : public ExtensionServiceTestBase {
50 protected: 50 protected:
51 // Initialize the ExtensionService, ExtensionToolbarModel, and 51 // Initialize the ExtensionService, ExtensionToolbarModel, and
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 // With the switch on, extensions with page actions and no action should also 130 // With the switch on, extensions with page actions and no action should also
131 // be displayed in the toolbar. 131 // be displayed in the toolbar.
132 const ExtensionList& extensions = toolbar_model()->toolbar_items(); 132 const ExtensionList& extensions = toolbar_model()->toolbar_items();
133 ASSERT_EQ(3u, extensions.size()); 133 ASSERT_EQ(3u, extensions.size());
134 EXPECT_EQ(browser_action(), extensions[0]); 134 EXPECT_EQ(browser_action(), extensions[0]);
135 EXPECT_EQ(page_action(), extensions[1]); 135 EXPECT_EQ(page_action(), extensions[1]);
136 EXPECT_EQ(no_action(), extensions[2]); 136 EXPECT_EQ(no_action(), extensions[2]);
137 } 137 }
138 138
139 } // namespace extensions 139 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698