| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include <set> | |
| 6 #include <string> | |
| 7 #include <vector> | |
| 8 | |
| 9 #include "base/command_line.h" | |
| 10 #include "base/files/file_util.h" | |
| 11 #include "base/logging.h" | |
| 12 #include "base/strings/string16.h" | |
| 13 #include "base/strings/string_split.h" | |
| 14 #include "base/strings/string_util.h" | |
| 15 #include "base/strings/utf_string_conversions.h" | |
| 16 #include "content/browser/accessibility/accessibility_tree_formatter.h" | |
| 17 #include "content/browser/accessibility/browser_accessibility.h" | |
| 18 #include "content/browser/accessibility/browser_accessibility_manager.h" | |
| 19 #include "content/browser/web_contents/web_contents_impl.h" | |
| 20 #include "content/public/browser/web_contents.h" | |
| 21 #include "content/public/common/content_paths.h" | |
| 22 #include "content/public/common/content_switches.h" | |
| 23 #include "content/public/common/url_constants.h" | |
| 24 #include "content/public/test/content_browser_test.h" | |
| 25 #include "content/public/test/content_browser_test_utils.h" | |
| 26 #include "content/shell/browser/shell.h" | |
| 27 #include "content/test/accessibility_browser_test_utils.h" | |
| 28 #include "testing/gtest/include/gtest/gtest.h" | |
| 29 | |
| 30 namespace content { | |
| 31 | |
| 32 class AndroidHitTestingBrowserTest : public ContentBrowserTest { | |
| 33 public: | |
| 34 AndroidHitTestingBrowserTest() {} | |
| 35 ~AndroidHitTestingBrowserTest() override {} | |
| 36 }; | |
| 37 | |
| 38 IN_PROC_BROWSER_TEST_F(AndroidHitTestingBrowserTest, | |
| 39 HitTestOutsideDocumentBoundsReturnsRoot) { | |
| 40 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); | |
| 41 | |
| 42 // Load the page. | |
| 43 AccessibilityNotificationWaiter waiter( | |
| 44 shell(), AccessibilityModeComplete, | |
| 45 ui::AX_EVENT_LOAD_COMPLETE); | |
| 46 const char url_str[] = | |
| 47 "data:text/html," | |
| 48 "<!doctype html>" | |
| 49 "<html><head><title>Accessibility Test</title></head>" | |
| 50 "<body>" | |
| 51 "<a href='#'>" | |
| 52 "This is some text in a link" | |
| 53 "</a>" | |
| 54 "</body></html>"; | |
| 55 GURL url(url_str); | |
| 56 NavigateToURL(shell(), url); | |
| 57 waiter.WaitForNotification(); | |
| 58 | |
| 59 // Get the BrowserAccessibilityManager. | |
| 60 WebContentsImpl* web_contents = | |
| 61 static_cast<WebContentsImpl*>(shell()->web_contents()); | |
| 62 BrowserAccessibilityManager* manager = | |
| 63 web_contents->GetRootBrowserAccessibilityManager(); | |
| 64 | |
| 65 // Send a hit test request, and wait for the hover event in response. | |
| 66 AccessibilityNotificationWaiter hover_waiter( | |
| 67 shell(), AccessibilityModeComplete, | |
| 68 ui::AX_EVENT_HOVER); | |
| 69 manager->delegate()->AccessibilityHitTest(gfx::Point(-1, -1)); | |
| 70 hover_waiter.WaitForNotification(); | |
| 71 | |
| 72 // Assert that the hover event was fired on the root of the tree. | |
| 73 int hover_target_id = hover_waiter.event_target_id(); | |
| 74 BrowserAccessibility* hovered_node = manager->GetFromID(hover_target_id); | |
| 75 ASSERT_TRUE(hovered_node != NULL); | |
| 76 ASSERT_EQ(ui::AX_ROLE_ROOT_WEB_AREA, hovered_node->GetRole()); | |
| 77 } | |
| 78 | |
| 79 } // namespace content | |
| OLD | NEW |