draw_quad_matchers.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Copyright 2021 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 COMPONENTS_VIZ_TEST_DRAW_QUAD_MATCHERS_H_
  5. #define COMPONENTS_VIZ_TEST_DRAW_QUAD_MATCHERS_H_
  6. #include "components/viz/common/quads/draw_quad.h"
  7. #include "testing/gmock/include/gmock/gmock.h"
  8. #include "third_party/skia/include/core/SkColor.h"
  9. // This file contains gmock matchers for verifying DrawQuads are of the expected
  10. // type with expected attributes. This can be used to verify that a
  11. // CompositorRenderPass or AggregatedRenderPass contains the expected quads.
  12. //
  13. // For example verifying that a render pass contains in front-to-back order, a
  14. // SolidColorDrawQuad which is white, a TextureDrawQuad and finally an
  15. // AggregatedRenderPassDrawQuad would look like:
  16. //
  17. // EXPECT_THAT(render_pass->quad_list,
  18. // testing::ElementsAre(IsSolidColorQuad(SK_ColorWHITE),
  19. // IsTextureQuad(),
  20. // IsAggregatedRenderPassQuad()));
  21. //
  22. // Add additional matcher generation functions to this file for DrawQuad types
  23. // and attributes that aren't implemented yet.
  24. namespace viz {
  25. // Provides human readable quad material names for gtest/gmock.
  26. void PrintTo(DrawQuad::Material material, ::std::ostream* os);
  27. // Matches a SolidColorDrawQuad.
  28. testing::Matcher<const DrawQuad*> IsSolidColorQuad();
  29. // Matches a SolidColorDrawQuad with |expected_color|.
  30. testing::Matcher<const DrawQuad*> IsSolidColorQuad(SkColor4f expected_color);
  31. // Matches a TextureDrawQuad.
  32. testing::Matcher<const DrawQuad*> IsTextureQuad();
  33. // Matches a YuvVideoDrawQuad.
  34. testing::Matcher<const DrawQuad*> IsYuvVideoQuad();
  35. // Matches a SurfaceDrawQuad.
  36. testing::Matcher<const DrawQuad*> IsSurfaceQuad();
  37. // Matches an AggregatedRenderPassQuad.
  38. testing::Matcher<const DrawQuad*> IsAggregatedRenderPassQuad();
  39. // Matches a DrawQuad with expected DrawQuad::rect.
  40. testing::Matcher<const DrawQuad*> HasRect(const gfx::Rect& rect);
  41. // Matches a DrawQuad with expected DrawQuad::visible_rect.
  42. testing::Matcher<const DrawQuad*> HasVisibleRect(const gfx::Rect& visible_rect);
  43. // Matches a DrawQuad with expected SharedQuadState::quad_to_target_transform.
  44. testing::Matcher<const DrawQuad*> HasTransform(const gfx::Transform& transform);
  45. } // namespace viz
  46. #endif // COMPONENTS_VIZ_TEST_DRAW_QUAD_MATCHERS_H_