summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/browser_action_test_util_gtk.cc
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2010-07-29 17:14:53 +0100
committerBen Murdoch <benm@google.com>2010-08-04 14:29:45 +0100
commitc407dc5cd9bdc5668497f21b26b09d988ab439de (patch)
tree7eaf8707c0309516bdb042ad976feedaf72b0bb1 /chrome/browser/extensions/browser_action_test_util_gtk.cc
parent0998b1cdac5733f299c12d88bc31ef9c8035b8fa (diff)
downloadexternal_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_gtk.cc')
-rw-r--r--chrome/browser/extensions/browser_action_test_util_gtk.cc90
1 files changed, 90 insertions, 0 deletions
diff --git a/chrome/browser/extensions/browser_action_test_util_gtk.cc b/chrome/browser/extensions/browser_action_test_util_gtk.cc
new file mode 100644
index 0000000..7761946
--- /dev/null
+++ b/chrome/browser/extensions/browser_action_test_util_gtk.cc
@@ -0,0 +1,90 @@
+// Copyright (c) 2009 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 <gtk/gtk.h>
+
+#include "chrome/browser/browser.h"
+#include "chrome/browser/browser_window.h"
+#include "chrome/browser/gtk/extension_popup_gtk.h"
+#include "chrome/browser/gtk/extension_view_gtk.h"
+#include "chrome/browser/gtk/view_id_util.h"
+
+namespace {
+
+GtkWidget* GetButton(Browser* browser, int index) {
+ GtkWidget* button = NULL;
+ GtkWidget* toolbar =
+ ViewIDUtil::GetWidget(GTK_WIDGET(browser->window()->GetNativeHandle()),
+ VIEW_ID_BROWSER_ACTION_TOOLBAR);
+ if (toolbar) {
+ GList* children = gtk_container_get_children(GTK_CONTAINER(toolbar));
+ button = static_cast<GtkWidget*>(g_list_nth(children, index)->data);
+ g_list_free(children);
+ }
+ return button;
+}
+
+} // namespace
+
+int BrowserActionTestUtil::NumberOfBrowserActions() {
+ int count = -1;
+ GtkWidget* toolbar =
+ ViewIDUtil::GetWidget(GTK_WIDGET(browser_->window()->GetNativeHandle()),
+ VIEW_ID_BROWSER_ACTION_TOOLBAR);
+ if (toolbar) {
+ GList* children = gtk_container_get_children(GTK_CONTAINER(toolbar));
+ count = g_list_length(children);
+ g_list_free(children);
+ }
+ return count;
+}
+
+bool BrowserActionTestUtil::HasIcon(int index) {
+ GtkWidget* button = GetButton(browser_, index);
+ return gtk_button_get_image(GTK_BUTTON(button)) != NULL;
+}
+
+void BrowserActionTestUtil::Press(int index) {
+ GtkWidget* button = GetButton(browser_, index);
+ gtk_button_clicked(GTK_BUTTON(button));
+}
+
+std::string BrowserActionTestUtil::GetTooltip(int index) {
+ GtkWidget* button = GetButton(browser_, index);
+ gchar* text = gtk_widget_get_tooltip_text(button);
+ std::string tooltip(text);
+ g_free(text);
+ return tooltip;
+}
+
+bool BrowserActionTestUtil::HasPopup() {
+ return ExtensionPopupGtk::get_current_extension_popup() != NULL;
+}
+
+gfx::Rect BrowserActionTestUtil::GetPopupBounds() {
+ ExtensionPopupGtk* popup = ExtensionPopupGtk::get_current_extension_popup();
+ if (popup)
+ return popup->GetViewBounds();
+ return gfx::Rect();
+}
+
+bool BrowserActionTestUtil::HidePopup() {
+ ExtensionPopupGtk* popup = ExtensionPopupGtk::get_current_extension_popup();
+ if (popup)
+ return popup->DestroyPopup();
+ return false;
+}
+
+// static
+gfx::Size BrowserActionTestUtil::GetMinPopupSize() {
+ // On Linux we actually just limit the size of the extension view.
+ return gfx::Size(ExtensionPopupGtk::kMinWidth, ExtensionPopupGtk::kMinHeight);
+}
+
+// static
+gfx::Size BrowserActionTestUtil::GetMaxPopupSize() {
+ return gfx::Size(ExtensionPopupGtk::kMaxWidth, ExtensionPopupGtk::kMaxHeight);
+}