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_TEST_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_TEST_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/command_line.h" | |
| 11 #include "base/timer/timer.h" | |
| 12 #include "chrome/browser/chromeos/login/login_manager_test.h" | |
| 13 #include "chrome/browser/chromeos/login/screenshot_tester.h" | |
| 14 #include "content/public/browser/notification_observer.h" | |
| 15 #include "content/public/browser/notification_registrar.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 ScreenshotTest : public LoginManagerTest, | |
|
dzhioev (left Google)
2014/08/07 11:23:55
Can't we derieve LoginManagerTest from ScreenshotT
| |
| 24 public content::NotificationObserver { | |
| 25 public: | |
| 26 ScreenshotTest(); | |
| 27 virtual ~ScreenshotTest(); | |
| 28 | |
| 29 // Override from LoginManagerTest. | |
| 30 virtual void SetUpOnMainThread() OVERRIDE; | |
| 31 | |
| 32 // Override from LoginManagerTest. | |
| 33 virtual void SetUpCommandLine(base::CommandLine* command_line) OVERRIDE; | |
| 34 | |
| 35 // Override from content::NotificationObserver. | |
| 36 virtual void Observe(int type, | |
| 37 const content::NotificationSource& source, | |
| 38 const content::NotificationDetails& details) OVERRIDE; | |
| 39 | |
| 40 // This method checks if animation is loaded, and, if not, | |
| 41 // waits until it is loaded and properly shown on the screen. | |
| 42 void WaitUntilAnimationLoads(); | |
| 43 | |
| 44 protected: | |
| 45 // Does all the required initializations for properly handling | |
| 46 // animation-connected issues. | |
| 47 // Should be overriden for each test according to which exactly animation | |
| 48 // exists in it. | |
| 49 virtual void InitializeAnimationHandler(); | |
| 50 | |
| 51 // Runs screenshot testing if it is turned on by command line switches. | |
| 52 void RunScreenshotTesting(const std::string& test_name); | |
| 53 | |
| 54 // Returns true if, according to the notificatons received, animation has | |
| 55 // finished loading by now. | |
| 56 // Should be overriden for each test according to which exactly animation | |
| 57 // exists in it. | |
| 58 virtual bool IsAnimationLoaded(); | |
| 59 | |
| 60 bool waiter_loop_is_on_; | |
| 61 base::Closure animation_waiter_quitter_; | |
| 62 content::NotificationRegistrar registrar_; | |
| 63 | |
| 64 private: | |
| 65 // Does all the required initializations before waiting for animation. | |
| 66 void PrepareForAnimationWaiting(const base::Closure& quitter); | |
| 67 | |
| 68 // It turns out that it takes some more time for the animation | |
| 69 // to finish loading even after all the notifications have been sent. | |
| 70 // That happens due to some properties of compositor. | |
| 71 // This method should be used after getting all the necessary notifications | |
| 72 // to wait for the actual load of animation. | |
| 73 void SynchronizeAnimationLoadWithCompositor(); | |
| 74 | |
| 75 // This method exists only because of the current implementation of | |
| 76 // SynchronizeAnimationLoadWithCompositor. | |
| 77 void HandleAnimationLoad(); | |
| 78 | |
| 79 base::OneShotTimer<ScreenshotTest> timer_; | |
| 80 | |
| 81 // Is true if testing with screenshots is turned on with all proper switches. | |
| 82 bool enable_test_screenshots_; | |
| 83 | |
| 84 ScreenshotTester screenshot_tester; | |
|
dzhioev (left Google)
2014/08/07 11:23:55
screenshot_tester_
| |
| 85 }; | |
| 86 | |
| 87 } // namespace chromeos | |
| 88 | |
| 89 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_SCREENSHOT_TEST_H_ | |
| OLD | NEW |