Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: chrome/browser/chromeos/ui/accessibility_focus_ring_controller_unittest.cc

Issue 2432583002: Make cursor highlighting feature work across multiple displays (Closed)
Patch Set: Address feedback on test Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "ash/shell.h"
6 #include "ash/test/ash_test_base.h"
7 #include "chrome/browser/chromeos/accessibility/accessibility_highlight_manager. h"
8 #include "chrome/browser/chromeos/ui/accessibility_cursor_ring_layer.h"
5 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h" 9 #include "chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h"
6
7 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 #include "ui/events/event.h"
12 #include "ui/events/event_utils.h"
8 13
9 namespace chromeos { 14 namespace chromeos {
10 15
11 class TestableAccessibilityFocusRingController 16 class TestableAccessibilityFocusRingController
12 : public AccessibilityFocusRingController { 17 : public AccessibilityFocusRingController {
13 public: 18 public:
14 TestableAccessibilityFocusRingController() { 19 TestableAccessibilityFocusRingController() {
15 // By default use an easy round number for testing. 20 // By default use an easy round number for testing.
16 margin_ = 10; 21 margin_ = 10;
17 } 22 }
18 ~TestableAccessibilityFocusRingController() override {} 23 ~TestableAccessibilityFocusRingController() override {}
19 24
20 void RectsToRings(const std::vector<gfx::Rect>& rects, 25 void RectsToRings(const std::vector<gfx::Rect>& rects,
21 std::vector<AccessibilityFocusRing>* rings) const { 26 std::vector<AccessibilityFocusRing>* rings) const {
22 AccessibilityFocusRingController::RectsToRings(rects, rings); 27 AccessibilityFocusRingController::RectsToRings(rects, rings);
23 } 28 }
24 29
25 int GetMargin() const override { return margin_; } 30 int GetMargin() const override { return margin_; }
26 31
27 private: 32 private:
28 int margin_; 33 int margin_;
29 }; 34 };
30 35
31 class AccessibilityFocusRingControllerTest : public testing::Test { 36 class AccessibilityFocusRingControllerTest : public ash::test::AshTestBase {
32 public: 37 public:
33 AccessibilityFocusRingControllerTest() {} 38 AccessibilityFocusRingControllerTest() {}
34 ~AccessibilityFocusRingControllerTest() override {} 39 ~AccessibilityFocusRingControllerTest() override {}
35 40
36 protected: 41 protected:
37 gfx::Rect AddMargin(gfx::Rect r) { 42 gfx::Rect AddMargin(gfx::Rect r) {
38 r.Inset(-controller_.GetMargin(), -controller_.GetMargin()); 43 r.Inset(-controller_.GetMargin(), -controller_.GetMargin());
39 return r; 44 return r;
40 } 45 }
41 46
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 EXPECT_EQ(gfx::Point(10, 400), points[28]); 126 EXPECT_EQ(gfx::Point(10, 400), points[28]);
122 EXPECT_EQ(gfx::Point(0, 400), points[29]); 127 EXPECT_EQ(gfx::Point(0, 400), points[29]);
123 EXPECT_EQ(gfx::Point(0, 390), points[30]); 128 EXPECT_EQ(gfx::Point(0, 390), points[30]);
124 EXPECT_EQ(gfx::Point(0, 110), points[31]); 129 EXPECT_EQ(gfx::Point(0, 110), points[31]);
125 EXPECT_EQ(gfx::Point(0, 100), points[32]); 130 EXPECT_EQ(gfx::Point(0, 100), points[32]);
126 EXPECT_EQ(gfx::Point(0, 100), points[33]); 131 EXPECT_EQ(gfx::Point(0, 100), points[33]);
127 EXPECT_EQ(gfx::Point(0, 100), points[34]); 132 EXPECT_EQ(gfx::Point(0, 100), points[34]);
128 EXPECT_EQ(gfx::Point(0, 100), points[35]); 133 EXPECT_EQ(gfx::Point(0, 100), points[35]);
129 } 134 }
130 135
136 TEST_F(AccessibilityFocusRingControllerTest, CursorWorksOnMultipleDisplays) {
137 if (!SupportsMultipleDisplays())
138 return;
139 UpdateDisplay("400x400,500x500");
140 aura::Window::Windows root_windows =
141 ash::Shell::GetInstance()->GetAllRootWindows();
142 ASSERT_EQ(2u, root_windows.size());
143
144 AccessibilityHighlightManager highlight_manager;
145 highlight_manager.HighlightCursor(true);
146 gfx::Point location(90, 90);
147 ui::MouseEvent event0(ui::ET_MOUSE_MOVED, location, location,
148 ui::EventTimeForNow(), 0, 0);
149 ui::Event::DispatcherApi event_mod(&event0);
150 event_mod.set_target(root_windows[0]);
151 highlight_manager.OnMouseEvent(&event0);
152
153 AccessibilityFocusRingController* controller =
154 AccessibilityFocusRingController::GetInstance();
155 AccessibilityCursorRingLayer* cursor_layer = controller->cursor_layer_.get();
156 EXPECT_EQ(root_windows[0], cursor_layer->root_window());
157 EXPECT_LT(abs(cursor_layer->layer()->GetTargetBounds().x() - location.x()),
158 50);
159 EXPECT_LT(abs(cursor_layer->layer()->GetTargetBounds().y() - location.y()),
160 50);
161
162 ui::MouseEvent event1(ui::ET_MOUSE_MOVED, location, location,
163 ui::EventTimeForNow(), 0, 0);
164 ui::Event::DispatcherApi event_mod1(&event1);
165 event_mod1.set_target(root_windows[1]);
166 highlight_manager.OnMouseEvent(&event1);
167
168 cursor_layer = controller->cursor_layer_.get();
169 EXPECT_EQ(root_windows[1], cursor_layer->root_window());
170 EXPECT_LT(abs(cursor_layer->layer()->GetTargetBounds().x() - location.x()),
171 50);
172 EXPECT_LT(abs(cursor_layer->layer()->GetTargetBounds().y() - location.y()),
173 50);
174 }
175
131 } // namespace chromeos 176 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/ui/accessibility_focus_ring_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698