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