Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_COMPARING_ADMIXTURE_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_COMPARING_ADMIXTURE_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/command_line.h" | |
| 11 #include "base/timer/timer.h" | |
| 12 #include "chrome/browser/chromeos/login/screenshot_tester.h" | |
| 13 #include "content/public/browser/notification_observer.h" | |
| 14 #include "content/public/browser/notification_registrar.h" | |
| 15 #include "content/public/test/browser_test_base.h" | |
| 16 | |
| 17 namespace chromeos { | |
| 18 | |
| 19 // Base class for tests which support testing with screenshots. | |
| 20 // Sets up everything required for taking screenshots. | |
| 21 // Provides functionality to deal with animation load: screenshots | |
| 22 // should be taken only when all the animation is loaded. | |
| 23 class ScreenshotComparingAdmixture : public content::BrowserTestBase::Admixture, | |
| 24 public content::NotificationObserver { | |
|
dzhioev (left Google)
2014/08/25 17:01:19
Fix indentation.
Lisa Ignatyeva
2014/08/25 17:57:54
Done.
| |
| 25 public: | |
| 26 ScreenshotComparingAdmixture(); | |
| 27 virtual ~ScreenshotComparingAdmixture(); | |
| 28 | |
| 29 // Override from BrowsertestBase::Admixture. | |
| 30 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE; | |
| 31 | |
| 32 // Override from BrowsertestBase::Admixture. | |
| 33 virtual void SetUpOnMainThread() OVERRIDE; | |
| 34 | |
| 35 // Override from BrowsertestBase::Admixture. | |
| 36 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE; | |
| 37 | |
| 38 // Override from content::NotificationObserver. | |
| 39 virtual void Observe( | |
| 40 int type, | |
| 41 const content::NotificationSource& source, | |
| 42 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.
| |
| 43 | |
| 44 // This method checks if animation is loaded, and, if not, | |
| 45 // waits until it is loaded and properly shown on the screen. | |
| 46 void WaitUntilAnimationLoads(); | |
| 47 | |
| 48 // Runs screenshot testing if it is turned on by command line switches. | |
| 49 void RunScreenshotTesting(const std::string& test_name); | |
| 50 | |
| 51 protected: | |
| 52 // Does all the required initializations for properly handling | |
| 53 // animation-connected issues. | |
| 54 virtual void InitializeAnimationHandler() = 0; | |
| 55 | |
| 56 // Returns true if, according to the notificatons received, animation has | |
| 57 // finished loading by now. | |
| 58 virtual bool IsAnimationLoaded() = 0; | |
| 59 | |
| 60 // virtual void RunTestOnMainThread() OVERRIDE; | |
|
dzhioev (left Google)
2014/08/25 17:01:19
Delete?
Lisa Ignatyeva
2014/08/25 17:57:54
Done.
| |
| 61 | |
| 62 bool waiter_loop_is_on_; | |
| 63 base::Closure animation_waiter_quitter_; | |
| 64 content::NotificationRegistrar registrar_; | |
| 65 | |
| 66 private: | |
| 67 // Does all the required initializations before waiting for animation. | |
| 68 void PrepareForAnimationWaiting(const base::Closure& quitter); | |
| 69 | |
| 70 // It turns out that it takes some more time for the animation | |
| 71 // to finish loading even after all the notifications have been sent. | |
| 72 // That happens due to some properties of compositor. | |
| 73 // This method should be used after getting all the necessary notifications | |
| 74 // to wait for the actual load of animation. | |
| 75 void SynchronizeAnimationLoadWithCompositor(); | |
| 76 | |
| 77 // This method exists only because of the current implementation of | |
| 78 // SynchronizeAnimationLoadWithCompositor. | |
| 79 void HandleAnimationLoad(); | |
| 80 | |
| 81 // virtual void TestBody() OVERRIDE; | |
|
dzhioev (left Google)
2014/08/25 17:01:19
Delete?
Lisa Ignatyeva
2014/08/25 17:57:54
Done.
| |
| 82 | |
| 83 base::OneShotTimer<ScreenshotComparingAdmixture> timer_; | |
| 84 | |
| 85 // Is true if testing with screenshots is turned on with all proper switches. | |
| 86 bool enable_test_screenshots_; | |
| 87 | |
| 88 // |screenshot_tester_ | does everything connected with taking, loading and | |
| 89 // comparing screenshots | |
| 90 ScreenshotTester screenshot_tester_; | |
| 91 }; | |
| 92 | |
| 93 } // namespace chromeos | |
| 94 | |
| 95 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_COMPARING_ADMIXTURE_H_ | |
| OLD | NEW |