summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-16 22:50:23 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-16 22:50:23 +0000
commit0590ff113f399e23c2c72e0e4be9569c7596c2f6 (patch)
treeb67d01e5489e879f8a97947075e3a5404e1a9af3 /chrome/browser
parent4f7336749506dead4f348f37171eda7165b5abb3 (diff)
downloadchromium_src-0590ff113f399e23c2c72e0e4be9569c7596c2f6.zip
chromium_src-0590ff113f399e23c2c72e0e4be9569c7596c2f6.tar.gz
chromium_src-0590ff113f399e23c2c72e0e4be9569c7596c2f6.tar.bz2
Finish porting FindInPageControllerTest to linux.
BUG=37809,268629 TEST=test passes Review URL: http://codereview.chromium.org/997004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41782 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/find_bar_host_browsertest.cc62
-rw-r--r--chrome/browser/gtk/find_bar_gtk.cc21
-rw-r--r--chrome/browser/gtk/find_bar_gtk.h8
-rw-r--r--chrome/browser/gtk/slide_animator_gtk.cc16
-rw-r--r--chrome/browser/gtk/slide_animator_gtk.h5
5 files changed, 62 insertions, 50 deletions
diff --git a/chrome/browser/find_bar_host_browsertest.cc b/chrome/browser/find_bar_host_browsertest.cc
index 81f322c..508e5c8 100644
--- a/chrome/browser/find_bar_host_browsertest.cc
+++ b/chrome/browser/find_bar_host_browsertest.cc
@@ -18,14 +18,8 @@
#if defined(TOOLKIT_VIEWS)
#include "views/focus/focus_manager.h"
-#endif
-
-// http://crbug.com/37809
-#if defined(OS_LINUX) && defined(TOOLKIT_GTK)
-#define FindDisappearOnNavigate DISABLED_FindDisappearOnNavigate
-#define FindDisappearOnNewTabAndHistory \
- DISABLED_FindDisappearOnNewTabAndHistory
-#define FindMovesWhenObscuring DISABLED_FindMovesWhenObscuring
+#elif defined(TOOLKIT_GTK)
+#include "chrome/browser/gtk/slide_animator_gtk.h"
#endif
const std::wstring kSimplePage = L"404_is_enough_for_us.html";
@@ -55,6 +49,13 @@ class FindInPageControllerTest : public InProcessBrowserTest {
public:
FindInPageControllerTest() {
EnableDOMAutomation();
+
+#if defined(TOOLKIT_VIEWS)
+ DropdownBarHost::disable_animations_during_testing_ = true;
+#elif defined(TOOLKIT_GTK)
+ SlideAnimatorGtk::SetAnimationsForTesting(false);
+#endif
+
}
protected:
@@ -484,12 +485,6 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
EXPECT_EQ(1, ordinal);
}
-// Make sure Find box disappears on Navigate but not on Refresh.
-#if defined(OS_LINUX) && defined(TOOLKIT_VIEWS)
-// The last EXPECT_FALSE(fully_visible) is failing all the time on
-// the linux_views bot. See bug: http://crbug.com/28629.
-#define FindDisappearOnNavigate DISABLED_FindDisappearOnNavigate
-#endif
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindDisappearOnNavigate) {
HTTPTestServer* server = StartHTTPServer();
@@ -498,29 +493,25 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindDisappearOnNavigate) {
GURL url2 = server->TestServerPageW(kFramePage);
ui_test_utils::NavigateToURL(browser(), url);
-#if defined(TOOLKIT_VIEWS)
- // Open the Find window with animations disabled.
- DropdownBarHost::disable_animations_during_testing_ = true;
-#endif
browser()->ShowFindBar();
- gfx::Point position;
bool fully_visible = false;
// Make sure it is open.
- EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
+ EXPECT_TRUE(GetFindBarWindowInfo(NULL, &fully_visible));
EXPECT_TRUE(fully_visible);
// Reload the tab and make sure Find window doesn't go away.
browser()->Reload();
+ ui_test_utils::WaitForNavigationInCurrentTab(browser());
- EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
+ EXPECT_TRUE(GetFindBarWindowInfo(NULL, &fully_visible));
EXPECT_TRUE(fully_visible);
// Navigate and make sure the Find window goes away.
ui_test_utils::NavigateToURL(browser(), url2);
- EXPECT_TRUE(GetFindBarWindowInfo(&position, &fully_visible));
+ EXPECT_TRUE(GetFindBarWindowInfo(NULL, &fully_visible));
EXPECT_FALSE(fully_visible);
}
@@ -534,10 +525,6 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
GURL url = server->TestServerPageW(kSimplePage);
ui_test_utils::NavigateToURL(browser(), url);
-#if defined(TOOLKIT_VIEWS)
- // Open the Find window with animations disabled.
- DropdownBarHost::disable_animations_during_testing_ = true;
-#endif
browser()->ShowFindBar();
gfx::Point position;
@@ -576,12 +563,11 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, FindMovesWhenObscuring) {
GURL url = server->TestServerPageW(kMoveIfOver);
ui_test_utils::NavigateToURL(browser(), url);
-#if defined(TOOLKIT_VIEWS)
- // Open the Find window with animations disabled.
- DropdownBarHost::disable_animations_during_testing_ = true;
-#endif
browser()->ShowFindBar();
+ // This is needed on GTK because the reposition operation is asynchronous.
+ MessageLoop::current()->RunAllPending();
+
gfx::Point start_position;
gfx::Point position;
bool fully_visible = false;
@@ -700,10 +686,6 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest,
focus_manager->GetCurrentTargetForAccelerator(escape);
EXPECT_TRUE(old_target != NULL);
-#if defined(TOOLKIT_VIEWS)
- // Open the Find window with animations disabled.
- DropdownBarHost::disable_animations_during_testing_ = true;
-#endif
browser()->ShowFindBar();
// Our Find bar should be the new target.
@@ -732,10 +714,6 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, StayActive) {
GURL url = server->TestServerPageW(kSimplePage);
ui_test_utils::NavigateToURL(browser(), url);
-#if defined(TOOLKIT_VIEWS)
- // Open the Find window with animations disabled.
- DropdownBarHost::disable_animations_during_testing_ = true;
-#endif
browser()->ShowFindBar();
// Simulate a user clearing the search string. Ideally, we should be
@@ -790,10 +768,6 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, RestartSearchFromF3) {
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PreferPreviousSearch) {
HTTPTestServer* server = StartHTTPServer();
-#if defined(TOOLKIT_VIEWS)
- DropdownBarHost::disable_animations_during_testing_ = true;
-#endif
-
// First we navigate to any page.
GURL url = server->TestServerPageW(kSimplePage);
ui_test_utils::NavigateToURL(browser(), url);
@@ -826,10 +800,6 @@ IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, PreferPreviousSearch) {
IN_PROC_BROWSER_TEST_F(FindInPageControllerTest, ActivateLinkNavigatesPage) {
HTTPTestServer* server = StartHTTPServer();
-#if defined(TOOLKIT_VIEWS)
- DropdownBarHost::disable_animations_during_testing_ = true;
-#endif
-
// First we navigate to our test content.
GURL url = server->TestServerPageW(kLinkPage);
ui_test_utils::NavigateToURL(browser(), url);
diff --git a/chrome/browser/gtk/find_bar_gtk.cc b/chrome/browser/gtk/find_bar_gtk.cc
index f99eb6f..3f2f10c 100644
--- a/chrome/browser/gtk/find_bar_gtk.cc
+++ b/chrome/browser/gtk/find_bar_gtk.cc
@@ -519,7 +519,8 @@ void FindBarGtk::Observe(NotificationType type,
bool FindBarGtk::GetFindBarWindowInfo(gfx::Point* position,
bool* fully_visible) {
if (position)
- NOTIMPLEMENTED();
+ *position = GetPosition();
+
if (fully_visible) {
*fully_visible = !slide_widget_->IsAnimating() &&
slide_widget_->IsShowing();
@@ -648,6 +649,24 @@ void FindBarGtk::AdjustTextAlignment() {
}
}
+gfx::Point FindBarGtk::GetPosition() {
+ gfx::Point point;
+
+ GValue value = { 0, };
+ g_value_init(&value, G_TYPE_INT);
+ gtk_container_child_get_property(GTK_CONTAINER(widget()->parent),
+ widget(), "x", &value);
+ point.set_x(g_value_get_int(&value));
+
+ gtk_container_child_get_property(GTK_CONTAINER(widget()->parent),
+ widget(), "y", &value);
+ point.set_y(g_value_get_int(&value));
+
+ g_value_unset(&value);
+
+ return point;
+}
+
// static
void FindBarGtk::OnParentSet(GtkWidget* widget, GtkObject* old_parent,
FindBarGtk* find_bar) {
diff --git a/chrome/browser/gtk/find_bar_gtk.h b/chrome/browser/gtk/find_bar_gtk.h
index 9e66551..c36ca50 100644
--- a/chrome/browser/gtk/find_bar_gtk.h
+++ b/chrome/browser/gtk/find_bar_gtk.h
@@ -1,5 +1,5 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved. Use
-// of this source code is governed by a BSD-style license that can be
+// 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.
#ifndef CHROME_BROWSER_GTK_FIND_BAR_GTK_H_
@@ -15,6 +15,7 @@
#include "chrome/common/notification_observer.h"
#include "chrome/common/notification_registrar.h"
#include "chrome/common/owned_widget_gtk.h"
+#include "gfx/point.h"
class Browser;
class BrowserWindowGtk;
@@ -107,6 +108,9 @@ class FindBarGtk : public FindBar,
// always in sync with the UI language direction.
void AdjustTextAlignment();
+ // Get the position of the findbar within the floating container.
+ gfx::Point GetPosition();
+
static void OnParentSet(GtkWidget* widget, GtkObject* old_parent,
FindBarGtk* find_bar);
diff --git a/chrome/browser/gtk/slide_animator_gtk.cc b/chrome/browser/gtk/slide_animator_gtk.cc
index ba48e46..2c1549d 100644
--- a/chrome/browser/gtk/slide_animator_gtk.cc
+++ b/chrome/browser/gtk/slide_animator_gtk.cc
@@ -26,6 +26,8 @@ void OnChildSizeRequest(GtkWidget* expanded,
} // namespace
+bool SlideAnimatorGtk::animations_enabled_ = true;
+
SlideAnimatorGtk::SlideAnimatorGtk(GtkWidget* child,
Direction direction,
int duration,
@@ -68,17 +70,24 @@ SlideAnimatorGtk::~SlideAnimatorGtk() {
}
void SlideAnimatorGtk::Open() {
+ if (!animations_enabled_)
+ return OpenWithoutAnimation();
+
gtk_widget_show(widget_.get());
animation_->Show();
}
void SlideAnimatorGtk::OpenWithoutAnimation() {
+ gtk_widget_show(widget_.get());
animation_->Reset(1.0);
- Open();
+ animation_->Show();
AnimationProgressed(animation_.get());
}
void SlideAnimatorGtk::Close() {
+ if (!animations_enabled_)
+ return CloseWithoutAnimation();
+
animation_->Hide();
}
@@ -128,6 +137,11 @@ void SlideAnimatorGtk::AnimationEnded(const Animation* animation) {
}
// static
+void SlideAnimatorGtk::SetAnimationsForTesting(bool enable) {
+ animations_enabled_ = enable;
+}
+
+// static
void SlideAnimatorGtk::OnChildSizeAllocate(GtkWidget* child,
GtkAllocation* allocation,
SlideAnimatorGtk* slider) {
diff --git a/chrome/browser/gtk/slide_animator_gtk.h b/chrome/browser/gtk/slide_animator_gtk.h
index d41f130..799816c 100644
--- a/chrome/browser/gtk/slide_animator_gtk.h
+++ b/chrome/browser/gtk/slide_animator_gtk.h
@@ -85,6 +85,9 @@ class SlideAnimatorGtk : public AnimationDelegate {
void AnimationProgressed(const Animation* animation);
void AnimationEnded(const Animation* animation);
+ // Used during testing; disable or enable animations (default is enabled).
+ static void SetAnimationsForTesting(bool enable);
+
private:
static void OnChildSizeAllocate(GtkWidget* child,
GtkAllocation* allocation,
@@ -110,6 +113,8 @@ class SlideAnimatorGtk : public AnimationDelegate {
// child widget has been allocated, at which point we will move it, and then
// set this variable to false to indicate it should not be moved again.
bool child_needs_move_;
+
+ static bool animations_enabled_;
};
#endif // CHROME_BROWSER_GTK_SLIDE_ANIMATOR_GTK_H_