autotest_desks_api.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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_AUTOTEST_DESKS_API_H_
  5. #define ASH_PUBLIC_CPP_AUTOTEST_DESKS_API_H_
  6. #include "ash/ash_export.h"
  7. #include "base/callback_forward.h"
  8. #include "ui/aura/window.h"
  9. namespace ash {
  10. // Exposes limited APIs for the autotest private APIs to interact with Virtual
  11. // Desks.
  12. class ASH_EXPORT AutotestDesksApi {
  13. public:
  14. AutotestDesksApi();
  15. AutotestDesksApi(const AutotestDesksApi& other) = delete;
  16. AutotestDesksApi& operator=(const AutotestDesksApi& rhs) = delete;
  17. ~AutotestDesksApi();
  18. // Creates a new desk if the maximum number of desks has not been reached, and
  19. // returns true if succeeded, false otherwise.
  20. bool CreateNewDesk();
  21. // Activates the desk at the given |index| and invokes |on_complete| when the
  22. // switch-desks animation completes. Returns false if |index| is invalid, or
  23. // the desk at |index| is already the active desk; true otherwise.
  24. bool ActivateDeskAtIndex(int index, base::OnceClosure on_complete);
  25. // Removes the currently active desk and triggers the remove-desk animation.
  26. // |on_complete| will be invoked when the remove-desks animation completes.
  27. // Returns false if the active desk is the last available desk which cannot be
  28. // removed; true otherwise.
  29. bool RemoveActiveDesk(base::OnceClosure on_complete);
  30. // Activates the desk at the given |index| by activating all the desks between
  31. // the current desk and the desk at |index| in succession. This mimics
  32. // pressing the activate adjacent desk accelerator rapidly. |on_complete| will
  33. // be invoked when the the final animation to |index| completes. Returns false
  34. // if |index| is invalid, or the desk at |index| is already the active desk;
  35. // true otherwise.
  36. bool ActivateAdjacentDesksToTargetIndex(int index,
  37. base::OnceClosure on_complete);
  38. // Check whether a window belongs to a desk at |desk_index| or not.
  39. bool IsWindowInDesk(aura::Window* window, int desk_index);
  40. // Returns the number of currently created desks.
  41. int GetDeskCount() const;
  42. };
  43. } // namespace ash
  44. #endif // ASH_PUBLIC_CPP_AUTOTEST_DESKS_API_H_