| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/command_line.h" | |
| 6 #include "base/file_util.h" | |
| 7 #include "base/gfx/point.h" | |
| 8 #include "base/gfx/rect.h" | |
| 9 #include "base/path_service.h" | |
| 10 #include "base/string_util.h" | |
| 11 #include "base/values.h" | |
| 12 #include "chrome/browser/view_ids.h" | |
| 13 #include "chrome/common/chrome_paths.h" | |
| 14 #include "chrome/common/chrome_switches.h" | |
| 15 #include "chrome/test/automation/browser_proxy.h" | |
| 16 #include "chrome/test/automation/tab_proxy.h" | |
| 17 #include "chrome/test/automation/window_proxy.h" | |
| 18 #include "chrome/test/ui/javascript_test_util.h" | |
| 19 #include "chrome/test/ui/ui_test.h" | |
| 20 #include "googleurl/src/gurl.h" | |
| 21 #include "net/base/net_util.h" | |
| 22 #include "views/event.h" | |
| 23 | |
| 24 #if defined(OS_MACOSX) | |
| 25 // window->GetViewBounds is not implemented | |
| 26 // window->SimulateOSMouseMove is not implemented | |
| 27 // http://code.google.com/p/chromium/issues/detail?id=26102 | |
| 28 #define MAYBE_TestOnMouseOut DISABLED_TestOnMouseOut | |
| 29 #elif defined(OS_WIN) | |
| 30 // Test succeeds locally, flaky on trybot | |
| 31 // http://code.google.com/p/chromium/issues/detail?id=26349 | |
| 32 #define MAYBE_TestOnMouseOut DISABLED_TestOnMouseOut | |
| 33 #endif | |
| 34 | |
| 35 namespace { | |
| 36 | |
| 37 class MouseLeaveTest : public UITest { | |
| 38 public: | |
| 39 MouseLeaveTest() { | |
| 40 dom_automation_enabled_ = true; | |
| 41 show_window_ = true; | |
| 42 } | |
| 43 | |
| 44 DISALLOW_COPY_AND_ASSIGN(MouseLeaveTest); | |
| 45 }; | |
| 46 | |
| 47 TEST_F(MouseLeaveTest, MAYBE_TestOnMouseOut) { | |
| 48 GURL test_url = GetTestUrl(L"", L"mouseleave.html"); | |
| 49 | |
| 50 scoped_refptr<TabProxy> tab(GetActiveTab()); | |
| 51 ASSERT_TRUE(tab.get()); | |
| 52 scoped_refptr<BrowserProxy> browser = automation()->GetBrowserWindow(0); | |
| 53 scoped_refptr<WindowProxy> window = browser->GetWindow(); | |
| 54 | |
| 55 gfx::Rect tab_view_bounds; | |
| 56 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_CONTAINER, &tab_view_bounds, | |
| 57 true)); | |
| 58 gfx::Point in_content_point( | |
| 59 tab_view_bounds.x() + tab_view_bounds.width() / 2, | |
| 60 tab_view_bounds.y() + 10); | |
| 61 gfx::Point above_content_point( | |
| 62 tab_view_bounds.x() + tab_view_bounds.width() / 2, | |
| 63 tab_view_bounds.y() - 2); | |
| 64 | |
| 65 // Start by moving the point just above the content. | |
| 66 ASSERT_TRUE(window->SimulateOSMouseMove(above_content_point)); | |
| 67 | |
| 68 // Navigate to the test html page. | |
| 69 tab->NavigateToURL(test_url); | |
| 70 | |
| 71 const int timeout_ms = 5 * action_max_timeout_ms(); | |
| 72 const int check_interval_ms = action_max_timeout_ms() / 10; | |
| 73 | |
| 74 // Wait for the onload() handler to complete so we can do the | |
| 75 // next part of the test. | |
| 76 ASSERT_TRUE(WaitUntilCookieValue( | |
| 77 tab.get(), test_url, "__state", check_interval_ms, timeout_ms, | |
| 78 "initial")); | |
| 79 | |
| 80 // Move the cursor to the top-center of the content, which will trigger | |
| 81 // a javascript onMouseOver event. | |
| 82 ASSERT_TRUE(window->SimulateOSMouseMove(in_content_point)); | |
| 83 | |
| 84 // Wait on the correct intermediate value of the cookie. | |
| 85 ASSERT_TRUE(WaitUntilCookieValue( | |
| 86 tab.get(), test_url, "__state", check_interval_ms, timeout_ms, | |
| 87 "initial,entered")); | |
| 88 | |
| 89 // Move the cursor above the content again, which should trigger | |
| 90 // a javascript onMouseOut event. | |
| 91 ASSERT_TRUE(window->SimulateOSMouseMove(above_content_point)); | |
| 92 | |
| 93 // Wait on the correct final value of the cookie. | |
| 94 ASSERT_TRUE(WaitUntilCookieValue( | |
| 95 tab.get(), test_url, "__state", check_interval_ms, timeout_ms, | |
| 96 "initial,entered,left")); | |
| 97 } | |
| 98 | |
| 99 } // namespace | |
| OLD | NEW |