test_context_factories.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 UI_COMPOSITOR_TEST_TEST_CONTEXT_FACTORIES_H_
  5. #define UI_COMPOSITOR_TEST_TEST_CONTEXT_FACTORIES_H_
  6. #include <memory>
  7. namespace gl {
  8. class DisableNullDrawGLBindings;
  9. }
  10. namespace viz {
  11. class HostFrameSinkManager;
  12. class ServerSharedBitmapManager;
  13. class FrameSinkManagerImpl;
  14. } // namespace viz
  15. namespace ui {
  16. class InProcessContextFactory;
  17. class ContextFactory;
  18. // Set up the compositor ContextFactory for a test environment. Unit tests that
  19. // do not have a full content environment need to call this before initializing
  20. // the Compositor. Some tests expect pixel output, and they should pass true for
  21. // |enable_pixel_output|. Most unit tests should pass false.
  22. class TestContextFactories {
  23. public:
  24. // The default for |output_to_window| will create an OutputSurface that does
  25. // not display anything. Set to true if you want to see results on the screen.
  26. explicit TestContextFactories(bool enable_pixel_output,
  27. bool output_to_window = false);
  28. ~TestContextFactories();
  29. TestContextFactories(const TestContextFactories&) = delete;
  30. TestContextFactories& operator=(const TestContextFactories&) = delete;
  31. ContextFactory* GetContextFactory() const;
  32. private:
  33. std::unique_ptr<gl::DisableNullDrawGLBindings> disable_null_draw_;
  34. std::unique_ptr<viz::ServerSharedBitmapManager> shared_bitmap_manager_;
  35. std::unique_ptr<viz::FrameSinkManagerImpl> frame_sink_manager_;
  36. std::unique_ptr<viz::HostFrameSinkManager> host_frame_sink_manager_;
  37. std::unique_ptr<ui::InProcessContextFactory> implicit_factory_;
  38. };
  39. } // namespace ui
  40. #endif // UI_COMPOSITOR_TEST_TEST_CONTEXT_FACTORIES_H_