shelf_layout_manager_test_base.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // Copyright (c) 2020 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_SHELF_TEST_SHELF_LAYOUT_MANAGER_TEST_BASE_H_
  5. #define ASH_SHELF_TEST_SHELF_LAYOUT_MANAGER_TEST_BASE_H_
  6. #include <utility>
  7. #include "ash/public/cpp/shelf_types.h"
  8. #include "ash/test/ash_test_base.h"
  9. #include "ash/wm/workspace/workspace_types.h"
  10. #include "base/time/time.h"
  11. namespace ui {
  12. class Layer;
  13. }
  14. namespace ash {
  15. class ShelfLayoutManager;
  16. class ShelfLayoutManagerTestBase : public AshTestBase {
  17. public:
  18. template <typename... TaskEnvironmentTraits>
  19. explicit ShelfLayoutManagerTestBase(TaskEnvironmentTraits&&... traits)
  20. : AshTestBase(std::forward<TaskEnvironmentTraits>(traits)...) {}
  21. // Calls the private SetState() function.
  22. void SetState(ShelfLayoutManager* layout_manager, ShelfVisibilityState state);
  23. void UpdateAutoHideStateNow();
  24. aura::Window* CreateTestWindow();
  25. aura::Window* CreateTestWindowInParent(aura::Window* root_window);
  26. // Create a simple widget in the current context (will delete on TearDown).
  27. views::Widget* CreateTestWidget();
  28. void RunGestureDragTests(const gfx::Point& shown, const gfx::Point& hidden);
  29. gfx::Rect GetVisibleShelfWidgetBoundsInScreen();
  30. // Turn on the lock screen.
  31. void LockScreen();
  32. // Turn off the lock screen.
  33. void UnlockScreen();
  34. int64_t GetPrimaryDisplayId();
  35. void StartScroll(gfx::Point start);
  36. void UpdateScroll(float delta_y);
  37. void EndScroll(bool is_fling, float velocity_y);
  38. void IncreaseTimestamp();
  39. WorkspaceWindowState GetWorkspaceWindowState() const;
  40. const ui::Layer* GetNonLockScreenContainersContainerLayer() const;
  41. // If |layout_manager->auto_hide_timer_| is running, stops it, runs its task,
  42. // and returns true. Otherwise, returns false.
  43. bool TriggerAutoHideTimeout() const;
  44. // Performs a swipe up gesture to show an auto-hidden shelf.
  45. void SwipeUpOnShelf();
  46. void SwipeDownOnShelf();
  47. void FlingUpOnShelf();
  48. void DragHotseatDownToBezel();
  49. // Drag Shelf from |start| to |target| by mouse.
  50. void MouseDragShelfTo(const gfx::Point& start, const gfx::Point& target);
  51. // Move mouse to show Shelf in auto-hide mode.
  52. void MouseMouseToShowAutoHiddenShelf();
  53. // Move mouse to |location| and do a two-finger vertical scroll.
  54. void DoTwoFingerVerticalScrollAtLocation(gfx::Point location,
  55. int y_offset,
  56. bool reverse_scroll);
  57. // Move mouse to |location| and do a mousewheel scroll.
  58. void DoMouseWheelScrollAtLocation(gfx::Point location,
  59. int delta_y,
  60. bool reverse_scroll);
  61. // Run the |visibility_update_for_tray_callback_| if set in
  62. // ShelfLayoutManager and return true. Otherwise, return false.
  63. bool RunVisibilityUpdateForTrayCallback();
  64. private:
  65. base::TimeTicks timestamp_;
  66. gfx::Point current_point_;
  67. };
  68. } // namespace ash
  69. #endif // ASH_SHELF_TEST_SHELF_LAYOUT_MANAGER_TEST_BASE_H_