diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-17 21:23:35 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-17 21:23:35 +0000 |
commit | 67f7191aa0be7791da0c4d9f913b2a90c4eb4dae (patch) | |
tree | daaaf89c0c8f3e8473674282acde2f6e05c14f89 /chrome | |
parent | 76ac017bca97c5e45569c43c4aded1e287e2cb0b (diff) | |
download | chromium_src-67f7191aa0be7791da0c4d9f913b2a90c4eb4dae.zip chromium_src-67f7191aa0be7791da0c4d9f913b2a90c4eb4dae.tar.gz chromium_src-67f7191aa0be7791da0c4d9f913b2a90c4eb4dae.tar.bz2 |
Port PageActionPopupTest to Linux by filling in missing functionality in locationbarviewgtk.
BUG=30326
TEST=test passes
Review URL: http://codereview.chromium.org/507032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34876 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/extensions/page_action_apitest.cc | 9 | ||||
-rw-r--r-- | chrome/browser/gtk/location_bar_view_gtk.cc | 43 | ||||
-rw-r--r-- | chrome/browser/gtk/location_bar_view_gtk.h | 7 |
3 files changed, 48 insertions, 11 deletions
diff --git a/chrome/browser/extensions/page_action_apitest.cc b/chrome/browser/extensions/page_action_apitest.cc index d7c385d..b545558 100644 --- a/chrome/browser/extensions/page_action_apitest.cc +++ b/chrome/browser/extensions/page_action_apitest.cc @@ -133,10 +133,9 @@ public: bool last_visibility_; }; -#if !defined(OS_WIN) -// The following test fails on Mac and Linux because some of page action -// implementation is missing in LocationBarView -// (see http://crbug.com/29898, http://crbug.com/30326) +#if defined(OS_MACOSX) +// The following test fails on Mac because some of page action implementation is +// missing in LocationBarView (see http://crbug.com/29898). #define MAYBE_Show DISABLED_Show #else #define MAYBE_Show Show @@ -166,7 +165,7 @@ IN_PROC_BROWSER_TEST_F(PageActionPopupTest, MAYBE_Show) { browser()->window()->GetLocationBar()->GetLocationBarForTesting(); ASSERT_EQ(1, location_bar->PageActionVisibleCount()); ExtensionAction* action = location_bar->GetVisiblePageAction(0); - ASSERT_TRUE(action == last_action_); + EXPECT_EQ(action, last_action_); { ResultCatcher catcher; diff --git a/chrome/browser/gtk/location_bar_view_gtk.cc b/chrome/browser/gtk/location_bar_view_gtk.cc index 5596267..c3468b8 100644 --- a/chrome/browser/gtk/location_bar_view_gtk.cc +++ b/chrome/browser/gtk/location_bar_view_gtk.cc @@ -469,17 +469,34 @@ int LocationBarViewGtk::PageActionVisibleCount() { } ExtensionAction* LocationBarViewGtk::GetPageAction(size_t index) { - NOTIMPLEMENTED(); - return NULL; + if (index >= page_action_views_.size()) { + NOTREACHED(); + return NULL; + } + + return page_action_views_[index]->page_action(); } ExtensionAction* LocationBarViewGtk::GetVisiblePageAction(size_t index) { - NOTIMPLEMENTED(); + size_t visible_index = 0; + for (size_t i = 0; i < page_action_views_.size(); ++i) { + if (page_action_views_[i]->IsVisible()) { + if (index == visible_index++) + return page_action_views_[i]->page_action(); + } + } + + NOTREACHED(); return NULL; } void LocationBarViewGtk::TestPageActionPressed(size_t index) { - NOTIMPLEMENTED(); + if (index >= page_action_views_.size()) { + NOTREACHED(); + return; + } + + page_action_views_[index]->TestActivatePageAction(); } void LocationBarViewGtk::Observe(NotificationType type, @@ -796,10 +813,18 @@ void LocationBarViewGtk::PageActionViewGtk::UpdateVisibility( visible = false; } - if (visible) { + + bool old_visible = IsVisible(); + if (visible) gtk_widget_show_all(event_box_.get()); - } else { + else gtk_widget_hide_all(event_box_.get()); + + if (visible != old_visible) { + NotificationService::current()->Notify( + NotificationType::EXTENSION_PAGE_ACTION_VISIBILITY_CHANGED, + Source<ExtensionAction>(page_action_), + Details<TabContents>(contents)); } } @@ -829,6 +854,12 @@ void LocationBarViewGtk::PageActionViewGtk::OnImageLoaded(SkBitmap* image, owner_->UpdatePageActions(); } +void LocationBarViewGtk::PageActionViewGtk::TestActivatePageAction() { + GdkEventButton event; + event.button = 1; + OnButtonPressed(widget(), &event, this); +} + // static gboolean LocationBarViewGtk::PageActionViewGtk::OnButtonPressed( GtkWidget* sender, diff --git a/chrome/browser/gtk/location_bar_view_gtk.h b/chrome/browser/gtk/location_bar_view_gtk.h index 951d725..7f40709 100644 --- a/chrome/browser/gtk/location_bar_view_gtk.h +++ b/chrome/browser/gtk/location_bar_view_gtk.h @@ -114,6 +114,10 @@ class LocationBarViewGtk : public AutocompleteEditController, GtkWidget* widget() { return event_box_.get(); } + ExtensionAction* page_action() { return page_action_; } + + bool IsVisible() { return GTK_WIDGET_VISIBLE(widget()); } + // Called to notify the PageAction that it should determine whether to be // visible or hidden. |contents| is the TabContents that is active, |url| // is the current page URL. @@ -122,6 +126,9 @@ class LocationBarViewGtk : public AutocompleteEditController, // A callback from ImageLoadingTracker for when the image has loaded. virtual void OnImageLoaded(SkBitmap* image, size_t index); + // Simulate left mouse click on the page action button. + void TestActivatePageAction(); + private: static gboolean OnButtonPressed(GtkWidget* sender, GdkEventButton* event, PageActionViewGtk* page_action_view); |