chromium/chrome/browser/extensions/api/notifications/notifications_apitest.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 <memory>

#include "base/containers/circular_deque.h"
#include "base/run_loop.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/apps/app_service/app_launch_params.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/apps/app_service/browser_app_launcher.h"
#include "chrome/browser/apps/platform_apps/app_browsertest_util.h"
#include "chrome/browser/extensions/api/notifications/extension_notification_display_helper.h"
#include "chrome/browser/extensions/api/notifications/extension_notification_display_helper_factory.h"
#include "chrome/browser/extensions/api/notifications/extension_notification_handler.h"
#include "chrome/browser/extensions/api/notifications/notifications_api.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/browser/notifications/notification_display_service_tester.h"
#include "chrome/browser/notifications/notification_handler.h"
#include "chrome/browser/notifications/notifier_state_tracker.h"
#include "chrome/browser/notifications/notifier_state_tracker_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "components/services/app_service/public/cpp/app_launch_util.h"
#include "content/public/test/browser_test.h"
#include "extensions/browser/api/test/test_api.h"
#include "extensions/browser/api_test_utils.h"
#include "extensions/browser/app_window/app_window.h"
#include "extensions/browser/app_window/app_window_registry.h"
#include "extensions/browser/app_window/native_app_window.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_host_test_helper.h"
#include "extensions/common/extension_builder.h"
#include "extensions/common/features/feature.h"
#include "extensions/common/mojom/view_type.mojom.h"
#include "extensions/test/extension_test_message_listener.h"
#include "extensions/test/result_catcher.h"
#include "ui/message_center/public/cpp/notification.h"
#include "ui/message_center/public/cpp/notifier_id.h"

#if BUILDFLAG(IS_MAC)
#include "base/mac/mac_util.h"
#endif

ContextType;
AppWindow;
AppWindowRegistry;
Extension;
ExtensionNotificationDisplayHelper;
ExtensionNotificationDisplayHelperFactory;
ResultCatcher;

utils;

namespace {

enum class WindowState {};

class NotificationsApiTest : public extensions::ExtensionApiTest {};

// TODO(crbug.com/40170747): We should merge this class with the base
// class once the issues mentioned in the bug are resolved.
class NotificationsApiTestWithBackgroundType
    : public NotificationsApiTest,
      public testing::WithParamInterface<ContextType> {};

}  // namespace

INSTANTIATE_TEST_SUITE_P();
INSTANTIATE_TEST_SUITE_P();

IN_PROC_BROWSER_TEST_P(NotificationsApiTestWithBackgroundType, TestBasicUsage) {}

// Flaky on TSan, see crbug.com/1304777.
#if BUILDFLAG(IS_LINUX) && defined(THREAD_SANITIZER)
#define MAYBE_TestEvents
#else
#define MAYBE_TestEvents
#endif
IN_PROC_BROWSER_TEST_P(NotificationsApiTestWithBackgroundType,
                       MAYBE_TestEvents) {}

IN_PROC_BROWSER_TEST_P(NotificationsApiTestWithBackgroundType, TestCSP) {}

// Native notifications don't support (or use) observers.
#if !BUILDFLAG(IS_MAC)
IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestByUser) {}
#endif  // !BUILDFLAG(IS_MAC)

IN_PROC_BROWSER_TEST_P(NotificationsApiTestWithBackgroundType,
                       TestPartialUpdate) {}

IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestGetPermissionLevel) {}

IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestOnPermissionLevelChanged) {}

// Native notifications don't support (nor use) observers.
#if !BUILDFLAG(IS_MAC)
IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestUserGesture) {}
#endif  // !BUILDFLAG(IS_MAC)

IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestRequireInteraction) {}

IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestShouldDisplayNormal) {}

// Full screen related tests don't run on Mac as native notifications full
// screen decisions are done by the OS directly.
#if !BUILDFLAG(IS_MAC)
IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestShouldDisplayFullscreen) {}

// The Fake OSX fullscreen window doesn't like drawing a second fullscreen
// window when another is visible.
IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestShouldDisplayMultiFullscreen) {}

// Verify that a notification is actually displayed when the app window that
// creates it is fullscreen.
IN_PROC_BROWSER_TEST_F(NotificationsApiTest,
                       TestShouldDisplayPopupNotification) {}
#endif  // !BUILDFLAG(IS_MAC)

IN_PROC_BROWSER_TEST_F(NotificationsApiTest, TestSmallImage) {}