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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_TESTING_SCREENSHOT_TESTING_MIXIN_H_
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_TESTING_SCREENSHOT_TESTING_MIXIN_H_
10 #include "base/command_line.h"
11 #include "base/timer/timer.h"
12 #include "chrome/browser/chromeos/login/mixin_based_browser_test.h"
13 #include "chrome/browser/chromeos/login/screenshot_testing/screenshot_tester.h"
14 #include "content/public/test/browser_test_base.h"
18 // Base mixin class for tests which support testing with screenshots.
19 // Sets up everything required for taking screenshots.
20 // Provides functionality to deal with animation load: screenshots
21 // should be taken only when all the animation is loaded.
22 class ScreenshotTestingMixin
: public MixinBasedBrowserTest::Mixin
{
24 ScreenshotTestingMixin();
25 ~ScreenshotTestingMixin() override
;
27 // Override from BrowsertestBase::Mixin.
28 void SetUpInProcessBrowserTestFixture() override
;
30 // Override from BrowsertestBase::Mixin.
31 void SetUpCommandLine(base::CommandLine
* command_line
) override
;
33 // Runs screenshot testing if it is turned on by command line switches.
34 void RunScreenshotTesting(const std::string
& test_name
);
36 // Remembers that area |area| should be ignored during comparison.
37 void IgnoreArea(const SkIRect
& area
);
40 // It turns out that it takes some more time for the animation
41 // to finish loading even after all the notifications have been sent.
42 // That happens due to some properties of compositor.
43 // This method should be used after getting all the necessary notifications
44 // to wait for the actual load of animation.
45 void SynchronizeAnimationLoadWithCompositor();
47 // This method exists only because of the current implementation of
48 // SynchronizeAnimationLoadWithCompositor.
49 void HandleAnimationLoad();
51 // Required for current implementation of
52 // SynchronizeAnimationLoadWithCompositor()
53 base::OneShotTimer
<ScreenshotTestingMixin
> timer_
;
54 base::Closure animation_waiter_quitter_
;
56 // Is true if testing with screenshots is turned on with all proper switches.
57 bool enable_test_screenshots_
;
59 // |screenshot_tester_ | does everything connected with taking, loading and
60 // comparing screenshots
61 ScreenshotTester screenshot_tester_
;
64 } // namespace chromeos
66 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_TESTING_SCREENSHOT_TESTING_MIXIN_H_