OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 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/utf_string_conversions.h" | |
7 #include "chrome/browser/ui/browser.h" | |
8 #include "chrome/browser/ui/browser_tabstrip.h" | |
9 #include "chrome/test/base/in_process_browser_test.h" | |
10 #include "chrome/test/base/ui_test_utils.h" | |
11 #include "content/public/browser/web_contents.h" | |
12 #include "content/public/browser/web_contents_view.h" | |
13 #include "content/public/test/browser_test_utils.h" | |
14 #include "ui/ui_controls/ui_controls.h" | |
15 | |
16 namespace { | |
17 | |
18 class MouseLeaveTest : public InProcessBrowserTest { | |
19 public: | |
20 MouseLeaveTest() {} | |
21 | |
22 DISALLOW_COPY_AND_ASSIGN(MouseLeaveTest); | |
23 }; | |
24 | |
25 #if defined(OS_MACOSX) | |
26 // Missing automation provider support: http://crbug.com/45892 | |
27 #define MAYBE_TestOnMouseOut DISABLED_TestOnMouseOut | |
28 #elif defined(OS_LINUX) | |
29 // http://crbug.com/133361 | |
30 #define MAYBE_TestOnMouseOut DISABLED_TestOnMouseOut | |
31 #else | |
32 #define MAYBE_TestOnMouseOut TestOnMouseOut | |
33 #endif | |
34 | |
35 IN_PROC_BROWSER_TEST_F(MouseLeaveTest, MAYBE_TestOnMouseOut) { | |
36 GURL test_url = ui_test_utils::GetTestUrl( | |
37 FilePath(), FilePath(FILE_PATH_LITERAL("mouseleave.html"))); | |
38 | |
39 content::WebContents* tab = chrome::GetActiveWebContents(browser()); | |
40 gfx::Rect tab_view_bounds; | |
41 tab->GetView()->GetContainerBounds(&tab_view_bounds); | |
42 | |
43 gfx::Point in_content_point( | |
44 tab_view_bounds.x() + tab_view_bounds.width() / 2, | |
45 tab_view_bounds.y() + 10); | |
46 gfx::Point above_content_point( | |
47 tab_view_bounds.x() + tab_view_bounds.width() / 2, | |
48 tab_view_bounds.y() - 2); | |
49 | |
50 // Start by moving the point just above the content. | |
51 ui_controls::SendMouseMove(above_content_point.x(), above_content_point.y()); | |
52 | |
53 // Navigate to the test html page. | |
54 string16 load_expected_title(ASCIIToUTF16("onload")); | |
55 content::TitleWatcher load_title_watcher(tab, load_expected_title); | |
56 ui_test_utils::NavigateToURL(browser(), test_url); | |
57 // Wait for the onload() handler to complete so we can do the | |
58 // next part of the test. | |
59 EXPECT_EQ(load_expected_title, load_title_watcher.WaitAndGetTitle()); | |
60 | |
61 // Move the cursor to the top-center of the content, which will trigger | |
62 // a javascript onMouseOver event. | |
63 ui_controls::SendMouseMove(in_content_point.x(), in_content_point.y()); | |
64 | |
65 // Wait on the correct intermediate title. | |
66 string16 entered_expected_title(ASCIIToUTF16("entered")); | |
67 content::TitleWatcher entered_title_watcher(tab, entered_expected_title); | |
68 EXPECT_EQ(entered_expected_title, entered_title_watcher.WaitAndGetTitle()); | |
69 | |
70 // Move the cursor above the content again, which should trigger | |
71 // a javascript onMouseOut event. | |
72 ui_controls::SendMouseMove(above_content_point.x(), above_content_point.y()); | |
73 | |
74 // Wait on the correct final value of the cookie. | |
75 string16 left_expected_title(ASCIIToUTF16("left")); | |
76 content::TitleWatcher left_title_watcher(tab, left_expected_title); | |
77 EXPECT_EQ(left_expected_title, left_title_watcher.WaitAndGetTitle()); | |
78 } | |
79 | |
80 } // namespace | |
OLD | NEW |