chromium/third_party/blink/renderer/core/paint/timing/image_paint_timing_detector_test.cc

// Copyright 2018 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/core/paint/timing/image_paint_timing_detector.h"

#include "base/functional/bind.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/test_mock_time_task_runner.h"
#include "base/test/trace_event_analyzer.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "components/ukm/test_ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "testing/gmock/include/gmock/gmock-matchers.h"
#include "third_party/blink/renderer/core/frame/frame_test_helpers.h"
#include "third_party/blink/renderer/core/frame/web_local_frame_impl.h"
#include "third_party/blink/renderer/core/html/html_image_element.h"
#include "third_party/blink/renderer/core/html/media/html_video_element.h"
#include "third_party/blink/renderer/core/loader/resource/image_resource.h"
#include "third_party/blink/renderer/core/paint/timing/largest_contentful_paint_calculator.h"
#include "third_party/blink/renderer/core/paint/timing/paint_timing_detector.h"
#include "third_party/blink/renderer/core/paint/timing/paint_timing_test_helper.h"
#include "third_party/blink/renderer/core/scroll/scroll_types.h"
#include "third_party/blink/renderer/core/svg/svg_image_element.h"
#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h"
#include "third_party/blink/renderer/core/timing/dom_window_performance.h"
#include "third_party/blink/renderer/core/timing/performance_timing_for_reporting.h"
#include "third_party/blink/renderer/core/timing/window_performance.h"
#include "third_party/blink/renderer/platform/graphics/unaccelerated_static_bitmap_image.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/testing/paint_test_configurations.h"
#include "third_party/blink/renderer/platform/testing/task_environment.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/url_test_helpers.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkSurface.h"

namespace blink {

#define SIMPLE_IMAGE

#define LARGE_IMAGE

#define TRANSPARENT_PLACEHOLDER_IMAGE

UkmPaintTiming;
Optional;

class ImagePaintTimingDetectorTest : public testing::Test,
                                     public PaintTestConfigurations {};

constexpr base::TimeDelta ImagePaintTimingDetectorTest::kQuantumOfTime;

INSTANTIATE_PAINT_TEST_SUITE_P();

TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_NoImage) {}

TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_OneImage) {}

TEST_P(ImagePaintTimingDetectorTest, InsertionOrderIsSecondaryRankingKey) {}

TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_TraceEvent_Candidate) {}

TEST_P(ImagePaintTimingDetectorTest,
       LargestImagePaint_TraceEvent_Candidate_Frame) {}

TEST_P(ImagePaintTimingDetectorTest, UpdatePerformanceTiming) {}

TEST_P(ImagePaintTimingDetectorTest, UpdatePerformanceTimingToZero) {}

TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_OpacityZero) {}

TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_VisibilityHidden) {}

TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_DisplayNone) {}

TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_OpacityNonZero) {}

TEST_P(ImagePaintTimingDetectorTest,
       IgnoreImageUntilInvalidatedRectSizeNonZero) {}

TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_Largest) {}

TEST_P(ImagePaintTimingDetectorTest,
       LargestImagePaint_IgnoreThoseOutsideViewport) {}

TEST_P(ImagePaintTimingDetectorTest,
       LargestImagePaint_UpdateOnRemovingTheLastImage) {}

TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_UpdateOnRemoving) {}

TEST_P(ImagePaintTimingDetectorTest,
       LargestImagePaint_NodeRemovedBetweenRegistrationAndInvocation) {}

TEST_P(ImagePaintTimingDetectorTest,
       RemoveRecordFromAllContainersAfterImageRemoval) {}

TEST_P(ImagePaintTimingDetectorTest,
       RemoveRecordFromAllContainersAfterInvisibleImageRemoved) {}

TEST_P(ImagePaintTimingDetectorTest,
       RemoveRecordFromAllContainersAfterBackgroundImageRemoval) {}

TEST_P(ImagePaintTimingDetectorTest,
       RemoveRecordFromAllContainersAfterImageRemovedAndCallbackInvoked) {}

TEST_P(ImagePaintTimingDetectorTest,
       LargestImagePaint_ReattachedNodeNotTreatedAsNew) {}

// This is to prove that a presentation time is assigned only to nodes of the
// frame who register the presentation time. In other words, presentation time A
// should match frame A; presentation time B should match frame B.
TEST_P(ImagePaintTimingDetectorTest,
       MatchPresentationTimeToNodesOfDifferentFrames) {}

TEST_P(ImagePaintTimingDetectorTest,
       LargestImagePaint_UpdateResultWhenLargestChanged) {}

TEST_P(ImagePaintTimingDetectorTest, OnePresentationPromiseForOneFrame) {}

TEST_P(ImagePaintTimingDetectorTest, VideoImage) {}

TEST_P(ImagePaintTimingDetectorTest, VideoImage_ImageNotLoaded) {}

TEST_P(ImagePaintTimingDetectorTest, SVGImage) {}

TEST_P(ImagePaintTimingDetectorTest, BackgroundImage) {}

TEST_P(ImagePaintTimingDetectorTest,
       BackgroundImageAndLayoutImageTrackedDifferently) {}

TEST_P(ImagePaintTimingDetectorTest, BackgroundImage_IgnoreBody) {}

TEST_P(ImagePaintTimingDetectorTest, BackgroundImage_IgnoreHtml) {}

TEST_P(ImagePaintTimingDetectorTest, BackgroundImage_IgnoreGradient) {}

// We put two background images in the same object, and test whether FCP++ can
// find two different images.
TEST_P(ImagePaintTimingDetectorTest, BackgroundImageTrackedDifferently) {}

TEST_P(ImagePaintTimingDetectorTest, DeactivateAfterUserInput) {}

TEST_P(ImagePaintTimingDetectorTest, ContinueAfterKeyUp) {}

TEST_P(ImagePaintTimingDetectorTest, NullTimeNoCrash) {}

TEST_P(ImagePaintTimingDetectorTest, Iframe) {}

TEST_P(ImagePaintTimingDetectorTest, Iframe_ClippedByMainFrameViewport) {}

TEST_P(ImagePaintTimingDetectorTest, Iframe_HalfClippedByMainFrameViewport) {}

TEST_P(ImagePaintTimingDetectorTest, SameSizeShouldNotBeIgnored) {}

TEST_P(ImagePaintTimingDetectorTest, UseIntrinsicSizeIfSmaller_Image) {}

TEST_P(ImagePaintTimingDetectorTest, NotUseIntrinsicSizeIfLarger_Image) {}

TEST_P(ImagePaintTimingDetectorTest,
       UseIntrinsicSizeIfSmaller_BackgroundImage) {}

TEST_P(ImagePaintTimingDetectorTest,
       NotUseIntrinsicSizeIfLarger_BackgroundImage) {}

TEST_P(ImagePaintTimingDetectorTest, OpacityZeroHTML) {}

TEST_P(ImagePaintTimingDetectorTest, OpacityZeroHTML2) {}

TEST_P(ImagePaintTimingDetectorTest, LargestImagePaint_FullViewportImage) {}

#if BUILDFLAG(IS_ANDROID)
// TODO(crbug.com/1353921): This test is flaky on Android. Fix it.
// https://chrome-swarming.appspot.com/task?id=60c68038be22f011
// The first EXPECT_EQ(0u, events.size()) below failed.
#define MAYBE_LargestImagePaint_Detached_Frame
#else
#define MAYBE_LargestImagePaint_Detached_Frame
#endif

TEST_P(ImagePaintTimingDetectorTest, MAYBE_LargestImagePaint_Detached_Frame) {}

class ImagePaintTimingDetectorFencedFrameTest
    : private ScopedFencedFramesForTest,
      public ImagePaintTimingDetectorTest {};

INSTANTIATE_PAINT_TEST_SUITE_P();

TEST_P(ImagePaintTimingDetectorFencedFrameTest, NotReported) {}

class ImagePaintTimingDetectorTransparentPlaceholderImageTest
    : public ImagePaintTimingDetectorTest {};

INSTANTIATE_PAINT_TEST_SUITE_P();

TEST_P(ImagePaintTimingDetectorTransparentPlaceholderImageTest,
       LargestImagePaint) {}

}  // namespace blink