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

Side by Side Diff: chrome/browser/ui/views/toolbar/browser_actions_container_browsertest.cc

Issue 640423003: Create a cross-platform browsertest for the browser actions bar (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/views/toolbar/browser_actions_container.h" 5 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h"
6 6
7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" 7 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h"
9 #include "chrome/browser/extensions/browser_action_test_util.h" 8 #include "chrome/browser/extensions/browser_action_test_util.h"
10 #include "chrome/browser/extensions/extension_browsertest.h"
11 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/extension_toolbar_model.h" 10 #include "chrome/browser/extensions/extension_toolbar_model.h"
13 #include "chrome/browser/ui/browser_window.h" 11 #include "chrome/browser/ui/browser_window.h"
14 #include "chrome/browser/ui/browser_window_testing_views.h" 12 #include "chrome/browser/ui/browser_window_testing_views.h"
13 #include "chrome/browser/ui/toolbar/browser_actions_bar_browsertest.h"
15 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h" 14 #include "chrome/browser/ui/views/extensions/browser_action_drag_data.h"
16 #include "chrome/browser/ui/views/frame/browser_view.h" 15 #include "chrome/browser/ui/views/frame/browser_view.h"
17 #include "chrome/browser/ui/views/toolbar/browser_action_view.h" 16 #include "chrome/browser/ui/views/toolbar/browser_action_view.h"
18 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" 17 #include "chrome/browser/ui/views/toolbar/toolbar_view.h"
19 #include "components/crx_file/id_util.h"
20 #include "content/public/test/test_utils.h"
21 #include "extensions/browser/extension_prefs.h" 18 #include "extensions/browser/extension_prefs.h"
22 #include "extensions/browser/extension_registry.h"
23 #include "extensions/common/extension.h" 19 #include "extensions/common/extension.h"
24 #include "extensions/common/extension_builder.h"
25 #include "extensions/common/value_builder.h"
26 #include "ui/base/dragdrop/drop_target_event.h" 20 #include "ui/base/dragdrop/drop_target_event.h"
27 #include "ui/base/dragdrop/os_exchange_data.h" 21 #include "ui/base/dragdrop/os_exchange_data.h"
28 #include "ui/gfx/geometry/point.h" 22 #include "ui/gfx/geometry/point.h"
29 #include "ui/views/view.h" 23 #include "ui/views/view.h"
30 24
31 using extensions::Extension; 25 using extensions::Extension;
32 26
33 namespace { 27 // TODO(devlin): Continue moving any tests that should be platform independent
34 28 // from this file to the crossplatform tests in
35 scoped_refptr<const Extension> CreateExtension(const std::string& name, 29 // chrome/browser/ui/toolbar/browser_actions_bar_browsertest.cc.
36 bool has_browser_action) {
37 extensions::DictionaryBuilder manifest;
38 manifest.Set("name", name).
39 Set("description", "an extension").
40 Set("manifest_version", 2).
41 Set("version", "1.0");
42 if (has_browser_action)
43 manifest.Set("browser_action", extensions::DictionaryBuilder().Pass());
44 return extensions::ExtensionBuilder().
45 SetManifest(manifest.Pass()).
46 SetID(crx_file::id_util::GenerateId(name)).
47 Build();
48 }
49
50 } // namespace
51
52 class BrowserActionsContainerTest : public ExtensionBrowserTest {
53 public:
54 BrowserActionsContainerTest() {
55 }
56 virtual ~BrowserActionsContainerTest() {}
57
58 protected:
59 virtual void SetUpCommandLine(base::CommandLine* command_line) override {
60 BrowserActionsContainer::disable_animations_during_testing_ = true;
61 ExtensionBrowserTest::SetUpCommandLine(command_line);
62 }
63
64 virtual void SetUpOnMainThread() override {
65 ExtensionBrowserTest::SetUpOnMainThread();
66 browser_actions_bar_.reset(new BrowserActionTestUtil(browser()));
67 }
68
69 virtual void TearDownOnMainThread() override {
70 BrowserActionsContainer::disable_animations_during_testing_ = false;
71 ExtensionBrowserTest::TearDownOnMainThread();
72 }
73
74 BrowserActionTestUtil* browser_actions_bar() {
75 return browser_actions_bar_.get();
76 }
77
78 // Creates three different extensions, each with a browser action, and adds
79 // them to associated ExtensionService. These can then be accessed via
80 // extension_[a|b|c]().
81 void LoadExtensions();
82
83 const Extension* extension_a() const { return extension_a_.get(); }
84 const Extension* extension_b() const { return extension_b_.get(); }
85 const Extension* extension_c() const { return extension_c_.get(); }
86
87 private:
88 scoped_ptr<BrowserActionTestUtil> browser_actions_bar_;
89
90 // Extensions with browser actions used for testing.
91 scoped_refptr<const Extension> extension_a_;
92 scoped_refptr<const Extension> extension_b_;
93 scoped_refptr<const Extension> extension_c_;
94 };
95
96 void BrowserActionsContainerTest::LoadExtensions() {
97 // Create three extensions with browser actions.
98 extension_a_ = CreateExtension("alpha", true);
99 extension_b_ = CreateExtension("beta", true);
100 extension_c_ = CreateExtension("gamma", true);
101
102 const Extension* extensions[] =
103 { extension_a(), extension_b(), extension_c() };
104 extensions::ExtensionRegistry* registry =
105 extensions::ExtensionRegistry::Get(profile());
106 // Add each, and verify that it is both correctly added to the extension
107 // registry and to the browser actions container.
108 for (size_t i = 0; i < arraysize(extensions); ++i) {
109 extension_service()->AddExtension(extensions[i]);
110 EXPECT_TRUE(registry->enabled_extensions().GetByID(extensions[i]->id())) <<
111 extensions[i]->name();
112 EXPECT_EQ(static_cast<int>(i + 1),
113 browser_actions_bar_->NumberOfBrowserActions());
114 EXPECT_TRUE(browser_actions_bar_->HasIcon(i));
115 EXPECT_EQ(static_cast<int>(i + 1),
116 browser_actions_bar()->VisibleBrowserActions());
117 }
118 }
119
120 // Test the basic functionality.
121 IN_PROC_BROWSER_TEST_F(BrowserActionsContainerTest, Basic) {
122 // Load an extension with no browser action.
123 extension_service()->AddExtension(CreateExtension("alpha", false).get());
124 // This extension should not be in the model (has no browser action).
125 EXPECT_EQ(0, browser_actions_bar()->NumberOfBrowserActions());
126
127 // Load an extension with a browser action.
128 extension_service()->AddExtension(CreateExtension("beta", true).get());
129 EXPECT_EQ(1, browser_actions_bar()->NumberOfBrowserActions());
130 EXPECT_TRUE(browser_actions_bar()->HasIcon(0));
131
132 // Unload the extension.
133 std::string id = browser_actions_bar()->GetExtensionId(0);
134 UnloadExtension(id);
135 EXPECT_EQ(0, browser_actions_bar()->NumberOfBrowserActions());
136 }
137 30
138 // Test moving various browser actions. This is not to check the logic of the 31 // Test moving various browser actions. This is not to check the logic of the
139 // move (that's in the toolbar model tests), but just to check our ui. 32 // move (that's in the toolbar model tests), but just to check our ui.
140 IN_PROC_BROWSER_TEST_F(BrowserActionsContainerTest, MoveBrowserActions) { 33 IN_PROC_BROWSER_TEST_F(BrowserActionsBarBrowserTest, MoveBrowserActions) {
141 LoadExtensions(); 34 LoadExtensions();
142 35
143 EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions()); 36 EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions());
144 EXPECT_EQ(3, browser_actions_bar()->NumberOfBrowserActions()); 37 EXPECT_EQ(3, browser_actions_bar()->NumberOfBrowserActions());
145 38
146 extensions::ExtensionToolbarModel* model = 39 extensions::ExtensionToolbarModel* model =
147 extensions::ExtensionToolbarModel::Get(profile()); 40 extensions::ExtensionToolbarModel::Get(profile());
148 ASSERT_TRUE(model); 41 ASSERT_TRUE(model);
149 42
150 // Order is now A B C. 43 // Order is now A B C.
(...skipping 16 matching lines...) Expand all
167 // Move B to middle position. Order is C B A. 60 // Move B to middle position. Order is C B A.
168 model->MoveExtensionIcon(extension_b(), 1); 61 model->MoveExtensionIcon(extension_b(), 1);
169 EXPECT_EQ(extension_c()->id(), browser_actions_bar()->GetExtensionId(0)); 62 EXPECT_EQ(extension_c()->id(), browser_actions_bar()->GetExtensionId(0));
170 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(1)); 63 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(1));
171 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(2)); 64 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(2));
172 } 65 }
173 66
174 // Test that dragging browser actions works, and that dragging a browser action 67 // Test that dragging browser actions works, and that dragging a browser action
175 // from the overflow menu results in it "popping" out (growing the container 68 // from the overflow menu results in it "popping" out (growing the container
176 // size by 1), rather than just reordering the extensions. 69 // size by 1), rather than just reordering the extensions.
177 IN_PROC_BROWSER_TEST_F(BrowserActionsContainerTest, DragBrowserActions) { 70 IN_PROC_BROWSER_TEST_F(BrowserActionsBarBrowserTest, DragBrowserActions) {
178 LoadExtensions(); 71 LoadExtensions();
179 72
180 // Sanity check: All extensions showing; order is A B C. 73 // Sanity check: All extensions showing; order is A B C.
181 EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions()); 74 EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions());
182 EXPECT_EQ(3, browser_actions_bar()->NumberOfBrowserActions()); 75 EXPECT_EQ(3, browser_actions_bar()->NumberOfBrowserActions());
183 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(0)); 76 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(0));
184 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(1)); 77 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(1));
185 EXPECT_EQ(extension_c()->id(), browser_actions_bar()->GetExtensionId(2)); 78 EXPECT_EQ(extension_c()->id(), browser_actions_bar()->GetExtensionId(2));
186 79
187 BrowserActionsContainer* container = 80 BrowserActionsContainer* container =
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 EXPECT_EQ(3u, container->VisibleBrowserActions()); 156 EXPECT_EQ(3u, container->VisibleBrowserActions());
264 EXPECT_FALSE(container->chevron()->visible()); 157 EXPECT_FALSE(container->chevron()->visible());
265 EXPECT_EQ(-1, model->GetVisibleIconCount()); 158 EXPECT_EQ(-1, model->GetVisibleIconCount());
266 159
267 // TODO(devlin): Ideally, we'd also have tests for dragging from the legacy 160 // TODO(devlin): Ideally, we'd also have tests for dragging from the legacy
268 // overflow menu (i.e., chevron) to the main bar, but this requires either 161 // overflow menu (i.e., chevron) to the main bar, but this requires either
269 // having a fairly complicated interactive UI test or finding a good way to 162 // having a fairly complicated interactive UI test or finding a good way to
270 // mock up the BrowserActionOverflowMenuController. 163 // mock up the BrowserActionOverflowMenuController.
271 } 164 }
272 165
273 IN_PROC_BROWSER_TEST_F(BrowserActionsContainerTest, Visibility) { 166 IN_PROC_BROWSER_TEST_F(BrowserActionsBarBrowserTest, Visibility) {
274 LoadExtensions(); 167 LoadExtensions();
275 168
276 // Change container to show only one action, rest in overflow: A, [B, C]. 169 // Change container to show only one action, rest in overflow: A, [B, C].
277 browser_actions_bar()->SetIconVisibilityCount(1); 170 browser_actions_bar()->SetIconVisibilityCount(1);
278 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions()); 171 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions());
279 172
280 // Disable extension A (should disappear). State becomes: B [C]. 173 // Disable extension A (should disappear). State becomes: B [C].
281 DisableExtension(extension_a()->id()); 174 DisableExtension(extension_a()->id());
282 EXPECT_EQ(2, browser_actions_bar()->NumberOfBrowserActions()); 175 EXPECT_EQ(2, browser_actions_bar()->NumberOfBrowserActions());
283 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions()); 176 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions());
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 // should be visible. 256 // should be visible.
364 EnableExtension(extension_c()->id()); 257 EnableExtension(extension_c()->id());
365 EXPECT_EQ(2, browser_actions_bar()->VisibleBrowserActions()); 258 EXPECT_EQ(2, browser_actions_bar()->VisibleBrowserActions());
366 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(0)); 259 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(0));
367 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(1)); 260 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(1));
368 EXPECT_TRUE(container->chevron()->visible()); 261 EXPECT_TRUE(container->chevron()->visible());
369 } 262 }
370 263
371 // Test that changes performed in one container affect containers in other 264 // Test that changes performed in one container affect containers in other
372 // windows so that it is consistent. 265 // windows so that it is consistent.
373 IN_PROC_BROWSER_TEST_F(BrowserActionsContainerTest, MultipleWindows) { 266 IN_PROC_BROWSER_TEST_F(BrowserActionsBarBrowserTest, MultipleWindows) {
374 LoadExtensions(); 267 LoadExtensions();
375 BrowserActionsContainer* first = 268 BrowserActionsContainer* first =
376 BrowserView::GetBrowserViewForBrowser(browser())->toolbar()-> 269 BrowserView::GetBrowserViewForBrowser(browser())->toolbar()->
377 browser_actions(); 270 browser_actions();
378 271
379 // Create a second browser. 272 // Create a second browser.
380 Browser* second_browser = new Browser( 273 Browser* second_browser = new Browser(
381 Browser::CreateParams(profile(), browser()->host_desktop_type())); 274 Browser::CreateParams(profile(), browser()->host_desktop_type()));
382 BrowserActionsContainer* second = 275 BrowserActionsContainer* second =
383 BrowserView::GetBrowserViewForBrowser(second_browser)->toolbar()-> 276 BrowserView::GetBrowserViewForBrowser(second_browser)->toolbar()->
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 EXPECT_EQ(extension_c(), first->GetBrowserActionViewAt(2u)->extension()); 311 EXPECT_EQ(extension_c(), first->GetBrowserActionViewAt(2u)->extension());
419 EXPECT_EQ(extension_c(), second->GetBrowserActionViewAt(2u)->extension()); 312 EXPECT_EQ(extension_c(), second->GetBrowserActionViewAt(2u)->extension());
420 313
421 // Next, simulate a resize by shrinking the container. 314 // Next, simulate a resize by shrinking the container.
422 first->OnResize(1, true); 315 first->OnResize(1, true);
423 // The first and second container should each have resized. 316 // The first and second container should each have resized.
424 EXPECT_EQ(2u, first->VisibleBrowserActions()); 317 EXPECT_EQ(2u, first->VisibleBrowserActions());
425 EXPECT_EQ(2u, second->VisibleBrowserActions()); 318 EXPECT_EQ(2u, second->VisibleBrowserActions());
426 } 319 }
427 320
428 IN_PROC_BROWSER_TEST_F(BrowserActionsContainerTest, ForceHide) { 321 IN_PROC_BROWSER_TEST_F(BrowserActionsBarBrowserTest, ForceHide) {
429 // Load extension A (with a browser action). 322 LoadExtensions();
430 extension_service()->AddExtension(CreateExtension("alpha", true).get());
431 EXPECT_EQ(1, browser_actions_bar()->NumberOfBrowserActions());
432 EXPECT_TRUE(browser_actions_bar()->HasIcon(0));
433 EXPECT_EQ(1, browser_actions_bar()->VisibleBrowserActions());
434 std::string idA = browser_actions_bar()->GetExtensionId(0);
435 323
436 // Force hide this browser action. 324 EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions());
325 EXPECT_EQ(extension_a()->id(), browser_actions_bar()->GetExtensionId(0));
326 // Force hide one of the extension's browser action.
Peter Kasting 2014/10/10 20:32:51 Nit: extensions'
Devlin 2014/10/10 20:40:23 Done.
437 extensions::ExtensionActionAPI::SetBrowserActionVisibility( 327 extensions::ExtensionActionAPI::SetBrowserActionVisibility(
438 extensions::ExtensionPrefs::Get(browser()->profile()), idA, false); 328 extensions::ExtensionPrefs::Get(browser()->profile()),
439 EXPECT_EQ(0, browser_actions_bar()->VisibleBrowserActions()); 329 extension_a()->id(),
330 false);
331 // The browser action for Extension A should be removed.
332 EXPECT_EQ(2, browser_actions_bar()->VisibleBrowserActions());
333 EXPECT_EQ(extension_b()->id(), browser_actions_bar()->GetExtensionId(0));
440 } 334 }
441 335
442 // Test that the BrowserActionsContainer responds correctly when the underlying 336 // Test that the BrowserActionsContainer responds correctly when the underlying
443 // model enters highlight mode, and that browser actions are undraggable in 337 // model enters highlight mode, and that browser actions are undraggable in
444 // highlight mode. (Highlight mode itself it tested more thoroughly in the 338 // highlight mode. (Highlight mode itself it tested more thoroughly in the
445 // ExtensionToolbarModel browsertests). 339 // ExtensionToolbarModel browsertests).
446 IN_PROC_BROWSER_TEST_F(BrowserActionsContainerTest, HighlightMode) { 340 IN_PROC_BROWSER_TEST_F(BrowserActionsBarBrowserTest, HighlightMode) {
447 LoadExtensions(); 341 LoadExtensions();
448 342
449 EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions()); 343 EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions());
450 EXPECT_EQ(3, browser_actions_bar()->NumberOfBrowserActions()); 344 EXPECT_EQ(3, browser_actions_bar()->NumberOfBrowserActions());
451 345
452 BrowserActionsContainer* container = browser() 346 BrowserActionsContainer* container = browser()
453 ->window() 347 ->window()
454 ->GetBrowserWindowTesting() 348 ->GetBrowserWindowTesting()
455 ->GetToolbarView() 349 ->GetToolbarView()
456 ->browser_actions(); 350 ->browser_actions();
(...skipping 22 matching lines...) Expand all
479 373
480 // We should go back to normal after leaving highlight mode. 374 // We should go back to normal after leaving highlight mode.
481 model->StopHighlighting(); 375 model->StopHighlighting();
482 EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions()); 376 EXPECT_EQ(3, browser_actions_bar()->VisibleBrowserActions());
483 EXPECT_EQ(3, browser_actions_bar()->NumberOfBrowserActions()); 377 EXPECT_EQ(3, browser_actions_bar()->NumberOfBrowserActions());
484 action_view = container->GetBrowserActionViewAt(0); 378 action_view = container->GetBrowserActionViewAt(0);
485 EXPECT_TRUE(container->CanStartDragForView(action_view, point, point)); 379 EXPECT_TRUE(container->CanStartDragForView(action_view, point, point));
486 } 380 }
487 381
488 // Test the behavior of the overflow container for Extension Actions. 382 // Test the behavior of the overflow container for Extension Actions.
489 class BrowserActionsContainerOverflowTest : public BrowserActionsContainerTest { 383 class BrowserActionsContainerOverflowTest
384 : public BrowserActionsBarBrowserTest {
490 public: 385 public:
491 BrowserActionsContainerOverflowTest() : main_bar_(NULL), model_(NULL) { 386 BrowserActionsContainerOverflowTest() : main_bar_(NULL), model_(NULL) {
492 } 387 }
493 virtual ~BrowserActionsContainerOverflowTest() { 388 virtual ~BrowserActionsContainerOverflowTest() {
494 } 389 }
495 390
496 protected: 391 protected:
497 // Returns true if the order of the BrowserActionViews in |main_bar_| 392 // Returns true if the order of the BrowserActionViews in |main_bar_|
498 // and |overflow_bar_| match. 393 // and |overflow_bar_| match.
499 bool ViewOrdersMatch(); 394 bool ViewOrdersMatch();
(...skipping 25 matching lines...) Expand all
525 extensions::ExtensionToolbarModel* model_; 420 extensions::ExtensionToolbarModel* model_;
526 421
527 // Enable the feature redesign switch. 422 // Enable the feature redesign switch.
528 scoped_ptr<extensions::FeatureSwitch::ScopedOverride> enable_redesign_; 423 scoped_ptr<extensions::FeatureSwitch::ScopedOverride> enable_redesign_;
529 424
530 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainerOverflowTest); 425 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainerOverflowTest);
531 }; 426 };
532 427
533 void BrowserActionsContainerOverflowTest::SetUpCommandLine( 428 void BrowserActionsContainerOverflowTest::SetUpCommandLine(
534 base::CommandLine* command_line) { 429 base::CommandLine* command_line) {
535 BrowserActionsContainerTest::SetUpCommandLine(command_line); 430 BrowserActionsBarBrowserTest::SetUpCommandLine(command_line);
536 enable_redesign_.reset(new extensions::FeatureSwitch::ScopedOverride( 431 enable_redesign_.reset(new extensions::FeatureSwitch::ScopedOverride(
537 extensions::FeatureSwitch::extension_action_redesign(), 432 extensions::FeatureSwitch::extension_action_redesign(),
538 true)); 433 true));
539 } 434 }
540 435
541 void BrowserActionsContainerOverflowTest::SetUpOnMainThread() { 436 void BrowserActionsContainerOverflowTest::SetUpOnMainThread() {
542 BrowserActionsContainerTest::SetUpOnMainThread(); 437 BrowserActionsBarBrowserTest::SetUpOnMainThread();
543 main_bar_ = BrowserView::GetBrowserViewForBrowser(browser()) 438 main_bar_ = BrowserView::GetBrowserViewForBrowser(browser())
544 ->toolbar()->browser_actions(); 439 ->toolbar()->browser_actions();
545 overflow_bar_.reset(new BrowserActionsContainer(browser(), NULL, main_bar_)); 440 overflow_bar_.reset(new BrowserActionsContainer(browser(), NULL, main_bar_));
546 overflow_bar_->set_owned_by_client(); 441 overflow_bar_->set_owned_by_client();
547 model_ = extensions::ExtensionToolbarModel::Get(profile()); 442 model_ = extensions::ExtensionToolbarModel::Get(profile());
548 } 443 }
549 444
550 void BrowserActionsContainerOverflowTest::TearDownOnMainThread() { 445 void BrowserActionsContainerOverflowTest::TearDownOnMainThread() {
551 overflow_bar_.reset(); 446 overflow_bar_.reset();
552 enable_redesign_.reset(); 447 enable_redesign_.reset();
553 BrowserActionsContainerTest::TearDownOnMainThread(); 448 BrowserActionsBarBrowserTest::TearDownOnMainThread();
554 } 449 }
555 450
556 bool BrowserActionsContainerOverflowTest::ViewOrdersMatch() { 451 bool BrowserActionsContainerOverflowTest::ViewOrdersMatch() {
557 if (main_bar_->num_browser_actions() != 452 if (main_bar_->num_browser_actions() !=
558 overflow_bar_->num_browser_actions()) 453 overflow_bar_->num_browser_actions())
559 return false; 454 return false;
560 for (size_t i = 0; i < main_bar_->num_browser_actions(); ++i) { 455 for (size_t i = 0; i < main_bar_->num_browser_actions(); ++i) {
561 if (main_bar_->GetBrowserActionViewAt(i)->extension() != 456 if (main_bar_->GetBrowserActionViewAt(i)->extension() !=
562 overflow_bar_->GetBrowserActionViewAt(i)->extension()) 457 overflow_bar_->GetBrowserActionViewAt(i)->extension())
563 return false; 458 return false;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 597
703 main_bar()->OnDragUpdated(target_event3); 598 main_bar()->OnDragUpdated(target_event3);
704 main_bar()->OnPerformDrop(target_event3); 599 main_bar()->OnPerformDrop(target_event3);
705 600
706 // Order should be A C B, and there should be no extensions in overflow. 601 // Order should be A C B, and there should be no extensions in overflow.
707 EXPECT_EQ(extension_a(), main_bar()->GetBrowserActionViewAt(0)->extension()); 602 EXPECT_EQ(extension_a(), main_bar()->GetBrowserActionViewAt(0)->extension());
708 EXPECT_EQ(extension_c(), main_bar()->GetBrowserActionViewAt(1)->extension()); 603 EXPECT_EQ(extension_c(), main_bar()->GetBrowserActionViewAt(1)->extension());
709 EXPECT_EQ(extension_b(), main_bar()->GetBrowserActionViewAt(2)->extension()); 604 EXPECT_EQ(extension_b(), main_bar()->GetBrowserActionViewAt(2)->extension());
710 VerifyVisibleCount(3u); 605 VerifyVisibleCount(3u);
711 } 606 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698