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

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

Issue 981603002: [Extensions Toolbar] Component extensions default to the front of the toolbar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Latest master Created 5 years, 9 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
« no previous file with comments | « chrome/browser/extensions/extension_toolbar_model.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/files/file_util.h" 5 #include "base/files/file_util.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/stringprintf.h" 9 #include "base/strings/stringprintf.h"
10 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" 10 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
(...skipping 10 matching lines...) Expand all
21 #include "chrome/browser/sessions/session_tab_helper.h" 21 #include "chrome/browser/sessions/session_tab_helper.h"
22 #include "chrome/common/extensions/api/extension_action/action_info.h" 22 #include "chrome/common/extensions/api/extension_action/action_info.h"
23 #include "components/crx_file/id_util.h" 23 #include "components/crx_file/id_util.h"
24 #include "content/public/test/test_renderer_host.h" 24 #include "content/public/test/test_renderer_host.h"
25 #include "content/public/test/web_contents_tester.h" 25 #include "content/public/test/web_contents_tester.h"
26 #include "extensions/browser/extension_prefs.h" 26 #include "extensions/browser/extension_prefs.h"
27 #include "extensions/browser/extension_registry.h" 27 #include "extensions/browser/extension_registry.h"
28 #include "extensions/browser/extension_system.h" 28 #include "extensions/browser/extension_system.h"
29 #include "extensions/browser/test_extension_registry_observer.h" 29 #include "extensions/browser/test_extension_registry_observer.h"
30 #include "extensions/common/extension.h" 30 #include "extensions/common/extension.h"
31 #include "extensions/common/extension_builder.h"
31 #include "extensions/common/feature_switch.h" 32 #include "extensions/common/feature_switch.h"
33 #include "extensions/common/value_builder.h"
32 34
33 #if defined(USE_AURA) 35 #if defined(USE_AURA)
34 #include "ui/aura/env.h" 36 #include "ui/aura/env.h"
35 #endif 37 #endif
36 38
37 namespace extensions { 39 namespace extensions {
38 40
39 namespace { 41 namespace {
40 42
41 // A simple observer that tracks the number of times certain events occur. 43 // A simple observer that tracks the number of times certain events occur.
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 base::RunLoop().RunUntilIdle(); 1124 base::RunLoop().RunUntilIdle();
1123 1125
1124 // The new order should be reflected in the model. 1126 // The new order should be reflected in the model.
1125 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(0)); 1127 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(0));
1126 EXPECT_EQ(browser_action_c(), GetExtensionAtIndex(1)); 1128 EXPECT_EQ(browser_action_c(), GetExtensionAtIndex(1));
1127 EXPECT_EQ(browser_action_a(), GetExtensionAtIndex(2)); 1129 EXPECT_EQ(browser_action_a(), GetExtensionAtIndex(2));
1128 EXPECT_EQ(inserted_and_removed_difference, 1130 EXPECT_EQ(inserted_and_removed_difference,
1129 observer()->inserted_count() - observer()->removed_count()); 1131 observer()->inserted_count() - observer()->removed_count());
1130 } 1132 }
1131 1133
1134 TEST_F(ExtensionToolbarModelUnitTest, ComponentExtesionsAddedToEnd) {
1135 Init();
1136
1137 ASSERT_TRUE(AddBrowserActionExtensions());
1138
1139 EXPECT_EQ(browser_action_a(), GetExtensionAtIndex(0));
1140 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(1));
1141 EXPECT_EQ(browser_action_c(), GetExtensionAtIndex(2));
1142
1143 const char kName[] = "component";
1144 DictionaryBuilder manifest;
1145 manifest.Set("name", kName)
1146 .Set("description", "An extension")
1147 .Set("manifest_version", 2)
1148 .Set("version", "1.0.0")
1149 .Set("browser_action", DictionaryBuilder().Pass());
1150 scoped_refptr<const Extension> component_extension =
1151 ExtensionBuilder().SetManifest(manifest.Pass())
1152 .SetID(crx_file::id_util::GenerateId(kName))
1153 .SetLocation(Manifest::COMPONENT)
1154 .Build();
1155 service()->AddExtension(component_extension.get());
1156
1157 EXPECT_EQ(component_extension.get(), GetExtensionAtIndex(0));
1158 EXPECT_EQ(browser_action_a(), GetExtensionAtIndex(1));
1159 EXPECT_EQ(browser_action_b(), GetExtensionAtIndex(2));
1160 EXPECT_EQ(browser_action_c(), GetExtensionAtIndex(3));
1161 }
1162
1132 } // namespace extensions 1163 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_toolbar_model.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698