chromium/chrome/browser/ui/global_error/global_error_browsertest.cc

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

#include <memory>

#include "base/files/file_util.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/path_service.h"
#include "base/run_loop.h"
#include "base/scoped_observation.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/extensions/extension_disabled_ui.h"
#include "chrome/browser/extensions/extension_error_controller.h"
#include "chrome/browser/extensions/extension_error_ui_default.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/external_install_error.h"
#include "chrome/browser/extensions/test_blocklist.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/recovery/recovery_install_global_error.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/global_error/global_error_observer.h"
#include "chrome/browser/ui/global_error/global_error_service.h"
#include "chrome/browser/ui/global_error/global_error_service_factory.h"
#include "chrome/browser/ui/test/test_browser_dialog.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/pref_names.h"
#include "components/crx_file/crx_verifier.h"
#include "content/public/browser/browser_task_traits.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/extension_creator.h"
#include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/extension_system.h"
#include "extensions/browser/mock_external_provider.h"
#include "extensions/browser/sandboxed_unpacker.h"
#include "extensions/common/api/extension_action/action_info.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/feature_switch.h"

namespace {

// Shows the first GlobalError with associated UI associated with |browser|.
void ShowPendingError(Browser* browser) {}

// Packs an extension from the extensions test data folder into a crx.
base::FilePath PackCRXInTempDir(base::ScopedTempDir* temp_dir,
                                const char* extension_folder,
                                const char* pem_file) {}

// Helper to wait for a global error to be added. To stop waiting, the global
// error must have a bubble view.
class GlobalErrorWaiter : public GlobalErrorObserver {};

}  // namespace

class GlobalErrorBubbleTest : public DialogBrowserTest {};

void GlobalErrorBubbleTest::ShowUi(const std::string& name) {}

IN_PROC_BROWSER_TEST_F(GlobalErrorBubbleTest,
                       InvokeUi_ExtensionDisabledGlobalError) {}

IN_PROC_BROWSER_TEST_F(GlobalErrorBubbleTest,
                       InvokeUi_ExtensionDisabledGlobalErrorRemote) {}

// This shows a non-persistent dialog during a RunLoop::RunUntilIdle(), so it's
// not possible to guarantee that events to dismiss the dialog are not processed
// as well. Disable by default to prevent flakiness in browser_tests.
IN_PROC_BROWSER_TEST_F(GlobalErrorBubbleTest,
                       DISABLED_InvokeUi_ExtensionGlobalError) {}

IN_PROC_BROWSER_TEST_F(GlobalErrorBubbleTest,
                       InvokeUi_ExternalInstallBubbleAlert) {}

// RecoveryInstallGlobalError only exists on Windows and Mac.
#if BUILDFLAG(IS_WIN) || BUILDFLAG(IS_MAC)
IN_PROC_BROWSER_TEST_F(GlobalErrorBubbleTest,
                       InvokeUi_RecoveryInstallGlobalError) {
  ShowAndVerifyUi();
}
#endif