wm_test_helper.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2013 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 UI_WM_TEST_WM_TEST_HELPER_H_
  5. #define UI_WM_TEST_WM_TEST_HELPER_H_
  6. #include <memory>
  7. #include "base/run_loop.h"
  8. #include "ui/aura/client/window_parenting_client.h"
  9. #include "ui/aura/window_tree_host.h"
  10. namespace aura {
  11. class TestScreen;
  12. class Window;
  13. class WindowTreeHost;
  14. namespace client {
  15. class DefaultCaptureClient;
  16. class FocusClient;
  17. }
  18. }
  19. namespace gfx {
  20. class Rect;
  21. class Size;
  22. }
  23. namespace wm {
  24. class CompoundEventFilter;
  25. class WMState;
  26. // Creates a minimal environment for running the shell. We can't pull in all of
  27. // ash here, but we can create and attach several of the same things we'd find
  28. // in ash.
  29. class WMTestHelper : public aura::client::WindowParentingClient {
  30. public:
  31. explicit WMTestHelper(const gfx::Size& default_window_size);
  32. WMTestHelper(const WMTestHelper&) = delete;
  33. WMTestHelper& operator=(const WMTestHelper&) = delete;
  34. ~WMTestHelper() override;
  35. aura::WindowTreeHost* host() { return host_.get(); }
  36. // Overridden from client::WindowParentingClient:
  37. aura::Window* GetDefaultParent(aura::Window* window,
  38. const gfx::Rect& bounds) override;
  39. private:
  40. std::unique_ptr<WMState> wm_state_;
  41. std::unique_ptr<aura::TestScreen> test_screen_;
  42. std::unique_ptr<aura::WindowTreeHost> host_;
  43. std::unique_ptr<wm::CompoundEventFilter> root_window_event_filter_;
  44. std::unique_ptr<aura::client::DefaultCaptureClient> capture_client_;
  45. std::unique_ptr<aura::client::FocusClient> focus_client_;
  46. };
  47. } // namespace wm
  48. #endif // UI_WM_TEST_WM_TEST_HELPER_H_