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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 AccessibilityFocusRingController::GetInstance()->SetNoFadeForTesting(); | 74 AccessibilityFocusRingController::GetInstance()->SetNoFadeForTesting(); |
75 InProcessBrowserTest::SetUp(); | 75 InProcessBrowserTest::SetUp(); |
76 } | 76 } |
77 | 77 |
78 void SetUpCommandLine(base::CommandLine* command_line) override { | 78 void SetUpCommandLine(base::CommandLine* command_line) override { |
79 command_line->AppendSwitch(::switches::kEnablePixelOutputInTests); | 79 command_line->AppendSwitch(::switches::kEnablePixelOutputInTests); |
80 } | 80 } |
81 | 81 |
82 void CaptureBeforeImage(const gfx::Rect& bounds) { | 82 void CaptureBeforeImage(const gfx::Rect& bounds) { |
83 Capture(bounds); | 83 Capture(bounds); |
84 image_.AsBitmap().deepCopyTo(&before_bmp_); | 84 if (before_bmp_.tryAllocPixels(image_.AsBitmap().info())) { |
| 85 image_.AsBitmap().readPixels(before_bmp_.info(), before_bmp_.getPixels(), |
| 86 before_bmp_.rowBytes(), 0, 0); |
| 87 } |
85 } | 88 } |
86 | 89 |
87 void CaptureAfterImage(const gfx::Rect& bounds) { | 90 void CaptureAfterImage(const gfx::Rect& bounds) { |
88 Capture(bounds); | 91 Capture(bounds); |
89 image_.AsBitmap().deepCopyTo(&after_bmp_); | 92 if (after_bmp_.tryAllocPixels(image_.AsBitmap().info())) { |
| 93 image_.AsBitmap().readPixels(after_bmp_.info(), after_bmp_.getPixels(), |
| 94 after_bmp_.rowBytes(), 0, 0); |
| 95 } |
90 } | 96 } |
91 | 97 |
92 void ComputeImageStats() { | 98 void ComputeImageStats() { |
93 diff_count_ = 0; | 99 diff_count_ = 0; |
94 double accum[4] = {0, 0, 0, 0}; | 100 double accum[4] = {0, 0, 0, 0}; |
95 for (int x = 0; x < before_bmp_.width(); ++x) { | 101 for (int x = 0; x < before_bmp_.width(); ++x) { |
96 for (int y = 0; y < before_bmp_.height(); ++y) { | 102 for (int y = 0; y < before_bmp_.height(); ++y) { |
97 SkColor before_color = before_bmp_.getColor(x, y); | 103 SkColor before_color = before_bmp_.getColor(x, y); |
98 SkColor after_color = after_bmp_.getColor(x, y); | 104 SkColor after_color = after_bmp_.getColor(x, y); |
99 if (before_color != after_color) { | 105 if (before_color != after_color) { |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 // This is a smoke test to assert that something is drawn in the right | 233 // This is a smoke test to assert that something is drawn in the right |
228 // part of the screen of approximately the right size and color. | 234 // part of the screen of approximately the right size and color. |
229 // There's deliberately some tolerance for tiny errors. | 235 // There's deliberately some tolerance for tiny errors. |
230 EXPECT_NEAR(1608, diff_count(), 50); | 236 EXPECT_NEAR(1608, diff_count(), 50); |
231 EXPECT_NEAR(255, SkColorGetR(average_diff_color()), 5); | 237 EXPECT_NEAR(255, SkColorGetR(average_diff_color()), 5); |
232 EXPECT_NEAR(201, SkColorGetG(average_diff_color()), 5); | 238 EXPECT_NEAR(201, SkColorGetG(average_diff_color()), 5); |
233 EXPECT_NEAR(152, SkColorGetB(average_diff_color()), 5); | 239 EXPECT_NEAR(152, SkColorGetB(average_diff_color()), 5); |
234 } | 240 } |
235 | 241 |
236 } // namespace chromeos | 242 } // namespace chromeos |
OLD | NEW |