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

Side by Side Diff: chrome/browser/ui/toolbar/toolbar_actions_bar_unittest.cc

Issue 766263003: [Extension Toolbar] Refactor and finish pop out logic for actions (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sky's + OWNERS Created 6 years 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
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 "chrome/browser/ui/toolbar/toolbar_actions_bar.h" 5 #include "chrome/browser/ui/toolbar/toolbar_actions_bar.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" 12 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
13 #include "chrome/browser/extensions/browser_action_test_util.h" 13 #include "chrome/browser/extensions/browser_action_test_util.h"
14 #include "chrome/browser/extensions/extension_action.h" 14 #include "chrome/browser/extensions/extension_action.h"
15 #include "chrome/browser/extensions/extension_action_manager.h" 15 #include "chrome/browser/extensions/extension_action_manager.h"
16 #include "chrome/browser/extensions/extension_action_test_util.h" 16 #include "chrome/browser/extensions/extension_action_test_util.h"
17 #include "chrome/browser/extensions/extension_service.h" 17 #include "chrome/browser/extensions/extension_service.h"
18 #include "chrome/browser/extensions/test_extension_system.h" 18 #include "chrome/browser/extensions/test_extension_system.h"
19 #include "chrome/browser/sessions/session_tab_helper.h" 19 #include "chrome/browser/sessions/session_tab_helper.h"
20 #include "chrome/browser/ui/tabs/tab_strip_model.h" 20 #include "chrome/browser/ui/tabs/tab_strip_model.h"
21 #include "chrome/browser/ui/toolbar/test_toolbar_actions_bar_helper.h" 21 #include "chrome/browser/ui/toolbar/test_toolbar_actions_bar_helper.h"
22 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h" 22 #include "chrome/browser/ui/toolbar/toolbar_action_view_controller.h"
23 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_delegate.h" 23 #include "chrome/browser/ui/toolbar/toolbar_actions_bar_delegate.h"
24 #include "chrome/test/base/browser_with_test_window_test.h" 24 #include "chrome/test/base/browser_with_test_window_test.h"
25 #include "extensions/browser/extension_system.h" 25 #include "extensions/browser/extension_system.h"
26 #include "extensions/common/extension.h" 26 #include "extensions/common/extension.h"
27 #include "extensions/common/feature_switch.h" 27 #include "extensions/common/feature_switch.h"
28 28
29 namespace {
30
31 // Verifies that the toolbar order matches for the given |actions_bar|. If the
32 // order matches, the return value is empty; otherwise, it contains the error.
33 std::string VerifyToolbarOrderForBar(
34 const ToolbarActionsBar* actions_bar,
35 BrowserActionTestUtil* browser_action_test_util,
36 const char* expected_names[],
37 size_t total_size,
38 size_t visible_count) {
39 const std::vector<ToolbarActionViewController*>& toolbar_actions =
40 actions_bar->toolbar_actions();
41 // If the total size is wrong, we risk segfaulting by continuing. Abort now.
42 if (total_size != toolbar_actions.size()) {
43 return base::StringPrintf("Incorrect action count: expected %d, found %d",
44 static_cast<int>(total_size),
45 static_cast<int>(toolbar_actions.size()));
46 }
47
48 // Check that the ToolbarActionsBar matches the expected state.
49 std::string error;
50 for (size_t i = 0; i < total_size; ++i) {
51 if (std::string(expected_names[i]) !=
52 base::UTF16ToUTF8(toolbar_actions[i]->GetActionName())) {
53 error += base::StringPrintf(
54 "Incorrect action in bar at index %d: expected '%s', found '%s'.\n",
55 static_cast<int>(i),
56 expected_names[i],
57 base::UTF16ToUTF8(toolbar_actions[i]->GetActionName()).c_str());
58 }
59 }
60 size_t icon_count = actions_bar->GetIconCount();
61 if (visible_count != icon_count)
62 error += base::StringPrintf(
63 "Incorrect visible count: expected %d, found %d.\n",
64 static_cast<int>(visible_count), static_cast<int>(icon_count));
65
66 // Test that the (platform-specific) toolbar view matches the expected state.
67 for (size_t i = 0; i < total_size; ++i) {
68 std::string id = browser_action_test_util->GetExtensionId(i);
69 if (id != toolbar_actions[i]->GetId()) {
70 error += base::StringPrintf(
71 "Incorrect action in view at index %d: expected '%s', found '%s'.\n",
72 static_cast<int>(i),
73 toolbar_actions[i]->GetId().c_str(),
74 id.c_str());
75 }
76 }
77 size_t view_icon_count = browser_action_test_util->VisibleBrowserActions();
78 if (visible_count != view_icon_count)
79 error += base::StringPrintf(
80 "Incorrect visible count in view: expected %d, found %d.\n",
81 static_cast<int>(visible_count), static_cast<int>(view_icon_count));
82
83 return error;
84 }
85
86 } // namespace
87
29 // A cross-platform unit test for the ToolbarActionsBar that uses the 88 // A cross-platform unit test for the ToolbarActionsBar that uses the
30 // TestToolbarActionsBarHelper to create the platform-specific containers. 89 // TestToolbarActionsBarHelper to create the platform-specific containers.
31 // TODO(devlin): Since this *does* use the real platform containers, in theory, 90 // TODO(devlin): Since this *does* use the real platform containers, in theory,
32 // we can move all the BrowserActionsBarBrowserTests to be unittests. See about 91 // we can move all the BrowserActionsBarBrowserTests to be unittests. See about
33 // doing this. 92 // doing this.
34 class ToolbarActionsBarUnitTest : public BrowserWithTestWindowTest { 93 class ToolbarActionsBarUnitTest : public BrowserWithTestWindowTest {
35 public: 94 public:
36 ToolbarActionsBarUnitTest() : toolbar_model_(nullptr) {} 95 ToolbarActionsBarUnitTest() : toolbar_model_(nullptr), use_redesign_(false) {}
96
97 // A constructor to allow subclasses to override the redesign value.
98 explicit ToolbarActionsBarUnitTest(bool use_redesign)
99 : toolbar_model_(nullptr),
100 use_redesign_(use_redesign) {}
101
37 ~ToolbarActionsBarUnitTest() override {} 102 ~ToolbarActionsBarUnitTest() override {}
38 103
39 protected: 104 protected:
40 void SetUp() override; 105 void SetUp() override;
41 void TearDown() override; 106 void TearDown() override;
42 107
43 // Activates the tab at the given |index| in the tab strip model. 108 // Activates the tab at the given |index| in the tab strip model.
44 void ActivateTab(int index); 109 void ActivateTab(int index);
45 110
46 // Set whether or not the given |action| wants to run on the |web_contents|. 111 // Set whether or not the given |action| wants to run on the |web_contents|.
(...skipping 16 matching lines...) Expand all
63 // in a debug message. These aren't enforced to be unique, so don't make 128 // in a debug message. These aren't enforced to be unique, so don't make
64 // duplicates. 129 // duplicates.
65 // If any of these is wrong, returns testing::AssertionFailure() with a 130 // If any of these is wrong, returns testing::AssertionFailure() with a
66 // message. 131 // message.
67 testing::AssertionResult VerifyToolbarOrder( 132 testing::AssertionResult VerifyToolbarOrder(
68 const char* expected_names[], 133 const char* expected_names[],
69 size_t total_size, 134 size_t total_size,
70 size_t visible_count) WARN_UNUSED_RESULT; 135 size_t visible_count) WARN_UNUSED_RESULT;
71 136
72 ToolbarActionsBar* toolbar_actions_bar() { 137 ToolbarActionsBar* toolbar_actions_bar() {
73 return toolbar_actions_bar_helper_->GetToolbarActionsBar(); 138 return main_bar_helper_->GetToolbarActionsBar();
139 }
140 ToolbarActionsBar* overflow_bar() {
141 return overflow_bar_helper_->GetToolbarActionsBar();
74 } 142 }
75 extensions::ExtensionToolbarModel* toolbar_model() { 143 extensions::ExtensionToolbarModel* toolbar_model() {
76 return toolbar_model_; 144 return toolbar_model_;
77 } 145 }
78 BrowserActionTestUtil* browser_action_test_util() { 146 BrowserActionTestUtil* browser_action_test_util() {
79 return browser_action_test_util_.get(); 147 return browser_action_test_util_.get();
80 } 148 }
149 BrowserActionTestUtil* overflow_browser_action_test_util() {
150 return overflow_browser_action_test_util_.get();
151 }
81 152
82 private: 153 private:
83 // The test helper that owns the ToolbarActionsBar and the platform-specific 154 // The test helper that owns the ToolbarActionsBar and the platform-specific
84 // view for it. 155 // view for it.
85 scoped_ptr<TestToolbarActionsBarHelper> toolbar_actions_bar_helper_; 156 scoped_ptr<TestToolbarActionsBarHelper> main_bar_helper_;
157
158 // The test helper for the overflow bar; only non-null if |use_redesign| is
159 // true.
160 scoped_ptr<TestToolbarActionsBarHelper> overflow_bar_helper_;
86 161
87 // The associated ExtensionToolbarModel (owned by the keyed service setup). 162 // The associated ExtensionToolbarModel (owned by the keyed service setup).
88 extensions::ExtensionToolbarModel* toolbar_model_; 163 extensions::ExtensionToolbarModel* toolbar_model_;
89 164
90 // A BrowserActionTestUtil object constructed with the associated 165 // A BrowserActionTestUtil object constructed with the associated
91 // ToolbarActionsBar. 166 // ToolbarActionsBar.
92 scoped_ptr<BrowserActionTestUtil> browser_action_test_util_; 167 scoped_ptr<BrowserActionTestUtil> browser_action_test_util_;
93 168
169 // The overflow container's BrowserActionTestUtil (only non-null if
170 // |use_redesign| is true).
171 scoped_ptr<BrowserActionTestUtil> overflow_browser_action_test_util_;
172
173 // True if the extension action redesign switch should be enabled.
174 bool use_redesign_;
175
176 scoped_ptr<extensions::FeatureSwitch::ScopedOverride> redesign_switch_;
177
94 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsBarUnitTest); 178 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsBarUnitTest);
95 }; 179 };
96 180
97 void ToolbarActionsBarUnitTest::SetUp() { 181 void ToolbarActionsBarUnitTest::SetUp() {
182 if (use_redesign_) {
183 redesign_switch_.reset(new extensions::FeatureSwitch::ScopedOverride(
184 extensions::FeatureSwitch::extension_action_redesign(), true));
185 }
186
98 BrowserWithTestWindowTest::SetUp(); 187 BrowserWithTestWindowTest::SetUp();
99 // The toolbar typically displays extension icons, so create some extension 188 // The toolbar typically displays extension icons, so create some extension
100 // test infrastructure. 189 // test infrastructure.
101 extensions::TestExtensionSystem* extension_system = 190 extensions::TestExtensionSystem* extension_system =
102 static_cast<extensions::TestExtensionSystem*>( 191 static_cast<extensions::TestExtensionSystem*>(
103 extensions::ExtensionSystem::Get(profile())); 192 extensions::ExtensionSystem::Get(profile()));
104 extension_system->CreateExtensionService( 193 extension_system->CreateExtensionService(
105 base::CommandLine::ForCurrentProcess(), 194 base::CommandLine::ForCurrentProcess(),
106 base::FilePath(), 195 base::FilePath(),
107 false); 196 false);
108 toolbar_model_ = 197 toolbar_model_ =
109 extensions::extension_action_test_util::CreateToolbarModelForProfile( 198 extensions::extension_action_test_util::CreateToolbarModelForProfile(
110 profile()); 199 profile());
111 200
112 toolbar_actions_bar_helper_ = TestToolbarActionsBarHelper::Create(browser()); 201 main_bar_helper_ = TestToolbarActionsBarHelper::Create(browser(), nullptr);
113 202
114 BrowserActionTestUtil::DisableAnimations(); 203 BrowserActionTestUtil::DisableAnimations();
115 browser_action_test_util_.reset( 204 browser_action_test_util_.reset(
116 new BrowserActionTestUtil(browser(), 205 new BrowserActionTestUtil(browser(),
117 toolbar_actions_bar()->delegate_for_test())); 206 toolbar_actions_bar()->delegate_for_test()));
207
208 if (use_redesign_) {
209 overflow_bar_helper_ =
210 TestToolbarActionsBarHelper::Create(browser(), main_bar_helper_.get());
211 overflow_browser_action_test_util_.reset(
212 new BrowserActionTestUtil(browser(),
213 overflow_bar()->delegate_for_test()));
214 }
118 } 215 }
119 216
120 void ToolbarActionsBarUnitTest::TearDown() { 217 void ToolbarActionsBarUnitTest::TearDown() {
121 // Since the profile gets destroyed in BrowserWithTestWindowTest::TearDown(), 218 // Since the profile gets destroyed in BrowserWithTestWindowTest::TearDown(),
122 // we need to delete this now. 219 // we need to delete this now.
123 toolbar_actions_bar_helper_.reset(); 220 overflow_bar_helper_.reset();
221 main_bar_helper_.reset();
222 redesign_switch_.reset();
124 BrowserWithTestWindowTest::TearDown(); 223 BrowserWithTestWindowTest::TearDown();
125 } 224 }
126 225
127 void ToolbarActionsBarUnitTest::ActivateTab(int index) { 226 void ToolbarActionsBarUnitTest::ActivateTab(int index) {
128 ASSERT_NE(nullptr, browser()->tab_strip_model()->GetWebContentsAt(index)); 227 ASSERT_NE(nullptr, browser()->tab_strip_model()->GetWebContentsAt(index));
129 browser()->tab_strip_model()->ActivateTabAt(index, true); 228 browser()->tab_strip_model()->ActivateTabAt(index, true);
130 // Normally, the toolbar view would (indirectly) tell the toolbar actions 229 // Normally, the toolbar view would (indirectly) tell the toolbar actions
131 // bar to update itself on tab change. Since this is a unittest, we have tell 230 // bar to update itself on tab change. Since this is a unittest, we have tell
132 // it to. 231 // it to.
133 toolbar_actions_bar()->Update(); 232 toolbar_actions_bar()->Update();
(...skipping 17 matching lines...) Expand all
151 bool wants_to_run) { 250 bool wants_to_run) {
152 action->SetIsVisible(SessionTabHelper::IdForTab(web_contents), wants_to_run); 251 action->SetIsVisible(SessionTabHelper::IdForTab(web_contents), wants_to_run);
153 extensions::ExtensionActionAPI::Get(profile())->NotifyChange( 252 extensions::ExtensionActionAPI::Get(profile())->NotifyChange(
154 action, web_contents, profile()); 253 action, web_contents, profile());
155 } 254 }
156 255
157 testing::AssertionResult ToolbarActionsBarUnitTest::VerifyToolbarOrder( 256 testing::AssertionResult ToolbarActionsBarUnitTest::VerifyToolbarOrder(
158 const char* expected_names[], 257 const char* expected_names[],
159 size_t total_size, 258 size_t total_size,
160 size_t visible_count) { 259 size_t visible_count) {
161 std::vector<ToolbarActionViewController*> toolbar_actions = 260 std::string main_bar_error =
162 toolbar_actions_bar()->toolbar_actions(); 261 VerifyToolbarOrderForBar(toolbar_actions_bar(),
163 // If the total size is wrong, we risk segfaulting by continuing. Abort now. 262 browser_action_test_util(),
164 if (total_size != toolbar_actions.size()) { 263 expected_names,
165 return testing::AssertionFailure() << "Incorrect action count: expected " << 264 total_size,
166 total_size << ", found " << toolbar_actions.size(); 265 visible_count);
266 std::string overflow_bar_error;
267 if (use_redesign_) {
268 overflow_bar_error =
269 VerifyToolbarOrderForBar(overflow_bar(),
270 overflow_browser_action_test_util(),
271 expected_names,
272 total_size,
273 total_size - visible_count);
274
167 } 275 }
168 276
169 // Check that the ToolbarActionsBar matches the expected state. 277 return main_bar_error.empty() && overflow_bar_error.empty() ?
170 std::string error; 278 testing::AssertionSuccess() :
171 for (size_t i = 0; i < total_size; ++i) { 279 testing::AssertionFailure() << "main bar error:\n" << main_bar_error <<
172 if (std::string(expected_names[i]) != 280 "overflow bar error:\n" << overflow_bar_error;
173 base::UTF16ToUTF8(toolbar_actions[i]->GetActionName())) {
174 error += base::StringPrintf(
175 "Incorrect action in bar at index %d: expected '%s', found '%s'.\n",
176 static_cast<int>(i),
177 expected_names[i],
178 base::UTF16ToUTF8(toolbar_actions[i]->GetActionName()).c_str());
179 }
180 }
181 size_t icon_count = toolbar_actions_bar()->GetIconCount();
182 if (visible_count != icon_count)
183 error += base::StringPrintf(
184 "Incorrect visible count: expected %d, found %d.\n",
185 static_cast<int>(visible_count), static_cast<int>(icon_count));
186
187 // Test that the (platform-specific) toolbar view matches the expected state.
188 for (size_t i = 0; i < total_size; ++i) {
189 std::string id = browser_action_test_util()->GetExtensionId(i);
190 if (id != toolbar_actions[i]->GetId()) {
191 error += base::StringPrintf(
192 "Incorrect action in view at index %d: expected '%s', found '%s'.\n",
193 static_cast<int>(i),
194 toolbar_actions[i]->GetId().c_str(),
195 id.c_str());
196 }
197 }
198 size_t view_icon_count = browser_action_test_util()->VisibleBrowserActions();
199 if (visible_count != view_icon_count)
200 error += base::StringPrintf(
201 "Incorrect visible count in view: expected %d, found %d.\n",
202 static_cast<int>(visible_count), static_cast<int>(view_icon_count));
203
204 return error.empty() ? testing::AssertionSuccess() :
205 testing::AssertionFailure() << error;
206 } 281 }
207 282
208 // A version of the ToolbarActionsBarUnitTest that enables the toolbar redesign.
209 class ToolbarActionsBarUnitTestWithSwitch : public ToolbarActionsBarUnitTest {
210 public:
211 ToolbarActionsBarUnitTestWithSwitch() {}
212 ~ToolbarActionsBarUnitTestWithSwitch() override {}
213
214 protected:
215 void SetUp() override {
216 redesign_switch_.reset(new extensions::FeatureSwitch::ScopedOverride(
217 extensions::FeatureSwitch::extension_action_redesign(), true));
218 ToolbarActionsBarUnitTest::SetUp();
219 }
220 void TearDown() override {
221 redesign_switch_.reset();
222 ToolbarActionsBarUnitTest::TearDown();
223 }
224
225 private:
226 scoped_ptr<extensions::FeatureSwitch::ScopedOverride> redesign_switch_;
227
228 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsBarUnitTestWithSwitch);
229 };
230
231 TEST_F(ToolbarActionsBarUnitTest, BasicToolbarActionsBarTest) { 283 TEST_F(ToolbarActionsBarUnitTest, BasicToolbarActionsBarTest) {
232 // Add three extensions to the profile; this is the easiest way to have 284 // Add three extensions to the profile; this is the easiest way to have
233 // toolbar actions. 285 // toolbar actions.
234 for (int i = 0; i < 3; ++i) { 286 for (int i = 0; i < 3; ++i) {
235 CreateAndAddExtension( 287 CreateAndAddExtension(
236 base::StringPrintf("extension %d", i), 288 base::StringPrintf("extension %d", i),
237 extensions::extension_action_test_util::BROWSER_ACTION); 289 extensions::extension_action_test_util::BROWSER_ACTION);
238 } 290 }
239 291
240 const ToolbarActionsBar::PlatformSettings& platform_settings = 292 const ToolbarActionsBar::PlatformSettings& platform_settings =
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 EXPECT_EQ(2u, toolbar_actions_bar()->GetIconCount()); 384 EXPECT_EQ(2u, toolbar_actions_bar()->GetIconCount());
333 385
334 // If we shrink the bar so that a full icon can't fit, it should resize to 386 // If we shrink the bar so that a full icon can't fit, it should resize to
335 // hide that icon. 387 // hide that icon.
336 toolbar_actions_bar()->OnResizeComplete(width - 1); 388 toolbar_actions_bar()->OnResizeComplete(width - 1);
337 width -= ToolbarActionsBar::IconWidth(true); 389 width -= ToolbarActionsBar::IconWidth(true);
338 EXPECT_EQ(width, toolbar_actions_bar()->GetPreferredSize().width()); 390 EXPECT_EQ(width, toolbar_actions_bar()->GetPreferredSize().width());
339 EXPECT_EQ(1u, toolbar_actions_bar()->GetIconCount()); 391 EXPECT_EQ(1u, toolbar_actions_bar()->GetIconCount());
340 } 392 }
341 393
394 class ToolbarActionsBarPopOutUnitTest
395 : public ToolbarActionsBarUnitTest {
396 public:
397 ToolbarActionsBarPopOutUnitTest() : ToolbarActionsBarUnitTest(true) {}
398
399 protected:
400 void SetUp() override {
401 ToolbarActionsBar::set_pop_out_actions_to_run_for_testing(true);
402 ToolbarActionsBarUnitTest::SetUp();
403 }
404
405 private:
406 DISALLOW_COPY_AND_ASSIGN(ToolbarActionsBarPopOutUnitTest);
407 };
408
342 // Test that toolbar actions can pop themselves out of overflow if they want to 409 // Test that toolbar actions can pop themselves out of overflow if they want to
343 // act on a given tab. 410 // act on a given tab.
344 TEST_F(ToolbarActionsBarUnitTestWithSwitch, ActionsPopOutToAct) { 411 TEST_F(ToolbarActionsBarPopOutUnitTest, ActionsPopOutToAct) {
345 // Add three extensions to the profile; this is the easiest way to have 412 // Add three extensions to the profile; this is the easiest way to have
346 // toolbar actions. 413 // toolbar actions.
347 const char kBrowserAction[] = "browser action"; 414 const char kBrowserAction[] = "browser action";
348 const char kPageAction[] = "page action"; 415 const char kPageAction[] = "page action";
349 const char kSynthetic[] = "synthetic"; // This has a generated action icon. 416 const char kSynthetic[] = "synthetic"; // This has a generated action icon.
350 417
351 CreateAndAddExtension(kBrowserAction, 418 CreateAndAddExtension(kBrowserAction,
352 extensions::extension_action_test_util::BROWSER_ACTION); 419 extensions::extension_action_test_util::BROWSER_ACTION);
353 scoped_refptr<const extensions::Extension> page_action = 420 scoped_refptr<const extensions::Extension> page_action =
354 CreateAndAddExtension( 421 CreateAndAddExtension(
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 SetActionWantsToRunOnTab(action, web_contents, true); 557 SetActionWantsToRunOnTab(action, web_contents, true);
491 558
492 // Even though the second page action triggered first, the order of actions 559 // Even though the second page action triggered first, the order of actions
493 // wanting to run should respect the normal order of actions. 560 // wanting to run should respect the normal order of actions.
494 const char* expected_names[] = 561 const char* expected_names[] =
495 { kPageAction, kPageAction2, kBrowserAction, kSynthetic }; 562 { kPageAction, kPageAction2, kBrowserAction, kSynthetic };
496 EXPECT_TRUE(VerifyToolbarOrder(expected_names, 4u, 2u)); 563 EXPECT_TRUE(VerifyToolbarOrder(expected_names, 4u, 2u));
497 } 564 }
498 } 565 }
499 566
500 TEST_F(ToolbarActionsBarUnitTestWithSwitch, AdjustingActionsThatWantToAct) { 567 TEST_F(ToolbarActionsBarPopOutUnitTest, AdjustingActionsThatWantToAct) {
501 // Add three extensions to the profile; this is the easiest way to have 568 // Add three extensions to the profile; this is the easiest way to have
502 // toolbar actions. 569 // toolbar actions.
503 const char kBrowserAction[] = "browser action"; 570 const char kBrowserAction[] = "browser action";
504 const char kPageAction[] = "page action"; 571 const char kPageAction[] = "page action";
505 const char kSynthetic[] = "synthetic"; // This has a generated action icon. 572 const char kSynthetic[] = "synthetic"; // This has a generated action icon.
506 573
507 CreateAndAddExtension(kBrowserAction, 574 CreateAndAddExtension(kBrowserAction,
508 extensions::extension_action_test_util::BROWSER_ACTION); 575 extensions::extension_action_test_util::BROWSER_ACTION);
509 scoped_refptr<const extensions::Extension> page_action = 576 scoped_refptr<const extensions::Extension> page_action =
510 CreateAndAddExtension( 577 CreateAndAddExtension(
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 EXPECT_TRUE(VerifyToolbarOrder(expected_names, 3u, 3u)); 679 EXPECT_TRUE(VerifyToolbarOrder(expected_names, 3u, 3u));
613 // Move "page action" to the overflow menu. 680 // Move "page action" to the overflow menu.
614 toolbar_actions_bar()->OnDragDrop( 681 toolbar_actions_bar()->OnDragDrop(
615 0, 2, ToolbarActionsBar::DRAG_TO_OVERFLOW); 682 0, 2, ToolbarActionsBar::DRAG_TO_OVERFLOW);
616 const char* expected_names2[] = { kBrowserAction, kSynthetic, kPageAction }; 683 const char* expected_names2[] = { kBrowserAction, kSynthetic, kPageAction };
617 EXPECT_TRUE(VerifyToolbarOrder(expected_names2, 3u, 2u)); 684 EXPECT_TRUE(VerifyToolbarOrder(expected_names2, 3u, 2u));
618 SetActionWantsToRunOnTab(action, web_contents, false); 685 SetActionWantsToRunOnTab(action, web_contents, false);
619 EXPECT_TRUE(VerifyToolbarOrder(expected_names2, 3u, 2u)); 686 EXPECT_TRUE(VerifyToolbarOrder(expected_names2, 3u, 2u));
620 } 687 }
621 } 688 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698