Chromium Code Reviews| Index: chrome/browser/chromeos/login/screenshot_comparing_admixture.h |
| diff --git a/chrome/browser/chromeos/login/screenshot_comparing_admixture.h b/chrome/browser/chromeos/login/screenshot_comparing_admixture.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..3cf16afc96b074a3e279dd94da057a6dcafbd05d |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/login/screenshot_comparing_admixture.h |
| @@ -0,0 +1,95 @@ |
| +// 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_COMPARING_ADMIXTURE_H_ |
| +#define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_COMPARING_ADMIXTURE_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/command_line.h" |
| +#include "base/timer/timer.h" |
| +#include "chrome/browser/chromeos/login/screenshot_tester.h" |
| +#include "content/public/browser/notification_observer.h" |
| +#include "content/public/browser/notification_registrar.h" |
| +#include "content/public/test/browser_test_base.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 ScreenshotComparingAdmixture : public content::BrowserTestBase::Admixture, |
| + public content::NotificationObserver { |
|
dzhioev (left Google)
2014/08/25 17:01:19
Fix indentation.
Lisa Ignatyeva
2014/08/25 17:57:54
Done.
|
| + public: |
| + ScreenshotComparingAdmixture(); |
| + virtual ~ScreenshotComparingAdmixture(); |
| + |
| + // Override from BrowsertestBase::Admixture. |
| + virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; |
| + |
| + // Override from BrowsertestBase::Admixture. |
| + virtual void SetUpOnMainThread() OVERRIDE; |
| + |
| + // Override from BrowsertestBase::Admixture. |
| + 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 = 0; |
|
dzhioev (left Google)
2014/08/25 17:01:19
I think this method is not needed in class interfa
Lisa Ignatyeva
2014/08/25 17:57:54
Done.
|
| + |
| + // This method checks if animation is loaded, and, if not, |
| + // waits until it is loaded and properly shown on the screen. |
| + void WaitUntilAnimationLoads(); |
| + |
| + // Runs screenshot testing if it is turned on by command line switches. |
| + void RunScreenshotTesting(const std::string& test_name); |
| + |
| + protected: |
| + // Does all the required initializations for properly handling |
| + // animation-connected issues. |
| + virtual void InitializeAnimationHandler() = 0; |
| + |
| + // Returns true if, according to the notificatons received, animation has |
| + // finished loading by now. |
| + virtual bool IsAnimationLoaded() = 0; |
| + |
| + // virtual void RunTestOnMainThread() OVERRIDE; |
|
dzhioev (left Google)
2014/08/25 17:01:19
Delete?
Lisa Ignatyeva
2014/08/25 17:57:54
Done.
|
| + |
| + 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(); |
| + |
| + // virtual void TestBody() OVERRIDE; |
|
dzhioev (left Google)
2014/08/25 17:01:19
Delete?
Lisa Ignatyeva
2014/08/25 17:57:54
Done.
|
| + |
| + base::OneShotTimer<ScreenshotComparingAdmixture> timer_; |
| + |
| + // Is true if testing with screenshots is turned on with all proper switches. |
| + bool enable_test_screenshots_; |
| + |
| + // |screenshot_tester_ | does everything connected with taking, loading and |
| + // comparing screenshots |
| + ScreenshotTester screenshot_tester_; |
| +}; |
| + |
| +} // namespace chromeos |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_COMPARING_ADMIXTURE_H_ |