diff options
author | Ben Murdoch <benm@google.com> | 2010-07-29 17:14:53 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2010-08-04 14:29:45 +0100 |
commit | c407dc5cd9bdc5668497f21b26b09d988ab439de (patch) | |
tree | 7eaf8707c0309516bdb042ad976feedaf72b0bb1 /chrome/browser/extensions/browser_action_test_util_views.cc | |
parent | 0998b1cdac5733f299c12d88bc31ef9c8035b8fa (diff) | |
download | external_chromium-c407dc5cd9bdc5668497f21b26b09d988ab439de.zip external_chromium-c407dc5cd9bdc5668497f21b26b09d988ab439de.tar.gz external_chromium-c407dc5cd9bdc5668497f21b26b09d988ab439de.tar.bz2 |
Merge Chromium src@r53293
Change-Id: Ia79acf8670f385cee48c45b0a75371d8e950af34
Diffstat (limited to 'chrome/browser/extensions/browser_action_test_util_views.cc')
-rw-r--r-- | chrome/browser/extensions/browser_action_test_util_views.cc | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/chrome/browser/extensions/browser_action_test_util_views.cc b/chrome/browser/extensions/browser_action_test_util_views.cc new file mode 100644 index 0000000..fad2f7d --- /dev/null +++ b/chrome/browser/extensions/browser_action_test_util_views.cc @@ -0,0 +1,89 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/browser/extensions/browser_action_test_util.h" + +#include "base/utf_string_conversions.h" +#include "chrome/browser/browser.h" +#include "chrome/browser/browser_window.h" +#include "chrome/browser/views/browser_actions_container.h" +#include "chrome/browser/views/extensions/extension_popup.h" +#include "chrome/browser/views/toolbar_view.h" +#include "chrome/test/in_process_browser_test.h" +#include "chrome/test/ui_test_utils.h" +#include "gfx/rect.h" +#include "gfx/size.h" + +namespace { + +BrowserActionsContainer* GetContainer(Browser* browser) { + BrowserActionsContainer* container = + browser->window()->GetBrowserWindowTesting()->GetToolbarView()-> + browser_actions(); + return container; +} + +} // namespace + +int BrowserActionTestUtil::NumberOfBrowserActions() { + return GetContainer(browser_)->num_browser_actions(); +} + +int BrowserActionTestUtil::VisibleBrowserActions() { + return GetContainer(browser_)->VisibleBrowserActions(); +} + +void BrowserActionTestUtil::WaitForBrowserActionUpdated(int index) { + ui_test_utils::WaitForBrowserActionUpdated( + GetContainer(browser_)->GetBrowserActionViewAt(index)-> + button()->extension()->browser_action()); +} + +bool BrowserActionTestUtil::HasIcon(int index) { + return !GetContainer(browser_)->GetBrowserActionViewAt(index)-> + button()->icon().empty(); +} + +void BrowserActionTestUtil::Press(int index) { + GetContainer(browser_)->TestExecuteBrowserAction(index); +} + +std::string BrowserActionTestUtil::GetExtensionId(int index) { + BrowserActionButton* button = + GetContainer(browser_)->GetBrowserActionViewAt(index)->button(); + return button->extension()->id(); +} + +std::string BrowserActionTestUtil::GetTooltip(int index) { + std::wstring text; + GetContainer(browser_)->GetBrowserActionViewAt(index)->button()-> + GetTooltipText(gfx::Point(), &text); + return WideToUTF8(text); +} + +bool BrowserActionTestUtil::HasPopup() { + return GetContainer(browser_)->TestGetPopup() != NULL; +} + +gfx::Rect BrowserActionTestUtil::GetPopupBounds() { + return GetContainer(browser_)->TestGetPopup()->view()->bounds(); +} + +bool BrowserActionTestUtil::HidePopup() { + BrowserActionsContainer* container = GetContainer(browser_); + container->HidePopup(); + return !HasPopup(); +} + +void BrowserActionTestUtil::SetIconVisibilityCount(size_t icons) { + GetContainer(browser_)->TestSetIconVisibilityCount(icons); +} + +gfx::Size BrowserActionTestUtil::GetMinPopupSize() { + return gfx::Size(ExtensionPopup::kMinWidth, ExtensionPopup::kMinHeight); +} + +gfx::Size BrowserActionTestUtil::GetMaxPopupSize() { + return gfx::Size(ExtensionPopup::kMaxWidth, ExtensionPopup::kMaxHeight); +} |