ash_test_util.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 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_UTIL_H_
  5. #define ASH_TEST_ASH_TEST_UTIL_H_
  6. #include <cstddef>
  7. #include "third_party/skia/include/core/SkColor.h"
  8. #include "ui/gfx/image/image_skia.h"
  9. namespace base {
  10. class FilePath;
  11. class TimeDelta;
  12. }
  13. namespace gfx {
  14. class Size;
  15. }
  16. namespace ash {
  17. // Takes a screenshot of the primary display and saves the screenshot picture to
  18. // the location specified by `file_path`. Returns true if the screenshot is
  19. // taken and saved successfully. Useful for debugging ash unit tests. When using
  20. // this function on an ash unit test, the test code should be executed with
  21. // --enable-pixel-output-in-tests flag.
  22. // NOTE: `file_path` must end with the extension '.png'. If there is an existing
  23. // file matching `file_path`, the existing file will be overwritten.
  24. bool TakePrimaryDisplayScreenshotAndSave(const base::FilePath& file_path);
  25. // Waits for the specified time duration.
  26. // NOTE: this function should only be used for debugging. It should not be used
  27. // in tests or product code.
  28. void GiveItSomeTimeForDebugging(base::TimeDelta time_duration);
  29. // Returns true if the system tray of the root window specified by
  30. // `root_window_index` is visible.
  31. bool IsSystemTrayForRootWindowVisible(size_t root_window_index);
  32. // Creates a pure color image of the specified size.
  33. gfx::ImageSkia CreateSolidColorTestImage(const gfx::Size& image_size,
  34. SkColor color);
  35. } // namespace ash
  36. #endif