OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_TESTING_SCREENSHOT_TESTER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_TESTING_SCREENSHOT_TESTER_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_TESTING_SCREENSHOT_TESTER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_TESTING_SCREENSHOT_TESTER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
| 11 #include "base/callback.h" |
11 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
12 #include "base/macros.h" | 13 #include "base/macros.h" |
13 #include "base/memory/ref_counted_memory.h" | 14 #include "base/memory/ref_counted_memory.h" |
14 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
15 #include "base/run_loop.h" | |
16 #include "third_party/skia/include/core/SkBitmap.h" | 16 #include "third_party/skia/include/core/SkBitmap.h" |
17 | 17 |
18 namespace chromeos { | 18 namespace chromeos { |
19 | 19 |
20 // A class that allows taking, saving and comparing screnshots while | 20 // A class that allows taking, saving and comparing screnshots while |
21 // running tests. | 21 // running tests. |
22 class ScreenshotTester { | 22 class ScreenshotTester { |
23 public: | 23 public: |
24 ScreenshotTester(); | 24 ScreenshotTester(); |
25 virtual ~ScreenshotTester(); | 25 virtual ~ScreenshotTester(); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 Result CompareScreenshotsRegularly(SkBitmap model_bitmap, | 130 Result CompareScreenshotsRegularly(SkBitmap model_bitmap, |
131 SkBitmap sample_bitmap); | 131 SkBitmap sample_bitmap); |
132 | 132 |
133 // Path to the directory for golden screenshots. | 133 // Path to the directory for golden screenshots. |
134 base::FilePath golden_screenshots_dir_; | 134 base::FilePath golden_screenshots_dir_; |
135 | 135 |
136 // Path to the directory where screenshots that failed comparing | 136 // Path to the directory where screenshots that failed comparing |
137 // and difference between them and golden ones will be stored. | 137 // and difference between them and golden ones will be stored. |
138 base::FilePath artifacts_dir_; | 138 base::FilePath artifacts_dir_; |
139 | 139 |
140 // |run_loop_| and |run_loop_quitter_| are used to synchronize | 140 // |run_loop_quitter_| is used to stop waiting when |
141 // with ui::GrabWindowSnapshotAsync. | 141 // ui::GrabWindowSnapshotAsync completes. |
142 base::RunLoop run_loop_; | |
143 base::Closure run_loop_quitter_; | 142 base::Closure run_loop_quitter_; |
144 | 143 |
145 // Is true when we're in test mode: | 144 // Is true when we're in test mode: |
146 // comparing golden screenshots and current ones. | 145 // comparing golden screenshots and current ones. |
147 bool test_mode_; | 146 bool test_mode_; |
148 | 147 |
149 // Is true when switches specify that PerceptualDiff should | 148 // Is true when switches specify that PerceptualDiff should |
150 // be used to compare images. | 149 // be used to compare images. |
151 bool pdiff_enabled_; | 150 bool pdiff_enabled_; |
152 | 151 |
153 // Is true when switches specify that artifacts should be saved somewhere. | 152 // Is true when switches specify that artifacts should be saved somewhere. |
154 bool generate_artifacts_; | 153 bool generate_artifacts_; |
155 | 154 |
156 // Vector which holds areas which the comparison ignores because | 155 // Vector which holds areas which the comparison ignores because |
157 // them being different is not a bug (e.g. time on the clock). | 156 // them being different is not a bug (e.g. time on the clock). |
158 std::vector<SkIRect> ignored_areas_; | 157 std::vector<SkIRect> ignored_areas_; |
159 | 158 |
160 base::WeakPtrFactory<ScreenshotTester> weak_factory_; | 159 base::WeakPtrFactory<ScreenshotTester> weak_factory_; |
161 | 160 |
162 DISALLOW_COPY_AND_ASSIGN(ScreenshotTester); | 161 DISALLOW_COPY_AND_ASSIGN(ScreenshotTester); |
163 }; | 162 }; |
164 | 163 |
165 } // namespace chromeos | 164 } // namespace chromeos |
166 | 165 |
167 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_TESTING_SCREENSHOT_TESTER_H_ | 166 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_TESTING_SCREENSHOT_TESTER_H_ |
OLD | NEW |