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

Unified Diff: chrome/browser/chromeos/login/screenshot_tester.h

Issue 433873002: Loading screenshots and simple 1-to-1 comparison of screenshots (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: compiler error fixed Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/screenshot_tester.h
diff --git a/chrome/browser/chromeos/login/screenshot_tester.h b/chrome/browser/chromeos/login/screenshot_tester.h
index 5a1d05226d58a82bb08ef50a182f39e57ee6b2b0..d9319e83ccf0cf1bdaca73e6a7e0e3bd85f32c4d 100644
--- a/chrome/browser/chromeos/login/screenshot_tester.h
+++ b/chrome/browser/chromeos/login/screenshot_tester.h
@@ -5,6 +5,8 @@
#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_TESTER_H_
#define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_TESTER_H_
+#include <string>
+
#include "base/base_export.h"
#include "base/bind_internal.h"
#include "base/files/file_path.h"
@@ -29,34 +31,56 @@ class ScreenshotTester {
// Does all the work that has been stated through switches:
// updates golden screenshot or takes a new screenshot and compares it
- // with the golden one (this part is not implemented yet).
- void Run(const std::string& file_name);
+ // with the golden one. |test_name| is the name of the test from which
+ // we run this method.
+ void Run(const std::string& test_name);
private:
typedef scoped_refptr<base::RefCountedBytes> PNGFile;
- // Takes a screenshot and puts it to |screenshot_| field.
- void TakeScreenshot();
+ // Takes a screenshot and returns it.
+ PNGFile TakeScreenshot();
+
+ // Saves |png_data| as a new golden screenshot for test |test_name_|.
+ void UpdateGoldenScreenshot(PNGFile png_data);
- // Saves |png_data| as a new golden screenshot for this test.
- void UpdateGoldenScreenshot(const std::string& file_name, PNGFile png_data);
+ // Saves an image |png_data|, assuming it is a .png file.
+ // Returns true if image was saved successfully.
+ bool SaveImage(const std::string& file_name,
+ const base::FilePath& screenshot_dir,
+ PNGFile png_data);
// Saves |png_data| as a current screenshot.
- void ReturnScreenshot(PNGFile png_data);
+ void ReturnScreenshot(const PNGFile& screenshot, PNGFile png_data);
+
+ // Loads golden screenshot from the disk. Fails if there is no
+ // golden screenshot for test |test_name_|.
+ PNGFile LoadGoldenScreenshot();
+
+ // Compares two given screenshots and saves |sample|
+ // and difference between |sample| and |model|, if they differ in any pixel.
+ void CompareScreenshots(PNGFile model, PNGFile sample);
+
+ // Name of the test from which Run() method has been called.
+ // Used for generating names for screenshot files.
+ std::string test_name_;
// Path to the directory for golden screenshots.
- base::FilePath screenshot_dest_;
+ base::FilePath golden_screenshots_dir_;
+
+ // Path to the directory where screenshots that failed comparing
+ // and difference between them and golden ones will be stored.
+ base::FilePath artifacts_dir_;
// |run_loop_| and |run_loop_quitter_| are used to synchronize
// with ui::GrabWindowSnapshotAsync.
base::RunLoop run_loop_;
base::Closure run_loop_quitter_;
- // Current screenshot.
- PNGFile screenshot_;
+ // Is true when we're in test mode:
+ // comparing golden screenshots and current ones.
+ bool test_mode_;
- // Is true when we running updating golden screenshots mode.
- bool update_golden_screenshot_;
base::WeakPtrFactory<ScreenshotTester> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(ScreenshotTester);
« no previous file with comments | « chrome/browser/chromeos/login/login_ui_browsertest.cc ('k') | chrome/browser/chromeos/login/screenshot_tester.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698