chromium/chrome/browser/page_load_metrics/integration_tests/soft_navigation_metrics_browsertest.cc

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

#include <cstdint>
#include <string_view>
#include <vector>

#include "base/json/json_reader.h"
#include "base/test/scoped_feature_list.h"
#include "base/test/trace_event_analyzer.h"
#include "base/values.h"
#include "cc/base/switches.h"
#include "chrome/browser/page_load_metrics/integration_tests/metric_integration_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/page_load_metrics/browser/page_load_metrics_test_waiter.h"
#include "components/page_load_metrics/browser/page_load_metrics_util.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/hit_test_region_observer.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "third_party/blink/public/common/performance/largest_contentful_paint_type.h"
#include "third_party/blink/public/common/switches.h"
#include "ui/gfx/geometry/point_conversions.h"

namespace {
class SoftNavigationTest : public MetricIntegrationTest,
                           public testing::WithParamInterface<bool> {};

// TODO(crbug.com/40924160): Investigate timeout issue on linux-lacros-rel and
// linux-wayland when retrieving web exposed soft nav lcp entries using the
// EvalJs method.
#if BUILDFLAG(IS_CHROMEOS_LACROS) || BUILDFLAG(IS_LINUX)
#define MAYBE_LargestContentfulPaint
#else
#define MAYBE_LargestContentfulPaint
#endif

IN_PROC_BROWSER_TEST_P(SoftNavigationTest, MAYBE_LargestContentfulPaint) {}

// TODO(crbug.com/334416161): Re-enable this test.
#if BUILDFLAG(IS_WIN)
#define MAYBE_NoSoftNavigation
#else
#define MAYBE_NoSoftNavigation
#endif
IN_PROC_BROWSER_TEST_P(SoftNavigationTest, MAYBE_NoSoftNavigation) {}

INSTANTIATE_TEST_SUITE_P();

// TODO(crbug.com/338061920, crbug.com/333963663): Flaky on Win.
#if BUILDFLAG(IS_WIN)
#define MAYBE_INP_ClickWithPresentation
#else
#define MAYBE_INP_ClickWithPresentation
#endif  //  BUILDFLAG(IS_WIN)
IN_PROC_BROWSER_TEST_P(SoftNavigationTest, MAYBE_INP_ClickWithPresentation) {}

// TODO(crbug.com/338061920): Flaky on win-asan.
#if BUILDFLAG(IS_WIN) && defined(ADDRESS_SANITIZER)
#define MAYBE_LayoutShift
#else
#define MAYBE_LayoutShift
#endif  //  BUILDFLAG(IS_WIN) && defined(ADDRESS_SANITIZER)
IN_PROC_BROWSER_TEST_P(SoftNavigationTest, MAYBE_LayoutShift) {}
}  // namespace