| 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 | |
| 15 #ifdef UNIT_TEST | |
| 16 #include "chrome/test/base/in_process_browser_test.h" | |
| 17 #include "chrome/test/base/ui_test_utils.h" | |
| 18 #endif // UNIT_TEST | |
| 19 | |
| 20 #include "ui/gfx/rect.h" | 14 #include "ui/gfx/rect.h" |
| 21 #include "ui/gfx/size.h" | 15 #include "ui/gfx/size.h" |
| 22 | 16 |
| 23 namespace { | 17 namespace { |
| 24 | 18 |
| 25 BrowserActionsContainer* GetContainer(Browser* browser) { | 19 BrowserActionsContainer* GetContainer(Browser* browser) { |
| 26 BrowserActionsContainer* container = | 20 BrowserActionsContainer* container = |
| 27 browser->window()->GetBrowserWindowTesting()->GetToolbarView()-> | 21 browser->window()->GetBrowserWindowTesting()->GetToolbarView()-> |
| 28 browser_actions(); | 22 browser_actions(); |
| 29 return container; | 23 return container; |
| 30 } | 24 } |
| 31 | 25 |
| 32 } // namespace | 26 } // namespace |
| 33 | 27 |
| 34 int BrowserActionTestUtil::NumberOfBrowserActions() { | 28 int BrowserActionTestUtil::NumberOfBrowserActions() { |
| 35 return GetContainer(browser_)->num_browser_actions(); | 29 return GetContainer(browser_)->num_browser_actions(); |
| 36 } | 30 } |
| 37 | 31 |
| 38 int BrowserActionTestUtil::VisibleBrowserActions() { | 32 int BrowserActionTestUtil::VisibleBrowserActions() { |
| 39 return GetContainer(browser_)->VisibleBrowserActions(); | 33 return GetContainer(browser_)->VisibleBrowserActions(); |
| 40 } | 34 } |
| 41 | 35 |
| 42 #ifdef UNIT_TEST | 36 ExtensionAction* BrowserActionTestUtil::GetExtensionAction(int index) { |
| 43 void BrowserActionTestUtil::WaitForBrowserActionUpdated(int index) { | 37 return GetContainer(browser_)->GetBrowserActionViewAt(index)-> |
| 44 ui_test_utils::WaitForBrowserActionUpdated( | 38 button()->extension()->browser_action(); |
| 45 GetContainer(browser_)->GetBrowserActionViewAt(index)-> | |
| 46 button()->extension()->browser_action()); | |
| 47 } | 39 } |
| 48 #endif // UNIT_TEST | |
| 49 | 40 |
| 50 bool BrowserActionTestUtil::HasIcon(int index) { | 41 bool BrowserActionTestUtil::HasIcon(int index) { |
| 51 return GetContainer(browser_)->GetBrowserActionViewAt(index)->button()-> | 42 return GetContainer(browser_)->GetBrowserActionViewAt(index)->button()-> |
| 52 HasIcon(); | 43 HasIcon(); |
| 53 } | 44 } |
| 54 | 45 |
| 55 void BrowserActionTestUtil::Press(int index) { | 46 void BrowserActionTestUtil::Press(int index) { |
| 56 GetContainer(browser_)->TestExecuteBrowserAction(index); | 47 GetContainer(browser_)->TestExecuteBrowserAction(index); |
| 57 } | 48 } |
| 58 | 49 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 87 GetContainer(browser_)->TestSetIconVisibilityCount(icons); | 78 GetContainer(browser_)->TestSetIconVisibilityCount(icons); |
| 88 } | 79 } |
| 89 | 80 |
| 90 gfx::Size BrowserActionTestUtil::GetMinPopupSize() { | 81 gfx::Size BrowserActionTestUtil::GetMinPopupSize() { |
| 91 return gfx::Size(ExtensionPopup::kMinWidth, ExtensionPopup::kMinHeight); | 82 return gfx::Size(ExtensionPopup::kMinWidth, ExtensionPopup::kMinHeight); |
| 92 } | 83 } |
| 93 | 84 |
| 94 gfx::Size BrowserActionTestUtil::GetMaxPopupSize() { | 85 gfx::Size BrowserActionTestUtil::GetMaxPopupSize() { |
| 95 return gfx::Size(ExtensionPopup::kMaxWidth, ExtensionPopup::kMaxHeight); | 86 return gfx::Size(ExtensionPopup::kMaxWidth, ExtensionPopup::kMaxHeight); |
| 96 } | 87 } |
| OLD | NEW |