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

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

Issue 441263002: Generalizing architecture for screenshot testing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: commented line removed Created 6 years, 4 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_test.h
diff --git a/chrome/browser/chromeos/login/screenshot_test.h b/chrome/browser/chromeos/login/screenshot_test.h
new file mode 100644
index 0000000000000000000000000000000000000000..d91aecd092deb2ec11d2cb225dca9a119a8eb655
--- /dev/null
+++ b/chrome/browser/chromeos/login/screenshot_test.h
@@ -0,0 +1,89 @@
+// 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_TEST_H_
+#define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_TEST_H_
+
+#include <string>
+
+#include "base/command_line.h"
+#include "base/timer/timer.h"
+#include "chrome/browser/chromeos/login/login_manager_test.h"
+#include "chrome/browser/chromeos/login/screenshot_tester.h"
+#include "content/public/browser/notification_observer.h"
+#include "content/public/browser/notification_registrar.h"
+
+namespace chromeos {
+
+// Base class for tests which support testing with screenshots.
+// Sets up everything required for taking screenshots.
+// Provides functionality to deal with animation load: screenshots
+// should be taken only when all the animation is loaded.
+class ScreenshotTest : public LoginManagerTest,
dzhioev (left Google) 2014/08/07 11:23:55 Can't we derieve LoginManagerTest from ScreenshotT
+ public content::NotificationObserver {
+ public:
+ ScreenshotTest();
+ virtual ~ScreenshotTest();
+
+ // Override from LoginManagerTest.
+ virtual void SetUpOnMainThread() OVERRIDE;
+
+ // Override from LoginManagerTest.
+ virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE;
+
+ // Override from content::NotificationObserver.
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
+ // This method checks if animation is loaded, and, if not,
+ // waits until it is loaded and properly shown on the screen.
+ void WaitUntilAnimationLoads();
+
+ protected:
+ // Does all the required initializations for properly handling
+ // animation-connected issues.
+ // Should be overriden for each test according to which exactly animation
+ // exists in it.
+ virtual void InitializeAnimationHandler();
+
+ // Runs screenshot testing if it is turned on by command line switches.
+ void RunScreenshotTesting(const std::string& test_name);
+
+ // Returns true if, according to the notificatons received, animation has
+ // finished loading by now.
+ // Should be overriden for each test according to which exactly animation
+ // exists in it.
+ virtual bool IsAnimationLoaded();
+
+ bool waiter_loop_is_on_;
+ base::Closure animation_waiter_quitter_;
+ content::NotificationRegistrar registrar_;
+
+ private:
+ // Does all the required initializations before waiting for animation.
+ void PrepareForAnimationWaiting(const base::Closure& quitter);
+
+ // It turns out that it takes some more time for the animation
+ // to finish loading even after all the notifications have been sent.
+ // That happens due to some properties of compositor.
+ // This method should be used after getting all the necessary notifications
+ // to wait for the actual load of animation.
+ void SynchronizeAnimationLoadWithCompositor();
+
+ // This method exists only because of the current implementation of
+ // SynchronizeAnimationLoadWithCompositor.
+ void HandleAnimationLoad();
+
+ base::OneShotTimer<ScreenshotTest> timer_;
+
+ // Is true if testing with screenshots is turned on with all proper switches.
+ bool enable_test_screenshots_;
+
+ ScreenshotTester screenshot_tester;
dzhioev (left Google) 2014/08/07 11:23:55 screenshot_tester_
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_TEST_H_

Powered by Google App Engine
This is Rietveld 408576698