chromium/third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d_test.cc

// 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.

#include "third_party/blink/renderer/modules/canvas/canvas2d/base_rendering_context_2d.h"

#include <array>
#include <cstdint>
#include <optional>
#include <string>
#include <vector>

#include "base/memory/scoped_refptr.h"
#include "cc/paint/paint_canvas.h"
#include "cc/paint/paint_flags.h"
#include "cc/paint/paint_image.h"
#include "cc/paint/paint_op.h"
#include "cc/paint/paint_record.h"
#include "cc/paint/paint_shader.h"
#include "cc/paint/refcounted_buffer.h"
#include "cc/test/paint_op_matchers.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/platform/scheduler/test/renderer_scheduler_test_support.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_binding_for_testing.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_begin_layer_options.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_typedefs.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_canvasfilter_string.h"
#include "third_party/blink/renderer/bindings/modules/v8/v8_union_cssimagevalue_htmlcanvaselement_htmlimageelement_htmlvideoelement_imagebitmap_offscreencanvas_svgimageelement_videoframe.h"
#include "third_party/blink/renderer/core/css/css_property_value_set.h"
#include "third_party/blink/renderer/core/css/parser/css_parser.h"
#include "third_party/blink/renderer/core/css/resolver/font_style_resolver.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/html/canvas/canvas_performance_monitor.h"
#include "third_party/blink/renderer/core/html/canvas/html_canvas_element.h"
#include "third_party/blink/renderer/core/html/canvas/recording_test_utils.h"
#include "third_party/blink/renderer/core/imagebitmap/image_bitmap.h"
#include "third_party/blink/renderer/core/style/filter_operation.h"
#include "third_party/blink/renderer/core/style/filter_operations.h"
#include "third_party/blink/renderer/modules/canvas/canvas2d/canvas_filter.h"
#include "third_party/blink/renderer/modules/canvas/canvas2d/canvas_filter_test_utils.h"
#include "third_party/blink/renderer/modules/canvas/canvas2d/mesh_2d_index_buffer.h"
#include "third_party/blink/renderer/modules/canvas/canvas2d/mesh_2d_uv_buffer.h"
#include "third_party/blink/renderer/modules/canvas/canvas2d/mesh_2d_vertex_buffer.h"
#include "third_party/blink/renderer/platform/bindings/exception_code.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/fonts/font_description.h"
#include "third_party/blink/renderer/platform/geometry/length.h"
#include "third_party/blink/renderer/platform/graphics/graphics_types.h"
#include "third_party/blink/renderer/platform/graphics/image_orientation.h"
#include "third_party/blink/renderer/platform/graphics/memory_managed_paint_canvas.h"  // IWYU pragma: keep (https://github.com/clangd/clangd/issues/2044)
#include "third_party/blink/renderer/platform/graphics/memory_managed_paint_recorder.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_filter.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/heap/member.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "third_party/blink/renderer/platform/wtf/text/wtf_string.h"
#include "third_party/skia/include/core/SkBlendMode.h"
#include "third_party/skia/include/core/SkClipOp.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkM44.h"
#include "third_party/skia/include/core/SkMatrix.h"
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkRect.h"
#include "third_party/skia/include/core/SkRefCnt.h"
#include "third_party/skia/include/core/SkTileMode.h"
#include "third_party/skia/include/private/base/SkPoint_impl.h"
#include "ui/gfx/geometry/size.h"

namespace blink {
namespace {

FillFlags;
ParseFilter;
RecordedOpsAre;
RecordedOpsView;
ClipPathOp;
ClipRectOp;
DrawColorOp;
DrawRectOp;
DrawVerticesOp;
PaintFlags;
PaintImage;
PaintOpEq;
PaintShader;
RestoreOp;
SaveLayerAlphaOp;
SaveLayerFiltersOp;
SaveLayerOp;
SaveOp;
ScaleOp;
SetMatrixOp;
TranslateOp;
UsePaintCache;
IsEmpty;

// Test version of BaseRenderingContext2D. BaseRenderingContext2D can't be
// tested directly because it's an abstract class. This test class essentially
// just gives a definition to all pure virtual method, making it instantiable.
class TestRenderingContext2D final
    : public GarbageCollected<TestRenderingContext2D>,
      public BaseRenderingContext2D,
      public MemoryManagedPaintRecorder::Client {};

V8UnionCanvasFilterOrString* MakeBlurCanvasFilter(float std_deviation) {}

BeginLayerOptions* FilterOption(blink::V8TestingScope& scope,
                                const std::string& filter) {}

TEST(BaseRenderingContextLayerTests, ContextLost) {}

TEST(BaseRenderingContextLayerTests, ResetsAndRestoresShadowStates) {}

TEST(BaseRenderingContextLayerTests, ResetsAndRestoresCompositeStates) {}

TEST(BaseRenderingContextLayerTests, ResetsAndRestoresFilterStates) {}

TEST(BaseRenderingContextLayerTests, BeginLayerThrowsOnInvalidFilterParam) {}

TEST(BaseRenderingContextLayerTests, putImageDataThrowsInLayer) {}

TEST(BaseRenderingContextLayerGlobalStateTests, DefaultRenderingStates) {}

TEST(BaseRenderingContextLayerGlobalStateTests, GlobalAlpha) {}

TEST(BaseRenderingContextLayerGlobalStateTests, BlendingOperation) {}

TEST(BaseRenderingContextLayerGlobalStateTests, CompositeOperation) {}

TEST(BaseRenderingContextLayerGlobalStateTests, Shadow) {}

TEST(BaseRenderingContextLayerGlobalStateTests, GlobalAlphaAndBlending) {}

TEST(BaseRenderingContextLayerGlobalStateTests, GlobalAlphaAndComposite) {}

TEST(BaseRenderingContextLayerGlobalStateTests, GlobalAlphaAndShadow) {}

TEST(BaseRenderingContextLayerGlobalStateTests, GlobalAlphaBlendingAndShadow) {}

TEST(BaseRenderingContextLayerGlobalStateTests, GlobalAlphaCompositeAndShadow) {}

TEST(BaseRenderingContextLayerGlobalStateTests, BlendingAndShadow) {}

TEST(BaseRenderingContextLayerGlobalStateTests, CompositeAndShadow) {}

TEST(BaseRenderingContextLayerGlobalStateTests, Filter) {}

TEST(BaseRenderingContextLayerGlobalStateTests, FilterAndGlobalAlpha) {}

TEST(BaseRenderingContextLayerGlobalStateTests, FilterAndBlending) {}

TEST(BaseRenderingContextLayerGlobalStateTests, FilterAndComposite) {}

TEST(BaseRenderingContextLayerGlobalStateTests, FilterAndShadow) {}

TEST(BaseRenderingContextLayerGlobalStateTests, FilterGlobalAlphaAndBlending) {}

TEST(BaseRenderingContextLayerGlobalStateTests, FilterGlobalAlphaAndComposite) {}

TEST(BaseRenderingContextLayerGlobalStateTests, FilterGlobalAlphaAndShadow) {}

TEST(BaseRenderingContextLayerGlobalStateTests,
     FilterGlobalAlphaBlendingAndShadow) {}

TEST(BaseRenderingContextLayerGlobalStateTests,
     FilterGlobalAlphaCompositeAndShadow) {}

TEST(BaseRenderingContextLayerGlobalStateTests, FilterBlendingAndShadow) {}

TEST(BaseRenderingContextLayerGlobalStateTests, FilterCompositeAndShadow) {}

TEST(BaseRenderingContextLayerGlobalStateTests, ContextFilter) {}

TEST(BaseRenderingContextLayerGlobalStateTests, ContextFilterLayerFilter) {}

TEST(BaseRenderingContextLayerGlobalStateTests, ContextFilterShadow) {}

TEST(BaseRenderingContextLayerGlobalStateTests, TransformsAlone) {}

TEST(BaseRenderingContextLayerGlobalStateTests, TransformsWithShadow) {}

TEST(BaseRenderingContextLayerGlobalStateTests, TransformsWithContextFilter) {}

TEST(BaseRenderingContextLayerGlobalStateTests,
     TransformsWithShadowAndCompositedDraw) {}

TEST(BaseRenderingContextLayerGlobalStateTests,
     TransformsWithShadowAndContextFilter) {}

TEST(BaseRenderingContextLayerGlobalStateTests, NonInvertibleTransform) {}

TEST(BaseRenderingContextLayerGlobalStateTests, CopyCompositeOp) {}

TEST(BaseRenderingContextLayerGlobalStateTests,
     CopyCompositeOpWithOtherStates) {}

TEST(BaseRenderingContextRestoreStackTests, RestoresSaves) {}

TEST(BaseRenderingContextRestoreStackTests, RestoresTransforms) {}

TEST(BaseRenderingContextRestoreStackTests, RestoresClip) {}

TEST(BaseRenderingContextRestoreStackTests, UnclosedLayersAreNotFlushed) {}

TEST(BaseRenderingContextResetTest, DiscardsRenderStates) {}

TEST(BaseRenderingContextLayersCallOrderTests, LoneBeginLayer) {}

TEST(BaseRenderingContextLayersCallOrderTests, LoneRestore) {}

TEST(BaseRenderingContextLayersCallOrderTests, LoneEndLayer) {}

TEST(BaseRenderingContextLayersCallOrderTests, SaveRestore) {}

TEST(BaseRenderingContextLayersCallOrderTests, SaveResetRestore) {}

TEST(BaseRenderingContextLayersCallOrderTests, BeginLayerEndLayer) {}

TEST(BaseRenderingContextLayersCallOrderTests, BeginLayerResetEndLayer) {}

TEST(BaseRenderingContextLayersCallOrderTests, SaveBeginLayer) {}

TEST(BaseRenderingContextLayersCallOrderTests, SaveEndLayer) {}

TEST(BaseRenderingContextLayersCallOrderTests, BeginLayerSave) {}

TEST(BaseRenderingContextLayersCallOrderTests, BeginLayerRestore) {}

TEST(BaseRenderingContextLayersCallOrderTests, SaveBeginLayerRestore) {}

TEST(BaseRenderingContextLayersCallOrderTests, BeginLayerSaveEndLayer) {}

TEST(BaseRenderingContextLayersCallOrderTests, NestedLayers) {}

TEST(BaseRenderingContextLayersCSSTests,
     FilterOperationsWithStyleResolutionHost) {}

TEST(BaseRenderingContextLayersCSSTests,
     FilterOperationsWithNoStyleResolutionHost) {}

TEST(BaseRenderingContextMeshTests, DrawMesh) {}

}  // namespace
}  // namespace blink