summaryrefslogtreecommitdiffstats
path: root/chrome/test/ui
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-02 18:51:22 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-02 18:51:22 +0000
commit20239df9d0639a19600526804f7d4e673fe25e61 (patch)
tree22a31875ddb40d0dfc4762e26cc34db66aab0dd1 /chrome/test/ui
parent5ce1080087f15aba535651d45fedd456992641cf (diff)
downloadchromium_src-20239df9d0639a19600526804f7d4e673fe25e61.zip
chromium_src-20239df9d0639a19600526804f7d4e673fe25e61.tar.gz
chromium_src-20239df9d0639a19600526804f7d4e673fe25e61.tar.bz2
Handle GTK enter and leave notification events and pass them to WebKit as
mouse move events. This prevents an HTML widget from staying in the mouseover state when the cursor leaves the window. Add a new ui test that checks the specific case that was broken by warping the mouse pointer inside and outside the content area. BUG=24660 TEST=ui_tests patch by Dominic Mazzoni <dmazzoni [at] google> original review: http://codereview.chromium.org/274010/show Review URL: http://codereview.chromium.org/354010 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30726 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/ui')
-rw-r--r--chrome/test/ui/mouseleave_uitest.cc99
1 files changed, 99 insertions, 0 deletions
diff --git a/chrome/test/ui/mouseleave_uitest.cc b/chrome/test/ui/mouseleave_uitest.cc
new file mode 100644
index 0000000..8cb59c2
--- /dev/null
+++ b/chrome/test/ui/mouseleave_uitest.cc
@@ -0,0 +1,99 @@
+// 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 "base/command_line.h"
+#include "base/file_util.h"
+#include "base/gfx/point.h"
+#include "base/gfx/rect.h"
+#include "base/path_service.h"
+#include "base/string_util.h"
+#include "base/values.h"
+#include "chrome/browser/view_ids.h"
+#include "chrome/common/chrome_paths.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/test/automation/browser_proxy.h"
+#include "chrome/test/automation/tab_proxy.h"
+#include "chrome/test/automation/window_proxy.h"
+#include "chrome/test/ui/javascript_test_util.h"
+#include "chrome/test/ui/ui_test.h"
+#include "googleurl/src/gurl.h"
+#include "net/base/net_util.h"
+#include "views/event.h"
+
+#if defined(OS_MACOSX)
+// window->GetViewBounds is not implemented
+// window->SimulateOSMouseMove is not implemented
+// http://code.google.com/p/chromium/issues/detail?id=26102
+#define MAYBE_TestOnMouseOut DISABLED_TestOnMouseOut
+#elif defined(OS_WIN)
+// Test succeeds locally, flaky on trybot
+// http://code.google.com/p/chromium/issues/detail?id=26349
+#define MAYBE_TestOnMouseOut DISABLED_TestOnMouseOut
+#endif
+
+namespace {
+
+class MouseLeaveTest : public UITest {
+ public:
+ MouseLeaveTest() {
+ dom_automation_enabled_ = true;
+ show_window_ = true;
+ }
+
+ DISALLOW_COPY_AND_ASSIGN(MouseLeaveTest);
+};
+
+TEST_F(MouseLeaveTest, MAYBE_TestOnMouseOut) {
+ GURL test_url = GetTestUrl(L"", L"mouseleave.html");
+
+ scoped_refptr<TabProxy> tab(GetActiveTab());
+ ASSERT_TRUE(tab.get());
+ scoped_refptr<BrowserProxy> browser = automation()->GetBrowserWindow(0);
+ scoped_refptr<WindowProxy> window = browser->GetWindow();
+
+ gfx::Rect tab_view_bounds;
+ ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_CONTAINER, &tab_view_bounds,
+ true));
+ gfx::Point in_content_point(
+ tab_view_bounds.x() + tab_view_bounds.width() / 2,
+ tab_view_bounds.y() + 10);
+ gfx::Point above_content_point(
+ tab_view_bounds.x() + tab_view_bounds.width() / 2,
+ tab_view_bounds.y() - 2);
+
+ // Start by moving the point just above the content.
+ ASSERT_TRUE(window->SimulateOSMouseMove(above_content_point));
+
+ // Navigate to the test html page.
+ tab->NavigateToURL(test_url);
+
+ const int timeout_ms = 5 * action_max_timeout_ms();
+ const int check_interval_ms = action_max_timeout_ms() / 10;
+
+ // Wait for the onload() handler to complete so we can do the
+ // next part of the test.
+ ASSERT_TRUE(WaitUntilCookieValue(
+ tab.get(), test_url, "__state", check_interval_ms, timeout_ms,
+ "initial"));
+
+ // Move the cursor to the top-center of the content, which will trigger
+ // a javascript onMouseOver event.
+ ASSERT_TRUE(window->SimulateOSMouseMove(in_content_point));
+
+ // Wait on the correct intermediate value of the cookie.
+ ASSERT_TRUE(WaitUntilCookieValue(
+ tab.get(), test_url, "__state", check_interval_ms, timeout_ms,
+ "initial,entered"));
+
+ // Move the cursor above the content again, which should trigger
+ // a javascript onMouseOut event.
+ ASSERT_TRUE(window->SimulateOSMouseMove(above_content_point));
+
+ // Wait on the correct final value of the cookie.
+ ASSERT_TRUE(WaitUntilCookieValue(
+ tab.get(), test_url, "__state", check_interval_ms, timeout_ms,
+ "initial,entered,left"));
+}
+
+} // namespace