| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/macros.h" | 5 #include "base/macros.h" |
| 6 #include "base/strings/string_number_conversions.h" | 6 #include "base/strings/string_number_conversions.h" |
| 7 #include "content/browser/accessibility/browser_accessibility.h" | 7 #include "content/browser/accessibility/browser_accessibility.h" |
| 8 #include "content/browser/web_contents/web_contents_impl.h" | 8 #include "content/browser/web_contents/web_contents_impl.h" |
| 9 #include "content/public/test/browser_test_utils.h" | 9 #include "content/public/test/browser_test_utils.h" |
| 10 #include "content/public/test/content_browser_test.h" | 10 #include "content/public/test/content_browser_test.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 protected: | 29 protected: |
| 30 void SetUpOnMainThread() override { | 30 void SetUpOnMainThread() override { |
| 31 host_resolver()->AddRule("*", "127.0.0.1"); | 31 host_resolver()->AddRule("*", "127.0.0.1"); |
| 32 SetupCrossSiteRedirector(embedded_test_server()); | 32 SetupCrossSiteRedirector(embedded_test_server()); |
| 33 ASSERT_TRUE(embedded_test_server()->Start()); | 33 ASSERT_TRUE(embedded_test_server()->Start()); |
| 34 } | 34 } |
| 35 | 35 |
| 36 void NavigateToUrlAndWaitForAccessibilityTree(const GURL& url) { | 36 void NavigateToUrlAndWaitForAccessibilityTree(const GURL& url) { |
| 37 AccessibilityNotificationWaiter waiter( | 37 AccessibilityNotificationWaiter waiter( |
| 38 shell()->web_contents(), | 38 shell()->web_contents(), |
| 39 AccessibilityModeComplete, | 39 ACCESSIBILITY_MODE_COMPLETE, |
| 40 ui::AX_EVENT_LOAD_COMPLETE); | 40 ui::AX_EVENT_LOAD_COMPLETE); |
| 41 NavigateToURL(shell(), url); | 41 NavigateToURL(shell(), url); |
| 42 waiter.WaitForNotification(); | 42 waiter.WaitForNotification(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 void SendTouchExplorationEvent(int x, int y) { | 45 void SendTouchExplorationEvent(int x, int y) { |
| 46 aura::Window* window = shell()->web_contents()->GetContentNativeView(); | 46 aura::Window* window = shell()->web_contents()->GetContentNativeView(); |
| 47 ui::EventProcessor* dispatcher = window->GetHost()->event_processor(); | 47 ui::EventProcessor* dispatcher = window->GetHost()->event_processor(); |
| 48 gfx::Rect bounds = window->GetBoundsInRootWindow(); | 48 gfx::Rect bounds = window->GetBoundsInRootWindow(); |
| 49 gfx::Point location(bounds.x() + x, bounds.y() + y); | 49 gfx::Point location(bounds.x() + x, bounds.y() + y); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( | 86 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( |
| 87 shell()->web_contents()); | 87 shell()->web_contents()); |
| 88 BrowserAccessibilityManager* manager = | 88 BrowserAccessibilityManager* manager = |
| 89 web_contents->GetRootBrowserAccessibilityManager(); | 89 web_contents->GetRootBrowserAccessibilityManager(); |
| 90 ASSERT_NE(nullptr, manager); | 90 ASSERT_NE(nullptr, manager); |
| 91 | 91 |
| 92 // Loop over all of the cells in the table. For each one, send a simulated | 92 // Loop over all of the cells in the table. For each one, send a simulated |
| 93 // touch exploration event in the center of that cell, and assert that we | 93 // touch exploration event in the center of that cell, and assert that we |
| 94 // get an accessibility hover event fired in the correct cell. | 94 // get an accessibility hover event fired in the correct cell. |
| 95 AccessibilityNotificationWaiter waiter( | 95 AccessibilityNotificationWaiter waiter( |
| 96 shell()->web_contents(), AccessibilityModeComplete, ui::AX_EVENT_HOVER); | 96 shell()->web_contents(), ACCESSIBILITY_MODE_COMPLETE, ui::AX_EVENT_HOVER); |
| 97 for (int row = 0; row < 5; ++row) { | 97 for (int row = 0; row < 5; ++row) { |
| 98 for (int col = 0; col < 7; ++col) { | 98 for (int col = 0; col < 7; ++col) { |
| 99 std::string expected_cell_text = base::IntToString(row * 7 + col); | 99 std::string expected_cell_text = base::IntToString(row * 7 + col); |
| 100 VLOG(1) << "Sending event in row " << row << " col " << col | 100 VLOG(1) << "Sending event in row " << row << " col " << col |
| 101 << " with text " << expected_cell_text; | 101 << " with text " << expected_cell_text; |
| 102 SendTouchExplorationEvent(50 * col + 25, 50 * row + 25); | 102 SendTouchExplorationEvent(50 * col + 25, 50 * row + 25); |
| 103 | 103 |
| 104 // Wait until we get a hover event in the expected grid cell. | 104 // Wait until we get a hover event in the expected grid cell. |
| 105 // Tolerate additional events, keep looping until we get the expected one. | 105 // Tolerate additional events, keep looping until we get the expected one. |
| 106 std::string cell_text; | 106 std::string cell_text; |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 SendTouchExplorationEvent(50, 350); | 175 SendTouchExplorationEvent(50, 350); |
| 176 waiter.WaitForNotification(); | 176 waiter.WaitForNotification(); |
| 177 int target_id = waiter.event_target_id(); | 177 int target_id = waiter.event_target_id(); |
| 178 BrowserAccessibility* hit = child_manager->GetFromID(target_id); | 178 BrowserAccessibility* hit = child_manager->GetFromID(target_id); |
| 179 EXPECT_EQ(ui::AX_ROLE_BUTTON, hit->GetData().role); | 179 EXPECT_EQ(ui::AX_ROLE_BUTTON, hit->GetData().role); |
| 180 std::string text = hit->GetData().GetStringAttribute(ui::AX_ATTR_NAME); | 180 std::string text = hit->GetData().GetStringAttribute(ui::AX_ATTR_NAME); |
| 181 EXPECT_EQ("Ordinary Button", text); | 181 EXPECT_EQ("Ordinary Button", text); |
| 182 } | 182 } |
| 183 | 183 |
| 184 } // namespace content | 184 } // namespace content |
| OLD | NEW |