| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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 "chrome/browser/chromeos/accessibility/accessibility_highlight_manager.
h" | 5 #include "chrome/browser/chromeos/accessibility/accessibility_highlight_manager.
h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 base::Closure run_loop_quitter_; | 137 base::Closure run_loop_quitter_; |
| 138 gfx::Image image_; | 138 gfx::Image image_; |
| 139 SkBitmap before_bmp_; | 139 SkBitmap before_bmp_; |
| 140 SkBitmap after_bmp_; | 140 SkBitmap after_bmp_; |
| 141 int diff_count_ = 0; | 141 int diff_count_ = 0; |
| 142 SkColor average_diff_color_ = 0; | 142 SkColor average_diff_color_ = 0; |
| 143 | 143 |
| 144 DISALLOW_COPY_AND_ASSIGN(AccessibilityHighlightManagerTest); | 144 DISALLOW_COPY_AND_ASSIGN(AccessibilityHighlightManagerTest); |
| 145 }; | 145 }; |
| 146 | 146 |
| 147 // Flaky. http://crbug.com/621306 |
| 147 IN_PROC_BROWSER_TEST_F(AccessibilityHighlightManagerTest, | 148 IN_PROC_BROWSER_TEST_F(AccessibilityHighlightManagerTest, |
| 148 TestCaretRingDrawsBluePixels) { | 149 DISABLED_TestCaretRingDrawsBluePixels) { |
| 149 gfx::Rect capture_bounds(200, 300, 100, 100); | 150 gfx::Rect capture_bounds(200, 300, 100, 100); |
| 150 gfx::Rect caret_bounds(230, 330, 1, 25); | 151 gfx::Rect caret_bounds(230, 330, 1, 25); |
| 151 | 152 |
| 152 CaptureBeforeImage(capture_bounds); | 153 CaptureBeforeImage(capture_bounds); |
| 153 | 154 |
| 154 TestAccessibilityHighlightManager manager; | 155 TestAccessibilityHighlightManager manager; |
| 155 manager.HighlightCaret(true); | 156 manager.HighlightCaret(true); |
| 156 MockTextInputClient text_input_client; | 157 MockTextInputClient text_input_client; |
| 157 text_input_client.SetCaretBounds(caret_bounds); | 158 text_input_client.SetCaretBounds(caret_bounds); |
| 158 manager.OnCaretBoundsChanged(&text_input_client); | 159 manager.OnCaretBoundsChanged(&text_input_client); |
| 159 | 160 |
| 160 CaptureAfterImage(capture_bounds); | 161 CaptureAfterImage(capture_bounds); |
| 161 ComputeImageStats(); | 162 ComputeImageStats(); |
| 162 | 163 |
| 163 // This is a smoke test to assert that something is drawn in the right | 164 // This is a smoke test to assert that something is drawn in the right |
| 164 // part of the screen of approximately the right size and color. | 165 // part of the screen of approximately the right size and color. |
| 165 // There's deliberately some tolerance for tiny errors. | 166 // There's deliberately some tolerance for tiny errors. |
| 166 EXPECT_NEAR(1487, diff_count(), 50); | 167 EXPECT_NEAR(1487, diff_count(), 50); |
| 167 EXPECT_NEAR(175, SkColorGetR(average_diff_color()), 5); | 168 EXPECT_NEAR(175, SkColorGetR(average_diff_color()), 5); |
| 168 EXPECT_NEAR(175, SkColorGetG(average_diff_color()), 5); | 169 EXPECT_NEAR(175, SkColorGetG(average_diff_color()), 5); |
| 169 EXPECT_NEAR(255, SkColorGetB(average_diff_color()), 5); | 170 EXPECT_NEAR(255, SkColorGetB(average_diff_color()), 5); |
| 170 } | 171 } |
| 171 | 172 |
| 173 // Flaky. http://crbug.com/621306 |
| 172 IN_PROC_BROWSER_TEST_F(AccessibilityHighlightManagerTest, | 174 IN_PROC_BROWSER_TEST_F(AccessibilityHighlightManagerTest, |
| 173 TestCursorRingDrawsRedPixels) { | 175 DISABLED_TestCursorRingDrawsRedPixels) { |
| 174 gfx::Rect capture_bounds(200, 300, 100, 100); | 176 gfx::Rect capture_bounds(200, 300, 100, 100); |
| 175 gfx::Point cursor_point(250, 350); | 177 gfx::Point cursor_point(250, 350); |
| 176 | 178 |
| 177 CaptureBeforeImage(capture_bounds); | 179 CaptureBeforeImage(capture_bounds); |
| 178 | 180 |
| 179 TestAccessibilityHighlightManager manager; | 181 TestAccessibilityHighlightManager manager; |
| 180 manager.HighlightCursor(true); | 182 manager.HighlightCursor(true); |
| 181 ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, cursor_point, cursor_point, | 183 ui::MouseEvent mouse_move(ui::ET_MOUSE_MOVED, cursor_point, cursor_point, |
| 182 ui::EventTimeForNow(), 0, 0); | 184 ui::EventTimeForNow(), 0, 0); |
| 183 manager.OnMouseEvent(&mouse_move); | 185 manager.OnMouseEvent(&mouse_move); |
| 184 CaptureAfterImage(capture_bounds); | 186 CaptureAfterImage(capture_bounds); |
| 185 ComputeImageStats(); | 187 ComputeImageStats(); |
| 186 | 188 |
| 187 // This is a smoke test to assert that something is drawn in the right | 189 // This is a smoke test to assert that something is drawn in the right |
| 188 // part of the screen of approximately the right size and color. | 190 // part of the screen of approximately the right size and color. |
| 189 // There's deliberately some tolerance for tiny errors. | 191 // There's deliberately some tolerance for tiny errors. |
| 190 EXPECT_NEAR(1521, diff_count(), 50); | 192 EXPECT_NEAR(1521, diff_count(), 50); |
| 191 EXPECT_NEAR(255, SkColorGetR(average_diff_color()), 5); | 193 EXPECT_NEAR(255, SkColorGetR(average_diff_color()), 5); |
| 192 EXPECT_NEAR(176, SkColorGetG(average_diff_color()), 5); | 194 EXPECT_NEAR(176, SkColorGetG(average_diff_color()), 5); |
| 193 EXPECT_NEAR(176, SkColorGetB(average_diff_color()), 5); | 195 EXPECT_NEAR(176, SkColorGetB(average_diff_color()), 5); |
| 194 } | 196 } |
| 195 | 197 |
| 198 // Flaky. http://crbug.com/621306 |
| 196 IN_PROC_BROWSER_TEST_F(AccessibilityHighlightManagerTest, | 199 IN_PROC_BROWSER_TEST_F(AccessibilityHighlightManagerTest, |
| 197 TestFocusRingDrawsOrangePixels) { | 200 DISABLED_TestFocusRingDrawsOrangePixels) { |
| 198 gfx::Rect capture_bounds(200, 300, 100, 100); | 201 gfx::Rect capture_bounds(200, 300, 100, 100); |
| 199 gfx::Rect focus_bounds(230, 330, 40, 40); | 202 gfx::Rect focus_bounds(230, 330, 40, 40); |
| 200 | 203 |
| 201 CaptureBeforeImage(capture_bounds); | 204 CaptureBeforeImage(capture_bounds); |
| 202 | 205 |
| 203 TestAccessibilityHighlightManager manager; | 206 TestAccessibilityHighlightManager manager; |
| 204 manager.HighlightFocus(true); | 207 manager.HighlightFocus(true); |
| 205 content::FocusedNodeDetails details{false, focus_bounds}; | 208 content::FocusedNodeDetails details{false, focus_bounds}; |
| 206 manager.Observe(content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, | 209 manager.Observe(content::NOTIFICATION_FOCUS_CHANGED_IN_PAGE, |
| 207 content::Source<AccessibilityHighlightManagerTest>(this), | 210 content::Source<AccessibilityHighlightManagerTest>(this), |
| 208 content::Details<content::FocusedNodeDetails>(&details)); | 211 content::Details<content::FocusedNodeDetails>(&details)); |
| 209 CaptureAfterImage(capture_bounds); | 212 CaptureAfterImage(capture_bounds); |
| 210 ComputeImageStats(); | 213 ComputeImageStats(); |
| 211 | 214 |
| 212 // This is a smoke test to assert that something is drawn in the right | 215 // This is a smoke test to assert that something is drawn in the right |
| 213 // part of the screen of approximately the right size and color. | 216 // part of the screen of approximately the right size and color. |
| 214 // There's deliberately some tolerance for tiny errors. | 217 // There's deliberately some tolerance for tiny errors. |
| 215 EXPECT_NEAR(1608, diff_count(), 50); | 218 EXPECT_NEAR(1608, diff_count(), 50); |
| 216 EXPECT_NEAR(255, SkColorGetR(average_diff_color()), 5); | 219 EXPECT_NEAR(255, SkColorGetR(average_diff_color()), 5); |
| 217 EXPECT_NEAR(201, SkColorGetG(average_diff_color()), 5); | 220 EXPECT_NEAR(201, SkColorGetG(average_diff_color()), 5); |
| 218 EXPECT_NEAR(152, SkColorGetB(average_diff_color()), 5); | 221 EXPECT_NEAR(152, SkColorGetB(average_diff_color()), 5); |
| 219 } | 222 } |
| 220 | 223 |
| 221 } // namespace chromeos | 224 } // namespace chromeos |
| OLD | NEW |