OLD | NEW |
| (Empty) |
1 // Copyright (c) 2011 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/file_path.h" | |
6 #include "base/test/test_timeouts.h" | |
7 #include "chrome/test/automation/automation_proxy.h" | |
8 #include "chrome/test/automation/browser_proxy.h" | |
9 #include "chrome/test/automation/tab_proxy.h" | |
10 #include "chrome/test/automation/window_proxy.h" | |
11 #include "chrome/test/base/ui_test_utils.h" | |
12 #include "chrome/test/ui/ui_test.h" | |
13 #include "googleurl/src/gurl.h" | |
14 #include "ui/gfx/point.h" | |
15 #include "ui/gfx/rect.h" | |
16 | |
17 namespace { | |
18 | |
19 class MouseLeaveTest : public UITest { | |
20 public: | |
21 MouseLeaveTest() { | |
22 dom_automation_enabled_ = true; | |
23 show_window_ = true; | |
24 } | |
25 | |
26 DISALLOW_COPY_AND_ASSIGN(MouseLeaveTest); | |
27 }; | |
28 | |
29 #if defined(OS_MACOSX) | |
30 // Missing automation provider support: http://crbug.com/45892 | |
31 #define MAYBE_TestOnMouseOut DISABLED_TestOnMouseOut | |
32 #else | |
33 #define MAYBE_TestOnMouseOut TestOnMouseOut | |
34 #endif | |
35 TEST_F(MouseLeaveTest, MAYBE_TestOnMouseOut) { | |
36 GURL test_url = ui_test_utils::GetTestUrl( | |
37 FilePath(FilePath::kCurrentDirectory), | |
38 FilePath(FILE_PATH_LITERAL("mouseleave.html"))); | |
39 | |
40 scoped_refptr<BrowserProxy> browser = automation()->GetBrowserWindow(0); | |
41 ASSERT_TRUE(browser.get()); | |
42 scoped_refptr<WindowProxy> window = browser->GetWindow(); | |
43 ASSERT_TRUE(window.get()); | |
44 scoped_refptr<TabProxy> tab(GetActiveTab()); | |
45 ASSERT_TRUE(tab.get()); | |
46 | |
47 gfx::Rect tab_view_bounds; | |
48 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_TAB_CONTAINER, &tab_view_bounds, | |
49 true)); | |
50 gfx::Point in_content_point( | |
51 tab_view_bounds.x() + tab_view_bounds.width() / 2, | |
52 tab_view_bounds.y() + 10); | |
53 gfx::Point above_content_point( | |
54 tab_view_bounds.x() + tab_view_bounds.width() / 2, | |
55 tab_view_bounds.y() - 2); | |
56 | |
57 // Start by moving the point just above the content. | |
58 ASSERT_TRUE(window->SimulateOSMouseMove(above_content_point)); | |
59 | |
60 // Navigate to the test html page. | |
61 ASSERT_EQ(AUTOMATION_MSG_NAVIGATION_SUCCESS, tab->NavigateToURL(test_url)); | |
62 | |
63 // Wait for the onload() handler to complete so we can do the | |
64 // next part of the test. | |
65 ASSERT_TRUE(WaitUntilCookieValue( | |
66 tab.get(), test_url, "__state", | |
67 TestTimeouts::large_test_timeout_ms(), "initial")); | |
68 | |
69 // Move the cursor to the top-center of the content, which will trigger | |
70 // a javascript onMouseOver event. | |
71 ASSERT_TRUE(window->SimulateOSMouseMove(in_content_point)); | |
72 | |
73 // Wait on the correct intermediate value of the cookie. | |
74 ASSERT_TRUE(WaitUntilCookieValue( | |
75 tab.get(), test_url, "__state", | |
76 TestTimeouts::large_test_timeout_ms(), "initial,entered")); | |
77 | |
78 // Move the cursor above the content again, which should trigger | |
79 // a javascript onMouseOut event. | |
80 ASSERT_TRUE(window->SimulateOSMouseMove(above_content_point)); | |
81 | |
82 // Wait on the correct final value of the cookie. | |
83 ASSERT_TRUE(WaitUntilCookieValue( | |
84 tab.get(), test_url, "__state", | |
85 TestTimeouts::large_test_timeout_ms(), "initial,entered,left")); | |
86 } | |
87 | |
88 } // namespace | |
OLD | NEW |