OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/extensions/extension_message_bubble_browsertest.h" |
| 6 #include "chrome/browser/ui/views/frame/browser_view.h" |
| 7 #include "chrome/browser/ui/views/toolbar/app_menu_button.h" |
| 8 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" |
| 9 #include "chrome/browser/ui/views/toolbar/toolbar_actions_bar_bubble_views.h" |
| 10 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 11 #include "ui/views/bubble/bubble_dialog_delegate.h" |
| 12 |
| 13 namespace { |
| 14 |
| 15 // Returns the ToolbarView for the given |browser|. |
| 16 ToolbarView* GetToolbarViewForBrowser(Browser* browser) { |
| 17 return BrowserView::GetBrowserViewForBrowser(browser)->toolbar(); |
| 18 } |
| 19 |
| 20 } // namespace |
| 21 |
| 22 // static |
| 23 ToolbarActionsBarBubbleViews* |
| 24 ExtensionMessageBubbleBrowserTest::GetViewsBubbleForBrowser(Browser* browser) { |
| 25 return static_cast<ToolbarActionsBarBubbleViews*>( |
| 26 GetToolbarViewForBrowser(browser)->browser_actions()->active_bubble()); |
| 27 } |
| 28 |
| 29 // static |
| 30 gfx::Rect ExtensionMessageBubbleBrowserTest::GetAnchorReferenceBoundsForBrowser( |
| 31 Browser* browser, |
| 32 AnchorPosition anchor) { |
| 33 ToolbarView* toolbar_view = GetToolbarViewForBrowser(browser); |
| 34 BrowserActionsContainer* container = toolbar_view->browser_actions(); |
| 35 views::View* anchor_view = nullptr; |
| 36 switch (anchor) { |
| 37 case ExtensionMessageBubbleBrowserTest::ANCHOR_BROWSER_ACTION: |
| 38 EXPECT_GT(container->num_toolbar_actions(), 0u); |
| 39 if (container->num_toolbar_actions() == 0) |
| 40 return gfx::Rect(); |
| 41 anchor_view = container->GetToolbarActionViewAt(0); |
| 42 break; |
| 43 case ExtensionMessageBubbleBrowserTest::ANCHOR_APP_MENU: |
| 44 anchor_view = toolbar_view->app_menu_button(); |
| 45 break; |
| 46 } |
| 47 |
| 48 EXPECT_TRUE(anchor_view); |
| 49 EXPECT_EQ(anchor_view, container->active_bubble()->GetAnchorView()); |
| 50 return anchor_view->GetBoundsInScreen(); |
| 51 } |
OLD | NEW |