// Copyright 2022 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef CC_TEST_PAINT_OP_MATCHERS_H_ #define CC_TEST_PAINT_OP_MATCHERS_H_ #include <optional> #include <ostream> #include <sstream> #include <string> #include <type_traits> #include <utility> #include "base/memory/ref_counted.h" #include "base/strings/stringprintf.h" #include "cc/paint/paint_op_buffer.h" #include "cc/test/paint_op_helper.h" #include "testing/gmock/include/gmock/gmock.h" namespace cc { // Matcher checking that a PaintOp is equal to a PaintOp constructed with the // provided parameters. // Example use: // PaintOpBuffer buffer = ...; // EXPECT_THAT(buffer, // ElementsAre(PaintOpEq<SaveOp>(), // PaintOpEq<SetMatrixOp>(SkM44::Scale(1, 2)))); template <typename OpT> class PaintOpEq { … }; // Matcher testing whether a PaintOp is of one or two specific types. The second // template parameter is intended for lite-ops. For example, a line may be // represented as either a DrawLineOp or DrawLineLiteOp. // // Example use: // PaintOpBuffer buffer = ...; // EXPECT_THAT(buffer, // ElementsAre(PaintOpIs<SaveOp>(), PaintOpIs<SetMatrixOp>())); template <typename OpT, typename OpU = OpT> class PaintOpIs { … }; // Equality matcher for DrawRecordOp objects. // // Example use: // PaintOpBuffer nested_buffer; // nested_buffer.push<SaveOp>(); // nested_buffer.push<RestoreOp>(); // // PaintOpBuffer parent_buffer; // parent_buffer.push<DrawRecordOp>(nested_buffer.ReleaseAsRecord()); // // EXPECT_THAT(parent_buffer.ReleaseAsRecord(), // ElementsAre(DrawRecordOpEq(PaintOpEq<SaveOp>(), // PaintOpEq<RestoreOp>()))); template <typename... Args> testing::Matcher<PaintOp> DrawRecordOpEq(Args... args) { … } } // namespace cc #endif // CC_TEST_PAINT_OP_MATCHERS_H_