ash_test_ui_stabilizer.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright (c) 2022 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. #ifndef ASH_TEST_ASH_TEST_UI_STABILIZER_H_
  5. #define ASH_TEST_ASH_TEST_UI_STABILIZER_H_
  6. #include "ash/test/ash_pixel_test_init_params.h"
  7. #include "ash/wallpaper/test_wallpaper_controller_client.h"
  8. #include "base/files/scoped_temp_dir.h"
  9. #include "base/test/icu_test_util.h"
  10. namespace gfx {
  11. class Size;
  12. } // namespace gfx
  13. namespace ash {
  14. // A test helper class that sets up the system UI for pixel tests.
  15. class AshTestUiStabilizer {
  16. public:
  17. explicit AshTestUiStabilizer(const pixel_test::InitParams& params);
  18. AshTestUiStabilizer(const AshTestUiStabilizer&) = delete;
  19. AshTestUiStabilizer& operator=(const AshTestUiStabilizer&) = delete;
  20. ~AshTestUiStabilizer();
  21. // Makes the variable UI components (such as the battery view and wallpaper)
  22. // constant to avoid flakiness in pixel tests.
  23. void StabilizeUi(const gfx::Size& wallpaper_size);
  24. private:
  25. // Ensures that the system UI is under the dark mode if the dark/light feature
  26. // is enabled.
  27. void MaybeSetDarkMode();
  28. // Sets a pure color wallpaper.
  29. void SetWallPaper(const gfx::Size& wallpaper_size);
  30. // Sets the battery state. It ensures that the tray battery icon does not
  31. // change during pixel tests.
  32. void SetBatteryState();
  33. const pixel_test::InitParams params_;
  34. // Used for setting the locale and the time zone.
  35. const base::test::ScopedRestoreICUDefaultLocale scoped_locale_;
  36. const base::test::ScopedRestoreDefaultTimezone time_zone_;
  37. };
  38. } // namespace ash
  39. #endif // ASH_TEST_ASH_TEST_UI_STABILIZER_H_