| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
| 10 #include "chrome/browser/ui/views/browser_action_view.h" | 10 #include "chrome/browser/ui/views/browser_action_view.h" |
| 11 #include "chrome/browser/ui/views/browser_actions_container.h" | 11 #include "chrome/browser/ui/views/browser_actions_container.h" |
| 12 #include "chrome/browser/ui/views/extensions/extension_popup.h" | 12 #include "chrome/browser/ui/views/extensions/extension_popup.h" |
| 13 #include "chrome/browser/ui/views/toolbar_view.h" | 13 #include "chrome/browser/ui/views/toolbar_view.h" |
| 14 #include "ui/gfx/image/image.h" |
| 14 #include "ui/gfx/rect.h" | 15 #include "ui/gfx/rect.h" |
| 15 #include "ui/gfx/size.h" | 16 #include "ui/gfx/size.h" |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 BrowserActionsContainer* GetContainer(Browser* browser) { | 20 BrowserActionsContainer* GetContainer(Browser* browser) { |
| 20 BrowserActionsContainer* container = | 21 BrowserActionsContainer* container = |
| 21 browser->window()->GetBrowserWindowTesting()->GetToolbarView()-> | 22 browser->window()->GetBrowserWindowTesting()->GetToolbarView()-> |
| 22 browser_actions(); | 23 browser_actions(); |
| 23 return container; | 24 return container; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 36 ExtensionAction* BrowserActionTestUtil::GetExtensionAction(int index) { | 37 ExtensionAction* BrowserActionTestUtil::GetExtensionAction(int index) { |
| 37 return GetContainer(browser_)->GetBrowserActionViewAt(index)-> | 38 return GetContainer(browser_)->GetBrowserActionViewAt(index)-> |
| 38 button()->extension()->browser_action(); | 39 button()->extension()->browser_action(); |
| 39 } | 40 } |
| 40 | 41 |
| 41 bool BrowserActionTestUtil::HasIcon(int index) { | 42 bool BrowserActionTestUtil::HasIcon(int index) { |
| 42 return GetContainer(browser_)->GetBrowserActionViewAt(index)->button()-> | 43 return GetContainer(browser_)->GetBrowserActionViewAt(index)->button()-> |
| 43 HasIcon(); | 44 HasIcon(); |
| 44 } | 45 } |
| 45 | 46 |
| 47 gfx::Image BrowserActionTestUtil::GetIcon(int index) { |
| 48 gfx::ImageSkia icon = GetContainer(browser_)->GetBrowserActionViewAt(index)-> |
| 49 button()->GetIconForTest(); |
| 50 return gfx::Image(icon); |
| 51 } |
| 52 |
| 46 void BrowserActionTestUtil::Press(int index) { | 53 void BrowserActionTestUtil::Press(int index) { |
| 47 GetContainer(browser_)->TestExecuteBrowserAction(index); | 54 GetContainer(browser_)->TestExecuteBrowserAction(index); |
| 48 } | 55 } |
| 49 | 56 |
| 50 std::string BrowserActionTestUtil::GetExtensionId(int index) { | 57 std::string BrowserActionTestUtil::GetExtensionId(int index) { |
| 51 BrowserActionButton* button = | 58 BrowserActionButton* button = |
| 52 GetContainer(browser_)->GetBrowserActionViewAt(index)->button(); | 59 GetContainer(browser_)->GetBrowserActionViewAt(index)->button(); |
| 53 return button->extension()->id(); | 60 return button->extension()->id(); |
| 54 } | 61 } |
| 55 | 62 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 78 GetContainer(browser_)->TestSetIconVisibilityCount(icons); | 85 GetContainer(browser_)->TestSetIconVisibilityCount(icons); |
| 79 } | 86 } |
| 80 | 87 |
| 81 gfx::Size BrowserActionTestUtil::GetMinPopupSize() { | 88 gfx::Size BrowserActionTestUtil::GetMinPopupSize() { |
| 82 return gfx::Size(ExtensionPopup::kMinWidth, ExtensionPopup::kMinHeight); | 89 return gfx::Size(ExtensionPopup::kMinWidth, ExtensionPopup::kMinHeight); |
| 83 } | 90 } |
| 84 | 91 |
| 85 gfx::Size BrowserActionTestUtil::GetMaxPopupSize() { | 92 gfx::Size BrowserActionTestUtil::GetMaxPopupSize() { |
| 86 return gfx::Size(ExtensionPopup::kMaxWidth, ExtensionPopup::kMaxHeight); | 93 return gfx::Size(ExtensionPopup::kMaxWidth, ExtensionPopup::kMaxHeight); |
| 87 } | 94 } |
| OLD | NEW |