Index: chrome/browser/ui/views/toolbar/browser_action_test_util_views.cc |
diff --git a/chrome/browser/ui/views/toolbar/browser_action_test_util_views.cc b/chrome/browser/ui/views/toolbar/browser_action_test_util_views.cc |
index 2540c7c50225dc47042e21fd2687311196558f6f..c737d0bdbb6d6056c8e0183d03b676156fb2932f 100644 |
--- a/chrome/browser/ui/views/toolbar/browser_action_test_util_views.cc |
+++ b/chrome/browser/ui/views/toolbar/browser_action_test_util_views.cc |
@@ -22,6 +22,28 @@ |
namespace { |
+// The BrowserActionsContainer expects to have a parent (and be added to the |
+// view hierarchy), so wrap it in a shell view that will set the container's |
+// bounds to be its preferred bounds. |
+class ContainerParent : public views::View { |
+ public: |
+ explicit ContainerParent(BrowserActionsContainer* container) |
+ : container_(container) { |
+ AddChildView(container_); |
+ } |
+ ~ContainerParent() override {} |
+ |
+ void Layout() override { |
+ gfx::Size s = container_->GetPreferredSize(); |
+ container_->SetBounds(0, 0, s.width(), s.height()); |
Peter Kasting
2015/09/15 00:13:38
container_->SizeToPreferredSize();
Devlin
2015/09/15 18:22:39
ah, useful. Done.
|
+ } |
+ |
+ private: |
+ BrowserActionsContainer* container_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(ContainerParent); |
+}; |
+ |
// The views-specific implementation of the TestToolbarActionsBarHelper, which |
// creates and owns a BrowserActionsContainer. |
class TestToolbarActionsBarHelperViews : public TestToolbarActionsBarHelper { |
@@ -35,13 +57,13 @@ class TestToolbarActionsBarHelperViews : public TestToolbarActionsBarHelper { |
} |
private: |
- // The parent of the BrowserActionsContainer, which directly owns the |
- // container as part of the views hierarchy. |
- views::View container_parent_; |
- |
// The created BrowserActionsContainer. Owned by |container_parent_|. |
BrowserActionsContainer* browser_actions_container_; |
+ // The parent of the BrowserActionsContainer, which directly owns the |
+ // container as part of the views hierarchy. |
+ ContainerParent container_parent_; |
+ |
DISALLOW_COPY_AND_ASSIGN(TestToolbarActionsBarHelperViews); |
}; |
@@ -49,11 +71,12 @@ TestToolbarActionsBarHelperViews::TestToolbarActionsBarHelperViews( |
Browser* browser, |
BrowserActionsContainer* main_bar) |
: browser_actions_container_( |
- new BrowserActionsContainer(browser, main_bar)) { |
- // The BrowserActionsContainer expects to have a parent (and be added to the |
- // view hierarchy), so wrap it in a shell view. |
+ new BrowserActionsContainer(browser, main_bar)), |
+ container_parent_(browser_actions_container_) { |
container_parent_.set_owned_by_client(); |
- container_parent_.AddChildView(browser_actions_container_); |
+ // Give the container plenty of room to play. |
+ container_parent_.SetSize(gfx::Size(1000, 1000)); |
+ container_parent_.Layout(); |
} |
TestToolbarActionsBarHelperViews::~TestToolbarActionsBarHelperViews() { |
@@ -174,6 +197,12 @@ bool BrowserActionTestUtil::ActionButtonWantsToRun(size_t index) { |
->wants_to_run_for_testing(); |
} |
+void BrowserActionTestUtil::SetWidth(int width) { |
+ BrowserActionsContainer* container = |
+ GetContainer(browser_, test_helper_.get()); |
+ container->SetSize(gfx::Size(width, container->size().height())); |
Peter Kasting
2015/09/15 00:13:38
container->SetSize(gfx::Size(width, container->hei
Devlin
2015/09/15 18:22:39
d'oh. Done.
|
+} |
+ |
ToolbarActionsBar* BrowserActionTestUtil::GetToolbarActionsBar() { |
return GetContainer(browser_, test_helper_.get())->toolbar_actions_bar(); |
} |