#include "chrome/browser/ui/webui/top_chrome/webui_contents_preload_manager.h"
#include <map>
#include "base/containers/span.h"
#include "base/metrics/statistics_recorder.h"
#include "base/run_loop.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/page_load_metrics/observers/non_tab_webui_page_load_metrics_observer.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_command_controller.h"
#include "chrome/browser/ui/ui_features.h"
#include "chrome/browser/ui/webui/top_chrome/preload_candidate_selector.h"
#include "chrome/browser/ui/webui/top_chrome/top_chrome_web_ui_controller.h"
#include "chrome/browser/ui/webui/top_chrome/top_chrome_webui_config.h"
#include "chrome/browser/ui/webui/top_chrome/webui_contents_preload_manager_test_api.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/scoped_web_ui_controller_factory_registration.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/url_loader_interceptor.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/views/controls/webview/webview.h"
#include "ui/views/widget/widget.h"
#include "url/gurl.h"
_;
Return;
namespace {
void WaitForHistogram(const std::string& histogram_name) { … }
int GetCommandIdForURL(GURL webui_url) { … }
PreloadModeName;
std::vector<PreloadModeName> GetAllPreloadManagerModes() { … }
class MockPreloadCandidateSelector : public webui::PreloadCandidateSelector { … };
}
class WebUIContentsPreloadManagerBrowserTestBase : public InProcessBrowserTest { … };
class WebUIContentsPreloadManagerBrowserSmokeTest
: public WebUIContentsPreloadManagerBrowserTestBase,
public ::testing::WithParamInterface<PreloadModeName> { … };
IN_PROC_BROWSER_TEST_P(WebUIContentsPreloadManagerBrowserSmokeTest,
TriggerPreloadedUIs) { … }
INSTANTIATE_TEST_SUITE_P(…);
namespace {
constexpr char kTestWebUIHost[] = …;
constexpr char kTestWebUIOrigin[] = …;
constexpr char kTestWebUIURL[] = …;
class TestTopChromeWebUIController : public TopChromeWebUIController { … };
class TestTopChromeWebUIConfig
: public DefaultTopChromeWebUIConfig<TestTopChromeWebUIController> { … };
}
class WebUIContentsPreloadManagerPageLoadMetricsTest
: public WebUIContentsPreloadManagerBrowserTestBase { … };
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_RequestToFCP …
#else
#define MAYBE_RequestToFCP …
#endif
IN_PROC_BROWSER_TEST_F(WebUIContentsPreloadManagerPageLoadMetricsTest,
MAYBE_RequestToFCP) { … }
class WebUIContentsPreloadManagerHistoryClusterMetricTest
: public WebUIContentsPreloadManagerBrowserTestBase { … };
IN_PROC_BROWSER_TEST_F(WebUIContentsPreloadManagerHistoryClusterMetricTest,
PreloadButNeverShow) { … }
IN_PROC_BROWSER_TEST_F(WebUIContentsPreloadManagerHistoryClusterMetricTest,
PreloadAndShow) { … }