overview_test_api.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright 2019 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_PUBLIC_CPP_OVERVIEW_TEST_API_H_
  5. #define ASH_PUBLIC_CPP_OVERVIEW_TEST_API_H_
  6. #include <cstdint>
  7. #include "ash/ash_export.h"
  8. #include "base/callback_forward.h"
  9. #include "base/containers/flat_map.h"
  10. #include "third_party/abseil-cpp/absl/types/optional.h"
  11. #include "ui/gfx/geometry/rect.h"
  12. namespace aura {
  13. class Window;
  14. }
  15. namespace ash {
  16. enum class OverviewAnimationState : int32_t {
  17. kEnterAnimationComplete,
  18. kExitAnimationComplete,
  19. };
  20. struct OverviewItemInfo {
  21. // A window represented by an overview item.
  22. aura::Window* window = nullptr;
  23. // Screen bounds of an overview item.
  24. gfx::Rect bounds_in_screen;
  25. // Whether an overview item is being dragged.
  26. bool is_dragged = false;
  27. };
  28. // Overview item info keyed by app windows.
  29. using OverviewInfo = base::flat_map<aura::Window*, OverviewItemInfo>;
  30. // Provides access to the limited functions of OverviewController for autotest
  31. // private API.
  32. class ASH_EXPORT OverviewTestApi {
  33. public:
  34. OverviewTestApi();
  35. OverviewTestApi(const OverviewTestApi&) = delete;
  36. OverviewTestApi& operator=(const OverviewTestApi&) = delete;
  37. ~OverviewTestApi();
  38. using DoneCallback = base::OnceCallback<void(bool animation_succeeded)>;
  39. // Set the overview mode state to |start|. |done_callback| will be invoked
  40. // synchronously if the animation is already complete, and asynchronously if
  41. // the overview state does not match |start|.
  42. void SetOverviewMode(bool start, DoneCallback done_callback);
  43. // Runs the callback when overview is finished animating to |expected_state|.
  44. // Passes true synchronously through |callback| if |expected_state| was
  45. // already set. Otherwise |callback| is passed whether the animation succeeded
  46. // asynchronously when the animation completes.
  47. void WaitForOverviewState(OverviewAnimationState expected_state,
  48. DoneCallback callback);
  49. // Returns overview info for the current overview items if overview is
  50. // started. Otherwise, returns absl::nullopt;
  51. absl::optional<OverviewInfo> GetOverviewInfo() const;
  52. };
  53. } // namespace ash
  54. #endif // ASH_PUBLIC_CPP_OVERVIEW_TEST_API_H_