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