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