| 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 #include "chrome/browser/chromeos/login/screenshot_tester.h" | 5 #include "chrome/browser/chromeos/login/screenshot_tester.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "base/base_export.h" | 8 #include "base/base_export.h" |
| 9 #include "base/bind_internal.h" | 9 #include "base/bind_internal.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 void ScreenshotTester::UpdateGoldenScreenshot(PNGFile png_data) { | 98 void ScreenshotTester::UpdateGoldenScreenshot(PNGFile png_data) { |
| 99 CHECK(SaveImage("golden_screenshot", golden_screenshots_dir_, png_data)); | 99 CHECK(SaveImage("golden_screenshot", golden_screenshots_dir_, png_data)); |
| 100 } | 100 } |
| 101 | 101 |
| 102 bool ScreenshotTester::SaveImage(const std::string& file_name, | 102 bool ScreenshotTester::SaveImage(const std::string& file_name, |
| 103 const base::FilePath& screenshot_dir, | 103 const base::FilePath& screenshot_dir, |
| 104 PNGFile png_data) { | 104 PNGFile png_data) { |
| 105 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 105 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 106 base::FilePath screenshot_path = | 106 base::FilePath screenshot_path = |
| 107 screenshot_dir.AppendASCII(test_name_ + "_" + file_name + ".png"); | 107 screenshot_dir.AppendASCII(test_name_ + "_" + file_name + ".png"); |
| 108 if (!png_data) { | 108 if (!png_data.get()) { |
| 109 LOG(ERROR) << "Can't take a screenshot"; | 109 LOG(ERROR) << "Can't take a screenshot"; |
| 110 return false; | 110 return false; |
| 111 } | 111 } |
| 112 if (!base::CreateDirectory(screenshot_path.DirName())) { | 112 if (!base::CreateDirectory(screenshot_path.DirName())) { |
| 113 LOG(ERROR) << "Can't create a directory " | 113 LOG(ERROR) << "Can't create a directory " |
| 114 << screenshot_path.DirName().value(); | 114 << screenshot_path.DirName().value(); |
| 115 return false; | 115 return false; |
| 116 } | 116 } |
| 117 if (static_cast<size_t>( | 117 if (static_cast<size_t>( |
| 118 base::WriteFile(screenshot_path, | 118 base::WriteFile(screenshot_path, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 VLOG(0) << "Current screenshot and diff picture saved to " | 215 VLOG(0) << "Current screenshot and diff picture saved to " |
| 216 << artifacts_dir_.value(); | 216 << artifacts_dir_.value(); |
| 217 } else { | 217 } else { |
| 218 VLOG(0) << "Current screenshot matches the golden screenshot. Screenshot " | 218 VLOG(0) << "Current screenshot matches the golden screenshot. Screenshot " |
| 219 "testing passed."; | 219 "testing passed."; |
| 220 } | 220 } |
| 221 ASSERT_TRUE(screenshots_match); | 221 ASSERT_TRUE(screenshots_match); |
| 222 } | 222 } |
| 223 | 223 |
| 224 } // namespace chromeos | 224 } // namespace chromeos |
| OLD | NEW |