| OLD | NEW |
| 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/extensions/api/extension_action/extension_action_api.h" | 7 #include "chrome/browser/extensions/api/extension_action/extension_action_api.h" |
| 8 #include "chrome/browser/extensions/browser_action_test_util.h" | 8 #include "chrome/browser/extensions/browser_action_test_util.h" |
| 9 #include "chrome/browser/extensions/extension_toolbar_model.h" | 9 #include "chrome/browser/extensions/extension_toolbar_model.h" |
| 10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 action_view = container->GetBrowserActionViewAt(0); | 324 action_view = container->GetBrowserActionViewAt(0); |
| 325 EXPECT_TRUE(container->CanStartDragForView(action_view, point, point)); | 325 EXPECT_TRUE(container->CanStartDragForView(action_view, point, point)); |
| 326 } | 326 } |
| 327 | 327 |
| 328 // Test the behavior of the overflow container for Extension Actions. | 328 // Test the behavior of the overflow container for Extension Actions. |
| 329 class BrowserActionsContainerOverflowTest | 329 class BrowserActionsContainerOverflowTest |
| 330 : public BrowserActionsBarBrowserTest { | 330 : public BrowserActionsBarBrowserTest { |
| 331 public: | 331 public: |
| 332 BrowserActionsContainerOverflowTest() : main_bar_(NULL), model_(NULL) { | 332 BrowserActionsContainerOverflowTest() : main_bar_(NULL), model_(NULL) { |
| 333 } | 333 } |
| 334 virtual ~BrowserActionsContainerOverflowTest() { | 334 ~BrowserActionsContainerOverflowTest() override {} |
| 335 } | |
| 336 | 335 |
| 337 protected: | 336 protected: |
| 338 // Returns true if the order of the BrowserActionViews in |main_bar_| | 337 // Returns true if the order of the BrowserActionViews in |main_bar_| |
| 339 // and |overflow_bar_| match. | 338 // and |overflow_bar_| match. |
| 340 bool ViewOrdersMatch(); | 339 bool ViewOrdersMatch(); |
| 341 | 340 |
| 342 // Returns Success if the visible count matches |expected_visible|. This means | 341 // Returns Success if the visible count matches |expected_visible|. This means |
| 343 // that the number of visible browser actions in |main_bar_| is | 342 // that the number of visible browser actions in |main_bar_| is |
| 344 // |expected_visible| and shows the first icons, and that the overflow bar | 343 // |expected_visible| and shows the first icons, and that the overflow bar |
| 345 // shows all (and only) the remainder. | 344 // shows all (and only) the remainder. |
| 346 testing::AssertionResult VerifyVisibleCount(size_t expected_visible); | 345 testing::AssertionResult VerifyVisibleCount(size_t expected_visible); |
| 347 | 346 |
| 348 // Accessors. | 347 // Accessors. |
| 349 BrowserActionsContainer* main_bar() { return main_bar_; } | 348 BrowserActionsContainer* main_bar() { return main_bar_; } |
| 350 BrowserActionsContainer* overflow_bar() { return overflow_bar_.get(); } | 349 BrowserActionsContainer* overflow_bar() { return overflow_bar_.get(); } |
| 351 extensions::ExtensionToolbarModel* model() { return model_; } | 350 extensions::ExtensionToolbarModel* model() { return model_; } |
| 352 | 351 |
| 353 private: | 352 private: |
| 354 virtual void SetUpCommandLine(base::CommandLine* command_line) override; | 353 void SetUpCommandLine(base::CommandLine* command_line) override; |
| 355 virtual void SetUpOnMainThread() override; | 354 void SetUpOnMainThread() override; |
| 356 virtual void TearDownOnMainThread() override; | 355 void TearDownOnMainThread() override; |
| 357 | 356 |
| 358 // The main BrowserActionsContainer (owned by the browser view). | 357 // The main BrowserActionsContainer (owned by the browser view). |
| 359 BrowserActionsContainer* main_bar_; | 358 BrowserActionsContainer* main_bar_; |
| 360 | 359 |
| 361 // The overflow BrowserActionsContainer. We manufacture this so that we don't | 360 // The overflow BrowserActionsContainer. We manufacture this so that we don't |
| 362 // have to open the wrench menu. | 361 // have to open the wrench menu. |
| 363 scoped_ptr<BrowserActionsContainer> overflow_bar_; | 362 scoped_ptr<BrowserActionsContainer> overflow_bar_; |
| 364 | 363 |
| 365 // The associated toolbar model. | 364 // The associated toolbar model. |
| 366 extensions::ExtensionToolbarModel* model_; | 365 extensions::ExtensionToolbarModel* model_; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 | 541 |
| 543 main_bar()->OnDragUpdated(target_event3); | 542 main_bar()->OnDragUpdated(target_event3); |
| 544 main_bar()->OnPerformDrop(target_event3); | 543 main_bar()->OnPerformDrop(target_event3); |
| 545 | 544 |
| 546 // Order should be A C B, and there should be no extensions in overflow. | 545 // Order should be A C B, and there should be no extensions in overflow. |
| 547 EXPECT_EQ(extension_a()->id(), main_bar()->GetIdAt(0u)); | 546 EXPECT_EQ(extension_a()->id(), main_bar()->GetIdAt(0u)); |
| 548 EXPECT_EQ(extension_c()->id(), main_bar()->GetIdAt(1u)); | 547 EXPECT_EQ(extension_c()->id(), main_bar()->GetIdAt(1u)); |
| 549 EXPECT_EQ(extension_b()->id(), main_bar()->GetIdAt(2u)); | 548 EXPECT_EQ(extension_b()->id(), main_bar()->GetIdAt(2u)); |
| 550 VerifyVisibleCount(3u); | 549 VerifyVisibleCount(3u); |
| 551 } | 550 } |
| OLD | NEW |