Battery Status API: add UMA logging for Linux.
[chromium-blink-merge.git] / content / browser / accessibility / android_hit_testing_browsertest.cc
blob1e54cd87c85c2d3d659ad509fa04ff8b40a24eb1
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.
5 #include <set>
6 #include <string>
7 #include <vector>
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"
31 namespace content {
33 class AndroidHitTestingBrowserTest : public ContentBrowserTest {
34 public:
35 AndroidHitTestingBrowserTest() {}
36 virtual ~AndroidHitTestingBrowserTest() {}
39 IN_PROC_BROWSER_TEST_F(AndroidHitTestingBrowserTest,
40 HitTestOutsideDocumentBoundsReturnsRoot) {
41 NavigateToURL(shell(), GURL(url::kAboutBlankURL));
43 // Load the page.
44 AccessibilityNotificationWaiter waiter(
45 shell(), AccessibilityModeComplete,
46 ui::AX_EVENT_LOAD_COMPLETE);
47 const char url_str[] =
48 "data:text/html,"
49 "<!doctype html>"
50 "<html><head><title>Accessibility Test</title></head>"
51 "<body>"
52 "<a href='#'>"
53 "This is some text in a link"
54 "</a>"
55 "</body></html>";
56 GURL url(url_str);
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,
69 ui::AX_EVENT_HOVER);
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