chromium/chrome/browser/ui/global_error/global_error_service_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/ui/global_error/global_error_service.h"

#include <memory>

#include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/global_error/global_error.h"
#include "chrome/browser/ui/global_error/global_error_bubble_view_base.h"
#include "chrome/browser/ui/global_error/global_error_service_factory.h"
#include "chrome/test/base/in_process_browser_test.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/test_utils.h"

namespace {

// An error that has a bubble view.
class BubbleViewError final : public GlobalErrorWithStandardBubble {};

} // namespace

class GlobalErrorServiceBrowserTest : public InProcessBrowserTest {};

// Test that showing a error with a bubble view works.
IN_PROC_BROWSER_TEST_F(GlobalErrorServiceBrowserTest, ShowBubbleView) {}

// Test that GlobalErrorBubbleViewBase::CloseBubbleView correctly closes the
// bubble view.
IN_PROC_BROWSER_TEST_F(GlobalErrorServiceBrowserTest, CloseBubbleView) {}

// Test that bubble is silently dismissed if it is showing when the GlobalError
// instance is removed from the profile.
//
// This uses the deprecated "unowned" API to the GlobalErrorService to maintain
// coverage. When those calls are eventually removed (http://crbug.com/673578)
// these uses should be switched to the non-deprecated API.
// TODO(crbug.com/41485585): Flaky on asan lacros.
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_BubbleViewDismissedOnRemove
#else
#define MAYBE_BubbleViewDismissedOnRemove
#endif
IN_PROC_BROWSER_TEST_F(GlobalErrorServiceBrowserTest,
                       MAYBE_BubbleViewDismissedOnRemove) {}