| 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/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 return GetContainer(browser_)->VisibleBrowserActions(); | 34 return GetContainer(browser_)->VisibleBrowserActions(); |
| 35 } | 35 } |
| 36 | 36 |
| 37 ExtensionAction* BrowserActionTestUtil::GetExtensionAction(int index) { | 37 ExtensionAction* BrowserActionTestUtil::GetExtensionAction(int index) { |
| 38 return extensions::ExtensionActionManager::Get(browser_->profile())-> | 38 return extensions::ExtensionActionManager::Get(browser_->profile())-> |
| 39 GetBrowserAction(*GetContainer(browser_)->GetBrowserActionViewAt(index)-> | 39 GetBrowserAction(*GetContainer(browser_)->GetBrowserActionViewAt(index)-> |
| 40 button()->extension()); | 40 button()->extension()); |
| 41 } | 41 } |
| 42 | 42 |
| 43 void BrowserActionTestUtil::InspectPopup(int index) { | 43 void BrowserActionTestUtil::InspectPopup(int index) { |
| 44 GetContainer(browser_)->InspectPopup(GetExtensionAction(index)); | 44 BrowserActionButton* button = |
| 45 GetContainer(browser_)->GetBrowserActionViewAt(index)->button(); |
| 46 button->InspectPopup(button->browser_action()); |
| 45 } | 47 } |
| 46 | 48 |
| 47 bool BrowserActionTestUtil::HasIcon(int index) { | 49 bool BrowserActionTestUtil::HasIcon(int index) { |
| 48 return !GetContainer(browser_)->GetBrowserActionViewAt(index)->button()-> | 50 return !GetContainer(browser_)->GetBrowserActionViewAt(index)->button()-> |
| 49 GetImage(views::Button::STATE_NORMAL).isNull(); | 51 GetImage(views::Button::STATE_NORMAL).isNull(); |
| 50 } | 52 } |
| 51 | 53 |
| 52 gfx::Image BrowserActionTestUtil::GetIcon(int index) { | 54 gfx::Image BrowserActionTestUtil::GetIcon(int index) { |
| 53 gfx::ImageSkia icon = GetContainer(browser_)->GetBrowserActionViewAt(index)-> | 55 gfx::ImageSkia icon = GetContainer(browser_)->GetBrowserActionViewAt(index)-> |
| 54 button()->GetIconForTest(); | 56 button()->GetIconForTest(); |
| 55 return gfx::Image(icon); | 57 return gfx::Image(icon); |
| 56 } | 58 } |
| 57 | 59 |
| 58 void BrowserActionTestUtil::Press(int index) { | 60 void BrowserActionTestUtil::Press(int index) { |
| 59 GetContainer(browser_)->TestExecuteBrowserAction(index); | 61 GetContainer(browser_)->GetBrowserActionViewAt(index)-> |
| 62 button()->ExecuteBrowserAction(); |
| 60 } | 63 } |
| 61 | 64 |
| 62 std::string BrowserActionTestUtil::GetExtensionId(int index) { | 65 std::string BrowserActionTestUtil::GetExtensionId(int index) { |
| 63 BrowserActionButton* button = | 66 BrowserActionButton* button = |
| 64 GetContainer(browser_)->GetBrowserActionViewAt(index)->button(); | 67 GetContainer(browser_)->GetBrowserActionViewAt(index)->button(); |
| 65 return button->extension()->id(); | 68 return button->extension()->id(); |
| 66 } | 69 } |
| 67 | 70 |
| 68 std::string BrowserActionTestUtil::GetTooltip(int index) { | 71 std::string BrowserActionTestUtil::GetTooltip(int index) { |
| 69 base::string16 text; | 72 base::string16 text; |
| 70 GetContainer(browser_)->GetBrowserActionViewAt(index)->button()-> | 73 GetContainer(browser_)->GetBrowserActionViewAt(index)->button()-> |
| 71 GetTooltipText(gfx::Point(), &text); | 74 GetTooltipText(gfx::Point(), &text); |
| 72 return base::UTF16ToUTF8(text); | 75 return base::UTF16ToUTF8(text); |
| 73 } | 76 } |
| 74 | 77 |
| 75 gfx::NativeView BrowserActionTestUtil::GetPopupNativeView() { | 78 gfx::NativeView BrowserActionTestUtil::GetPopupNativeView() { |
| 76 return GetContainer(browser_)->TestGetPopup()->GetWidget()->GetNativeView(); | 79 return GetContainer(browser_)->TestGetPopup()->GetWidget()->GetNativeView(); |
| 77 } | 80 } |
| 78 | 81 |
| 79 bool BrowserActionTestUtil::HasPopup() { | 82 bool BrowserActionTestUtil::HasPopup() { |
| 80 return GetContainer(browser_)->TestGetPopup() != NULL; | 83 return GetContainer(browser_)->TestGetPopup() != NULL; |
| 81 } | 84 } |
| 82 | 85 |
| 83 gfx::Rect BrowserActionTestUtil::GetPopupBounds() { | 86 gfx::Rect BrowserActionTestUtil::GetPopupBounds() { |
| 84 return GetContainer(browser_)->TestGetPopup()->bounds(); | 87 return GetContainer(browser_)->TestGetPopup()->bounds(); |
| 85 } | 88 } |
| 86 | 89 |
| 87 bool BrowserActionTestUtil::HidePopup() { | 90 bool BrowserActionTestUtil::HidePopup() { |
| 88 GetContainer(browser_)->HidePopup(); | 91 GetContainer(browser_)->HideActivePopup(); |
| 89 return !HasPopup(); | 92 return !HasPopup(); |
| 90 } | 93 } |
| 91 | 94 |
| 92 void BrowserActionTestUtil::SetIconVisibilityCount(size_t icons) { | 95 void BrowserActionTestUtil::SetIconVisibilityCount(size_t icons) { |
| 93 GetContainer(browser_)->TestSetIconVisibilityCount(icons); | 96 GetContainer(browser_)->TestSetIconVisibilityCount(icons); |
| 94 } | 97 } |
| 95 | 98 |
| 96 gfx::Size BrowserActionTestUtil::GetMinPopupSize() { | 99 gfx::Size BrowserActionTestUtil::GetMinPopupSize() { |
| 97 return gfx::Size(ExtensionPopup::kMinWidth, ExtensionPopup::kMinHeight); | 100 return gfx::Size(ExtensionPopup::kMinWidth, ExtensionPopup::kMinHeight); |
| 98 } | 101 } |
| 99 | 102 |
| 100 gfx::Size BrowserActionTestUtil::GetMaxPopupSize() { | 103 gfx::Size BrowserActionTestUtil::GetMaxPopupSize() { |
| 101 return gfx::Size(ExtensionPopup::kMaxWidth, ExtensionPopup::kMaxHeight); | 104 return gfx::Size(ExtensionPopup::kMaxWidth, ExtensionPopup::kMaxHeight); |
| 102 } | 105 } |
| OLD | NEW |