1 // Copyright 2014 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.
9 #include "base/command_line.h"
10 #include "base/file_util.h"
11 #include "base/logging.h"
12 #include "base/path_service.h"
13 #include "base/strings/string16.h"
14 #include "base/strings/string_split.h"
15 #include "base/strings/string_util.h"
16 #include "base/strings/utf_string_conversions.h"
17 #include "content/browser/accessibility/accessibility_tree_formatter.h"
18 #include "content/browser/accessibility/browser_accessibility.h"
19 #include "content/browser/accessibility/browser_accessibility_manager.h"
20 #include "content/browser/web_contents/web_contents_impl.h"
21 #include "content/public/browser/web_contents.h"
22 #include "content/public/common/content_paths.h"
23 #include "content/public/common/content_switches.h"
24 #include "content/public/common/url_constants.h"
25 #include "content/public/test/content_browser_test.h"
26 #include "content/public/test/content_browser_test_utils.h"
27 #include "content/shell/browser/shell.h"
28 #include "content/test/accessibility_browser_test_utils.h"
29 #include "testing/gtest/include/gtest/gtest.h"
33 class AndroidHitTestingBrowserTest
: public ContentBrowserTest
{
35 AndroidHitTestingBrowserTest() {}
36 virtual ~AndroidHitTestingBrowserTest() {}
39 IN_PROC_BROWSER_TEST_F(AndroidHitTestingBrowserTest
,
40 HitTestOutsideDocumentBoundsReturnsRoot
) {
41 NavigateToURL(shell(), GURL(url::kAboutBlankURL
));
44 AccessibilityNotificationWaiter
waiter(
45 shell(), AccessibilityModeComplete
,
46 ui::AX_EVENT_LOAD_COMPLETE
);
47 const char url_str
[] =
50 "<html><head><title>Accessibility Test</title></head>"
53 "This is some text in a link"
57 NavigateToURL(shell(), url
);
58 waiter
.WaitForNotification();
60 // Get the BrowserAccessibilityManager.
61 WebContentsImpl
* web_contents
=
62 static_cast<WebContentsImpl
*>(shell()->web_contents());
63 BrowserAccessibilityManager
* manager
=
64 web_contents
->GetRootBrowserAccessibilityManager();
66 // Send a hit test request, and wait for the hover event in response.
67 AccessibilityNotificationWaiter
hover_waiter(
68 shell(), AccessibilityModeComplete
,
70 manager
->delegate()->AccessibilityHitTest(gfx::Point(-1, -1));
71 hover_waiter
.WaitForNotification();
73 // Assert that the hover event was fired on the root of the tree.
74 int hover_target_id
= hover_waiter
.event_target_id();
75 BrowserAccessibility
* hovered_node
= manager
->GetFromID(hover_target_id
);
76 ASSERT_TRUE(hovered_node
!= NULL
);
77 ASSERT_EQ(ui::AX_ROLE_ROOT_WEB_AREA
, hovered_node
->GetRole());
80 } // namespace content