blob: 835c3ee9621cce253abe1a0560e064e7863cd14d [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/flow/layers/layer.h"
namespace flutter {
namespace testing {
// Mock implementation of the |Layer| interface that does nothing but paint
// the specified |path| into the canvas. It records the |PrerollContext| and
// |PaintContext| data passed in by its parent |Layer|, so the test can later
// verify the data against expected values.
class MockLayer : public Layer {
MockLayer(SkPath path,
SkPaint paint = SkPaint(),
bool fake_has_platform_view = false,
bool fake_needs_system_composite = false,
bool fake_reads_surface = false);
void Preroll(PrerollContext* context, const SkMatrix& matrix) override;
void Paint(PaintContext& context) const override;
const MutatorsStack& parent_mutators() { return parent_mutators_; }
const SkMatrix& parent_matrix() { return parent_matrix_; }
const SkRect& parent_cull_rect() { return parent_cull_rect_; }
float parent_elevation() { return parent_elevation_; }
bool parent_has_platform_view() { return parent_has_platform_view_; }
MutatorsStack parent_mutators_;
SkMatrix parent_matrix_;
SkRect parent_cull_rect_ = SkRect::MakeEmpty();
SkPath fake_paint_path_;
SkPaint fake_paint_;
float parent_elevation_ = 0;
bool parent_has_platform_view_ = false;
bool fake_has_platform_view_ = false;
bool fake_needs_system_composite_ = false;
bool fake_reads_surface_ = false;
} // namespace testing
} // namespace flutter