| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 VLOG(1) << "Sending event in row " << row << " col " << col | 77 VLOG(1) << "Sending event in row " << row << " col " << col |
| 78 << " with text " << expected_cell_text; | 78 << " with text " << expected_cell_text; |
| 79 | 79 |
| 80 // Send a touch exploration event to the center of the particular grid | 80 // Send a touch exploration event to the center of the particular grid |
| 81 // cell. A touch exploration event is just a mouse move event with | 81 // cell. A touch exploration event is just a mouse move event with |
| 82 // the ui::EF_TOUCH_ACCESSIBILITY flag set. | 82 // the ui::EF_TOUCH_ACCESSIBILITY flag set. |
| 83 gfx::Rect bounds = window->GetBoundsInRootWindow(); | 83 gfx::Rect bounds = window->GetBoundsInRootWindow(); |
| 84 gfx::Point location(bounds.x() + 50 * col + 25, | 84 gfx::Point location(bounds.x() + 50 * col + 25, |
| 85 bounds.y() + 50 * row + 25); | 85 bounds.y() + 50 * row + 25); |
| 86 int flags = ui::EF_TOUCH_ACCESSIBILITY; | 86 int flags = ui::EF_TOUCH_ACCESSIBILITY; |
| 87 scoped_ptr<ui::Event> mouse_move_event(new ui::MouseEvent( | 87 std::unique_ptr<ui::Event> mouse_move_event( |
| 88 ui::ET_MOUSE_MOVED, location, location, ui::EventTimeForNow(), | 88 new ui::MouseEvent(ui::ET_MOUSE_MOVED, location, location, |
| 89 flags, 0)); | 89 ui::EventTimeForNow(), flags, 0)); |
| 90 ignore_result(dispatcher->OnEventFromSource(mouse_move_event.get())); | 90 ignore_result(dispatcher->OnEventFromSource(mouse_move_event.get())); |
| 91 | 91 |
| 92 // Wait until we get a hover event in the expected grid cell. | 92 // Wait until we get a hover event in the expected grid cell. |
| 93 // Tolerate additional events, keep looping until we get the expected one. | 93 // Tolerate additional events, keep looping until we get the expected one. |
| 94 std::string cell_text; | 94 std::string cell_text; |
| 95 do { | 95 do { |
| 96 waiter2.WaitForNotification(); | 96 waiter2.WaitForNotification(); |
| 97 int target_id = waiter2.event_target_id(); | 97 int target_id = waiter2.event_target_id(); |
| 98 BrowserAccessibility* hit = manager->GetFromID(target_id); | 98 BrowserAccessibility* hit = manager->GetFromID(target_id); |
| 99 BrowserAccessibility* child = hit->PlatformGetChild(0); | 99 BrowserAccessibility* child = hit->PlatformGetChild(0); |
| 100 ASSERT_NE(nullptr, child); | 100 ASSERT_NE(nullptr, child); |
| 101 cell_text = child->GetData().GetStringAttribute(ui::AX_ATTR_NAME); | 101 cell_text = child->GetData().GetStringAttribute(ui::AX_ATTR_NAME); |
| 102 VLOG(1) << "Got hover event in cell with text: " << cell_text; | 102 VLOG(1) << "Got hover event in cell with text: " << cell_text; |
| 103 } while (cell_text != expected_cell_text); | 103 } while (cell_text != expected_cell_text); |
| 104 } | 104 } |
| 105 } | 105 } |
| 106 } | 106 } |
| 107 | 107 |
| 108 } // namespace content | 108 } // namespace content |
| OLD | NEW |