chromium/chrome/browser/printing/print_preview_dialog_controller_browsertest.cc

// Copyright 2012 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/printing/print_preview_dialog_controller.h"

#include <memory>

#include "base/command_line.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/run_loop.h"
#include "base/strings/utf_string_conversions.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "build/build_config.h"
#include "chrome/browser/plugins/chrome_plugin_service_filter.h"
#include "chrome/browser/plugins/plugin_prefs.h"
#include "chrome/browser/printing/print_view_manager.h"
#include "chrome/browser/printing/test_print_preview_dialog_cloned_observer.h"
#include "chrome/browser/printing/test_print_view_manager_for_request_preview.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/task_manager/mock_web_contents_task_manager.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/common/chrome_content_client.h"
#include "chrome/common/url_constants.h"
#include "chrome/grit/generated_resources.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/plugin_service.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/common/webplugininfo.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/scoped_accessibility_mode_override.h"
#include "content/public/test/test_utils.h"
#include "ipc/ipc_message_macros.h"
#include "ui/accessibility/ax_mode.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/ui_base_switches.h"
#include "url/gurl.h"

WebContents;
WebContentsObserver;

namespace {

void PluginsLoadedCallback(
    base::OnceClosure quit_closure,
    const std::vector<content::WebPluginInfo>& /* info */) {}

void CheckPdfPluginForRenderFrame(content::RenderFrameHost* frame) {}

}  // namespace

class PrintPreviewDialogControllerBrowserTest : public InProcessBrowserTest {};

// Test to verify that when a initiator navigates, we can create a new preview
// dialog for the new tab contents.
// TODO(crbug.com/40251696): Test is flaky on Mac
#if BUILDFLAG(IS_MAC)
#define MAYBE_NavigateFromInitiatorTab
#else
#define MAYBE_NavigateFromInitiatorTab
#endif
IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest,
                       MAYBE_NavigateFromInitiatorTab) {}

// Test to verify that after reloading the initiator, it creates a new print
// preview dialog.
// TODO(crbug.com/40251696): Test is flaky on Mac
#if BUILDFLAG(IS_MAC)
#define MAYBE_ReloadInitiatorTab
#else
#define MAYBE_ReloadInitiatorTab
#endif
IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest,
                       MAYBE_ReloadInitiatorTab) {}

// Test to verify that after print preview works even when the PDF plugin is
// disabled for webpages.
// TODO(crbug.com/40884297): Flaky on Mac12 Test.
#if BUILDFLAG(IS_MAC)
#define MAYBE_PdfPluginDisabled
#else
#define MAYBE_PdfPluginDisabled
#endif
IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest,
                       MAYBE_PdfPluginDisabled) {}

namespace {

std::u16string GetExpectedPrefix() {}

const std::vector<raw_ptr<task_manager::WebContentsTag, VectorExperimental>>&
GetTrackedTags() {}

}  // namespace

// TODO(crbug.com/40879071): Flaky on macos12 builds.
#if BUILDFLAG(IS_MAC)
#define MAYBE_TaskManagementTest
#else
#define MAYBE_TaskManagementTest
#endif
IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest,
                       MAYBE_TaskManagementTest) {}

IN_PROC_BROWSER_TEST_F(PrintPreviewDialogControllerBrowserTest,
                       PrintPreviewPdfAccessibility) {}