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

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

Issue 405093003: Taking screenshots while running a test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added comments for ScreenshotTester fields & fixed some minor style bugs 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
new file mode 100644
index 0000000000000000000000000000000000000000..263881597c361aed3569510e076cabf7a4b2b721
--- /dev/null
+++ b/chrome/browser/chromeos/login/screenshot_tester.h
@@ -0,0 +1,65 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_TESTER_H_
+#define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_TESTER_H_
+
+#include "base/base_export.h"
+#include "base/bind_internal.h"
+#include "base/files/file_path.h"
+#include "base/macros.h"
+#include "base/memory/ref_counted_memory.h"
+#include "base/memory/weak_ptr.h"
+#include "base/run_loop.h"
+
Denis Kuznetsov (DE-MUC) 2014/07/21 14:25:33 namespace chromeos here and in .cc file
Lisa Ignatyeva 2014/07/21 14:40:50 Done.
+// A class that allows taking, saving and comparing screnshots while
+// running tests.
+class ScreenshotTester {
+ public:
+ ScreenshotTester();
+ virtual ~ScreenshotTester();
+
+ // Returns true if the screenshots should be taken and will be taken,
+ // false otherwise. Also gets all the information from the command line
+ // swithes.
+ bool TryInitialize();
+
+ // 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);
+
+ private:
+ typedef scoped_refptr<base::RefCountedBytes> PNGFile;
+ void TakeScreenshot();
+
+ // Saves |png_data| as a new golden screenshot for this test.
+ void UpdateGoldenScreenshot(PNGFile png_data);
+
+ // Saves |png_data| as a current screenshot.
+ void ReturnScreenshot(PNGFile png_data);
+
+ // Path to the directory for golden screenshots.
+ base::FilePath screenshot_dest_;
+
+ // Full path to a golden screenshot for the test
+ // from which ScreenshotTester.Run() was called
+ base::FilePath golden_screenshot_path_;
+
+ // |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 running updating golden screenshots mode.
+ bool update_golden_screenshot_;
+ base::WeakPtrFactory<ScreenshotTester> weak_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(ScreenshotTester);
+};
+
+#endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_TESTER_H_
« 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