| 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/extensions/browser_action_test_util.h" | 5 #include "chrome/browser/extensions/browser_action_test_util.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/extension_action_manager.h" | 8 #include "chrome/browser/extensions/extension_action_manager.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.h" | 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
| 12 #include "chrome/browser/ui/browser_window_testing_views.h" | 12 #include "chrome/browser/ui/browser_window_testing_views.h" |
| 13 #include "chrome/browser/ui/views/extensions/extension_action_view_controller.h" | 13 #include "chrome/browser/ui/views/extensions/extension_action_view_controller.h" |
| 14 #include "chrome/browser/ui/views/extensions/extension_popup.h" | 14 #include "chrome/browser/ui/views/extensions/extension_popup.h" |
| 15 #include "chrome/browser/ui/views/toolbar/browser_action_view.h" | |
| 16 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" | 15 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h" |
| 16 #include "chrome/browser/ui/views/toolbar/toolbar_action_view.h" |
| 17 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" | 17 #include "chrome/browser/ui/views/toolbar/toolbar_view.h" |
| 18 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
| 19 #include "ui/gfx/image/image.h" | 19 #include "ui/gfx/image/image.h" |
| 20 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
| 21 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
| 22 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 BrowserActionsContainer* GetContainer(Browser* browser) { | 26 BrowserActionsContainer* GetContainer(Browser* browser) { |
| 27 return browser->window()->GetBrowserWindowTesting()->GetToolbarView()-> | 27 return browser->window()->GetBrowserWindowTesting()->GetToolbarView()-> |
| 28 browser_actions(); | 28 browser_actions(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 } // namespace | 31 } // namespace |
| 32 | 32 |
| 33 int BrowserActionTestUtil::NumberOfBrowserActions() { | 33 int BrowserActionTestUtil::NumberOfBrowserActions() { |
| 34 return GetContainer(browser_)->num_browser_actions(); | 34 return GetContainer(browser_)->num_toolbar_actions(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 int BrowserActionTestUtil::VisibleBrowserActions() { | 37 int BrowserActionTestUtil::VisibleBrowserActions() { |
| 38 return GetContainer(browser_)->VisibleBrowserActions(); | 38 return GetContainer(browser_)->VisibleBrowserActions(); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void BrowserActionTestUtil::InspectPopup(int index) { | 41 void BrowserActionTestUtil::InspectPopup(int index) { |
| 42 BrowserActionView* view = | 42 ToolbarActionView* view = |
| 43 GetContainer(browser_)->GetBrowserActionViewAt(index); | 43 GetContainer(browser_)->GetToolbarActionViewAt(index); |
| 44 static_cast<ExtensionActionViewController*>(view->view_controller())-> | 44 static_cast<ExtensionActionViewController*>(view->view_controller())-> |
| 45 InspectPopup(); | 45 InspectPopup(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 bool BrowserActionTestUtil::HasIcon(int index) { | 48 bool BrowserActionTestUtil::HasIcon(int index) { |
| 49 return !GetContainer(browser_)->GetBrowserActionViewAt(index)-> | 49 return !GetContainer(browser_)->GetToolbarActionViewAt(index)-> |
| 50 GetImage(views::Button::STATE_NORMAL).isNull(); | 50 GetImage(views::Button::STATE_NORMAL).isNull(); |
| 51 } | 51 } |
| 52 | 52 |
| 53 gfx::Image BrowserActionTestUtil::GetIcon(int index) { | 53 gfx::Image BrowserActionTestUtil::GetIcon(int index) { |
| 54 gfx::ImageSkia icon = GetContainer(browser_)->GetBrowserActionViewAt(index)-> | 54 gfx::ImageSkia icon = GetContainer(browser_)->GetToolbarActionViewAt(index)-> |
| 55 GetIconForTest(); | 55 GetIconForTest(); |
| 56 return gfx::Image(icon); | 56 return gfx::Image(icon); |
| 57 } | 57 } |
| 58 | 58 |
| 59 void BrowserActionTestUtil::Press(int index) { | 59 void BrowserActionTestUtil::Press(int index) { |
| 60 GetContainer(browser_)->GetBrowserActionViewAt(index)-> | 60 GetContainer(browser_)->GetToolbarActionViewAt(index)-> |
| 61 view_controller()->ExecuteAction(true); | 61 view_controller()->ExecuteAction(true); |
| 62 } | 62 } |
| 63 | 63 |
| 64 std::string BrowserActionTestUtil::GetExtensionId(int index) { | 64 std::string BrowserActionTestUtil::GetExtensionId(int index) { |
| 65 return GetContainer(browser_)->GetBrowserActionViewAt(index)-> | 65 return GetContainer(browser_)->GetToolbarActionViewAt(index)-> |
| 66 view_controller()->GetId(); | 66 view_controller()->GetId(); |
| 67 } | 67 } |
| 68 | 68 |
| 69 std::string BrowserActionTestUtil::GetTooltip(int index) { | 69 std::string BrowserActionTestUtil::GetTooltip(int index) { |
| 70 base::string16 text; | 70 base::string16 text; |
| 71 GetContainer(browser_)->GetBrowserActionViewAt(index)-> | 71 GetContainer(browser_)->GetToolbarActionViewAt(index)-> |
| 72 GetTooltipText(gfx::Point(), &text); | 72 GetTooltipText(gfx::Point(), &text); |
| 73 return base::UTF16ToUTF8(text); | 73 return base::UTF16ToUTF8(text); |
| 74 } | 74 } |
| 75 | 75 |
| 76 gfx::NativeView BrowserActionTestUtil::GetPopupNativeView() { | 76 gfx::NativeView BrowserActionTestUtil::GetPopupNativeView() { |
| 77 return GetContainer(browser_)->TestGetPopup(); | 77 return GetContainer(browser_)->TestGetPopup(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 bool BrowserActionTestUtil::HasPopup() { | 80 bool BrowserActionTestUtil::HasPopup() { |
| 81 return GetContainer(browser_)->TestGetPopup() != NULL; | 81 return GetContainer(browser_)->TestGetPopup() != NULL; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 109 | 109 |
| 110 // static | 110 // static |
| 111 gfx::Size BrowserActionTestUtil::GetMinPopupSize() { | 111 gfx::Size BrowserActionTestUtil::GetMinPopupSize() { |
| 112 return gfx::Size(ExtensionPopup::kMinWidth, ExtensionPopup::kMinHeight); | 112 return gfx::Size(ExtensionPopup::kMinWidth, ExtensionPopup::kMinHeight); |
| 113 } | 113 } |
| 114 | 114 |
| 115 // static | 115 // static |
| 116 gfx::Size BrowserActionTestUtil::GetMaxPopupSize() { | 116 gfx::Size BrowserActionTestUtil::GetMaxPopupSize() { |
| 117 return gfx::Size(ExtensionPopup::kMaxWidth, ExtensionPopup::kMaxHeight); | 117 return gfx::Size(ExtensionPopup::kMaxWidth, ExtensionPopup::kMaxHeight); |
| 118 } | 118 } |
| OLD | NEW |