chromium/chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer_unittest.cc

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

#include "chrome/browser/page_load_metrics/observers/from_gws_page_load_metrics_observer.h"

#include <vector>

#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "build/build_config.h"
#include "chrome/browser/page_load_metrics/observers/page_load_metrics_observer_test_harness.h"
#include "components/page_load_metrics/browser/metrics_web_contents_observer.h"
#include "components/page_load_metrics/browser/page_load_metrics_util.h"
#include "components/page_load_metrics/browser/page_load_tracker.h"
#include "components/page_load_metrics/common/test/page_load_metrics_test_util.h"
#include "content/public/browser/web_contents.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "third_party/blink/public/common/input/web_mouse_event.h"
#include "url/gurl.h"

namespace {

constexpr char kExampleUrl[] =;
constexpr char kExampleUrl2[] =;
constexpr char kGoogleSearchResultsUrl[] =;
constexpr char kGoogleSearchResultsVideoUrl[] =;

}  // namespace

class FromGWSPageLoadMetricsObserverTest
    : public page_load_metrics::PageLoadMetricsObserverTestHarness {};

class FromGWSPageLoadMetricsLoggerTest : public testing::Test {};

TEST_F(FromGWSPageLoadMetricsObserverTest, NoMetrics) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, NoPreviousCommittedUrl) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, NonSearchPreviousCommittedUrl) {}

TEST_F(FromGWSPageLoadMetricsObserverTest,
       GoogleNonSearchPreviousCommittedUrl1) {}

TEST_F(FromGWSPageLoadMetricsObserverTest,
       GoogleNonSearchPreviousCommittedUrl2) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, SearchPreviousCommittedUrl1) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, SearchPreviousCommittedUrl2) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, SearchPreviousCommittedUrl3) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, SearchPreviousCommittedUrl4) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, SearchPreviousCommittedUrlToMaps1) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, SearchPreviousCommittedUrlToMaps2) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, SearchPreviousCommittedUrlToMaps3) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, GoogleSearchModeLogged) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, SearchToNonSearchToOtherPage) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, SearchToNonSearchToSearch) {}

TEST_F(FromGWSPageLoadMetricsObserverTest,
       SearchToNonSearchToSearchToNonSearch) {}

TEST_F(FromGWSPageLoadMetricsObserverTest,
       SearchToNonSearchToSearchToNonSearchBackgrounded) {}

TEST_F(FromGWSPageLoadMetricsObserverTest,
       SearchRedirectorPreviousCommittedUrl) {}

TEST_F(FromGWSPageLoadMetricsObserverTest,
       NonSearchRedirectorPreviousCommittedUrl) {}

TEST_F(FromGWSPageLoadMetricsObserverTest,
       SearchPreviousCommittedUrlBackgroundLater) {}

// Disabled due to flakiness: https://crbug.com/1092018
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_NewNavigationBeforeCommit
#else
#define MAYBE_NewNavigationBeforeCommit
#endif
TEST_F(FromGWSPageLoadMetricsObserverTest, MAYBE_NewNavigationBeforeCommit) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, NewNavigationBeforePaint) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, StopBeforeCommit) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, StopBeforeCommitNonSearch) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, StopBeforeCommitSearchToSearch) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, StopBeforePaint) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, StopBeforeCommitAndBeforePaint) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, CloseBeforeCommit) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, CloseBeforePaint) {}

TEST_F(FromGWSPageLoadMetricsObserverTest,
       AbortCloseBeforeCommitAndBeforePaint) {}

TEST_F(FromGWSPageLoadMetricsObserverTest,
       AbortStopBeforeCommitAndCloseBeforePaint) {}

// TODO(bmcquade, csharrison): add tests for reload, back/forward, and other
// aborts.

TEST_F(FromGWSPageLoadMetricsObserverTest, NoAbortNewNavigationFromAboutURL) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, NoAbortNewNavigationAfterPaint) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, NewNavigationBeforeInteraction) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, StopBeforeInteraction) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, CloseBeforeInteraction) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, CloseBeforePaintAndInteraction) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, CloseAfterInteraction) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, CommittedIntent) {}

TEST_F(FromGWSPageLoadMetricsObserverTest, ProvisionalIntent) {}

// Fixture for testing side panel interactions with FromGWS metrics.
class FromGWSPageLoadMetricsObserverWithSidePanelTest
    : public FromGWSPageLoadMetricsObserverTest {};

// Ensures link initiated side panel navigations from Google SRPs report GWS
// metrics, even if the initially committed page in the tab frame is a
// non-Google search page.
TEST_F(FromGWSPageLoadMetricsObserverWithSidePanelTest,
       NonSearchPreviousCommittedUrl) {}

// Ensures link initiated side panel navigations from Google SRPs log expected
// regular and side panel specific GWS metrics.
TEST_F(FromGWSPageLoadMetricsObserverWithSidePanelTest,
       RecordsRegularAndSidePanelSpecificMetrics) {}

// If initiated from the side panel hosting a Google SRP ensure we capture the
// search mode of the side panel's Google SRP.
TEST_F(FromGWSPageLoadMetricsObserverWithSidePanelTest,
       GoogleSearchModeLogged) {}

// Test that we do not report visible metrics if the tab has been backgrounded.
TEST_F(FromGWSPageLoadMetricsObserverWithSidePanelTest,
       SidePanelNavigationBackgrounded) {}

// If a side panel initiated navigation is not a Google SRP or is not link
// initiated it should not report GWS metrics.
TEST_F(FromGWSPageLoadMetricsObserverWithSidePanelTest,
       DoesNotRecordNonGWSAndNonLinkInitiatedNavigations) {}

TEST_F(FromGWSPageLoadMetricsLoggerTest, Basic) {}

TEST_F(FromGWSPageLoadMetricsLoggerTest, NoPreviousPage) {}

TEST_F(FromGWSPageLoadMetricsLoggerTest, NavigationNotInitiatedViaLink) {}

TEST_F(FromGWSPageLoadMetricsLoggerTest, ProvisionalFromGWS) {}

TEST_F(FromGWSPageLoadMetricsLoggerTest, ProvisionalNotFromGWS) {}

TEST_F(FromGWSPageLoadMetricsLoggerTest, ProvisionalIgnoredAfterCommit1) {}

TEST_F(FromGWSPageLoadMetricsLoggerTest, ProvisionalIgnoredAfterCommit2) {}

TEST_F(FromGWSPageLoadMetricsLoggerTest, NavigationFromSearch) {}

TEST_F(FromGWSPageLoadMetricsLoggerTest, NavigationToSearchHostname) {}

TEST_F(FromGWSPageLoadMetricsLoggerTest, NavigationFromSearchRedirector) {}

FromGWSPageLoadMetricsLoggerWithSidePanelTest;

TEST_F(FromGWSPageLoadMetricsLoggerWithSidePanelTest,
       InitiatedFromSidePanelWithGoogleSRP) {}

TEST_F(FromGWSPageLoadMetricsLoggerWithSidePanelTest,
       InitiatedFromSidePanelWithNonGooglePage) {}

TEST_F(FromGWSPageLoadMetricsLoggerWithSidePanelTest,
       InitiatedFromSidePanelWithGoogleSRPNotLinkInitiated) {}