chromium/third_party/blink/renderer/core/page/print_context_test.cc

// Copyright 2014 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifdef UNSAFE_BUFFERS_BUILD
// TODO(crbug.com/351564777): Remove this and convert code to safer constructs.
#pragma allow_unsafe_buffers
#endif

#include "third_party/blink/renderer/core/page/print_context.h"

#include <memory>

#include "base/test/scoped_feature_list.h"
#include "components/viz/test/test_context_provider.h"
#include "components/viz/test/test_gles2_interface.h"
#include "components/viz/test/test_raster_interface.h"
#include "gpu/config/gpu_finch_features.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/events/before_print_event.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/html/canvas/canvas_rendering_context.h"
#include "third_party/blink/renderer/core/html/html_element.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/paint/paint_layer_painter.h"
#include "third_party/blink/renderer/core/scroll/scrollbar_theme.h"
#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h"
#include "third_party/blink/renderer/core/testing/dummy_page_holder.h"
#include "third_party/blink/renderer/platform/graphics/canvas_resource_provider.h"
#include "third_party/blink/renderer/platform/graphics/gpu/shared_gpu_context.h"
#include "third_party/blink/renderer/platform/graphics/graphics_context.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_record_builder.h"
#include "third_party/blink/renderer/platform/graphics/test/gpu_test_utils.h"
#include "third_party/blink/renderer/platform/testing/paint_test_configurations.h"
#include "third_party/blink/renderer/platform/wtf/text/text_stream.h"
#include "third_party/skia/include/core/SkCanvas.h"

_;

namespace blink {

const int kPageWidth =;
const int kPageHeight =;

class MockPageContextCanvas : public SkCanvas {};

class PrintContextTest : public PaintTestConfigurations, public RenderingTest {};

class PrintContextFrameTest : public PrintContextTest {};

#define EXPECT_SKRECT_EQ(expectedX, expectedY, expectedWidth, expectedHeight, \
                         actualRect)

INSTANTIATE_PAINT_TEST_SUITE_P();

TEST_P(PrintContextTest, LinkTarget) {}

TEST_P(PrintContextTest, LinkTargetInCompositedScroller) {}

TEST_P(PrintContextTest, LinkTargetUnderAnonymousBlockBeforeBlock) {}

TEST_P(PrintContextTest, LinkTargetContainingABlock) {}

TEST_P(PrintContextTest, LinkTargetUnderInInlines) {}

TEST_P(PrintContextTest, LinkTargetUnderInInlinesMultipleLines) {}

TEST_P(PrintContextTest, LinkTargetUnderInInlinesMultipleLinesCulledInline) {}

TEST_P(PrintContextTest, LinkTargetRelativelyPositionedInline) {}

TEST_P(PrintContextTest, LinkTargetUnderRelativelyPositionedInline) {}

TEST_P(PrintContextTest,
       LinkTargetUnderRelativelyPositionedInlineMultipleLines) {}

TEST_P(PrintContextTest,
       LinkTargetUnderRelativelyPositionedInlineMultipleLinesCulledInline) {}

TEST_P(PrintContextTest, SingleLineLinkNextToWrappedLink) {}

TEST_P(PrintContextTest, LinkTargetSvg) {}

TEST_P(PrintContextTest, LinkedTarget) {}

TEST_P(PrintContextTest, EmptyLinkedTarget) {}

TEST_P(PrintContextTest, LinkTargetBoundingBox) {}

TEST_P(PrintContextTest, LinkInFragmentedContainer) {}

TEST_P(PrintContextTest, LinkedTargetSecondPage) {}

// Here are a few tests to check that shrink to fit doesn't mess up page count.

TEST_P(PrintContextTest, ScaledVerticalRL1) {}

TEST_P(PrintContextTest, ScaledVerticalRL2) {}

TEST_P(PrintContextTest, ScaledVerticalRL3) {}

TEST_P(PrintContextTest, ScaledVerticalLR1) {}

TEST_P(PrintContextTest, ScaledVerticalLR2) {}

TEST_P(PrintContextTest, ScaledVerticalLR3) {}

TEST_P(PrintContextTest, ScaledHorizontalTB1) {}

TEST_P(PrintContextTest, ScaledHorizontalTB2) {}

TEST_P(PrintContextTest, ScaledHorizontalTB3) {}

TEST_P(PrintContextTest, SvgMarkersOnMultiplePages) {}

INSTANTIATE_PAINT_TEST_SUITE_P();

TEST_P(PrintContextFrameTest, WithSubframe) {}

TEST_P(PrintContextFrameTest, WithScrolledSubframe) {}

// This tests that we properly resize and re-layout pages for printing.
TEST_P(PrintContextFrameTest, BasicPrintPageLayout) {}

TEST_P(PrintContextTest, Canvas2DBeforePrint) {}

TEST_P(PrintContextTest, Canvas2DPixelated) {}

TEST_P(PrintContextTest, Canvas2DAutoFlushingSuppressed) {}

// For testing printing behavior when 2d canvases are gpu-accelerated.
class PrintContextAcceleratedCanvasTest : public PrintContextTest {};

INSTANTIATE_PAINT_TEST_SUITE_P();

TEST_P(PrintContextAcceleratedCanvasTest, Canvas2DBeforePrint) {}

namespace {

class AcceleratedCompositingTestPlatform
    : public blink::TestingPlatformSupport {};

}  // namespace

// For testing printing behavior when 2d canvas contexts use oop rasterization.
class PrintContextOOPRCanvasTest : public PrintContextTest {};

INSTANTIATE_PAINT_TEST_SUITE_P();

TEST_P(PrintContextOOPRCanvasTest, Canvas2DBeforePrint) {}

TEST_P(PrintContextOOPRCanvasTest, Canvas2DFlushForImageListener) {}

TEST_P(PrintContextOOPRCanvasTest, Canvas2DNoFlushForImageListener) {}

TEST_P(PrintContextTest, Canvas2DAutoFlushBeforePrinting) {}

// This tests that we don't resize or re-layout subframes in printed content.
// TODO(weili): This test fails when the iframe isn't the root scroller - e.g.
// Adding ScopedImplicitRootScrollerForTest disabler(false);
// https://crbug.com/841602.
TEST_P(PrintContextFrameTest, DISABLED_SubframePrintPageLayout) {}

TEST_P(PrintContextTest,
       TransparentRootBackgroundWithShouldPrintBackgroundDisabled) {}

TEST_P(PrintContextTest,
       TransparentRootBackgroundWithShouldPrintBackgroundEnabled) {}

TEST_P(PrintContextTest, WhiteRootBackgroundWithShouldPrintBackgroundDisabled) {}

TEST_P(PrintContextTest, WhiteRootBackgroundWithShouldPrintBackgroundEnabled) {}

}  // namespace blink