chromium/chrome/browser/resource_coordinator/tab_helper_browsertest.cc

// Copyright 2021 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/resource_coordinator/tab_helper.h"

#include "base/functional/bind.h"
#include "chrome/browser/resource_coordinator/tab_load_tracker.h"
#include "chrome/browser/resource_coordinator/tab_load_tracker_test_support.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/prerender_test_util.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

namespace content {
class WebContents;
}

namespace resource_coordinator {
namespace {

class MockLoadingStateHelper : public TabLoadTracker::Observer {};

}  // namespace

class TabHelperBrowserTest : public InProcessBrowserTest {};

// Tests that `ukm_source_id_` from ResourceCoordinatorTabHelper is updated and
// used only with the active page loading. Since `ukm_source_id_` is used in
// TabManagerStatsCollector::OnTabIsLoaded() triggered by
// OnLoadingStateChange(), this test checks that OnLoadingStateChange() is not
// called in prerendering.
IN_PROC_BROWSER_TEST_F(TabHelperBrowserTest,
                       TabHelperBrowserTestInPrerendering) {}

}  // namespace resource_coordinator