From 7cb01c0282e24995854dc906089c454ef1a1fd2c Mon Sep 17 00:00:00 2001 From: brave-builds Date: Thu, 12 Dec 2024 21:51:41 +0000 Subject: [PATCH] Uplift of #26998 (squashed) to beta --- .../browser/ui/toasts/toast_controller.cc | 3 ++- .../ui/toasts/toast_controller_unittest.cc | 17 ++++++++++++++++- test/filters/browser_tests.filter | 3 ++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/chromium_src/chrome/browser/ui/toasts/toast_controller.cc b/chromium_src/chrome/browser/ui/toasts/toast_controller.cc index cbcdc0a85ec3..19f5504d354c 100644 --- a/chromium_src/chrome/browser/ui/toasts/toast_controller.cc +++ b/chromium_src/chrome/browser/ui/toasts/toast_controller.cc @@ -11,7 +11,8 @@ bool ToastController::MaybeShowToast(ToastParams params) { if (params.toast_id == ToastId::kLinkCopied || - params.toast_id == ToastId::kImageCopied) { + params.toast_id == ToastId::kImageCopied || + params.toast_id == ToastId::kAddedToReadingList) { return false; } return MaybeShowToast_ChromiumImpl(std::move(params)); diff --git a/chromium_src/chrome/browser/ui/toasts/toast_controller_unittest.cc b/chromium_src/chrome/browser/ui/toasts/toast_controller_unittest.cc index cf048a203519..08eb7fa72ca2 100644 --- a/chromium_src/chrome/browser/ui/toasts/toast_controller_unittest.cc +++ b/chromium_src/chrome/browser/ui/toasts/toast_controller_unittest.cc @@ -9,7 +9,7 @@ // test toasts, but those are the two notifications we want to hide so redefine // their identifiers here so we can continue to run the upstream tests. #define kLinkCopied kLinkToHighlightCopied -#define kImageCopied kAddedToReadingList +#define kImageCopied kClearBrowsingData #include "src/chrome/browser/ui/toasts/toast_controller_unittest.cc" #undef kImageCopied #undef kLinkCopied @@ -41,3 +41,18 @@ TEST_F(ToastControllerUnitTest, NeverShowToastForImageCopied) { EXPECT_FALSE(controller->MaybeShowToast(ToastParams(ToastId::kImageCopied))); EXPECT_FALSE(controller->IsShowingToast()); } + +TEST_F(ToastControllerUnitTest, NeverShowToastForAddedToReadingList) { + ToastRegistry* const registry = toast_registry(); + registry->RegisterToast( + ToastId::kAddedToReadingList, + ToastSpecification::Builder(vector_icons::kEmailIcon, 0).Build()); + + auto controller = std::make_unique(registry); + + EXPECT_FALSE(controller->IsShowingToast()); + EXPECT_TRUE(controller->CanShowToast(ToastId::kAddedToReadingList)); + EXPECT_FALSE( + controller->MaybeShowToast(ToastParams(ToastId::kAddedToReadingList))); + EXPECT_FALSE(controller->IsShowingToast()); +} diff --git a/test/filters/browser_tests.filter b/test/filters/browser_tests.filter index ca98e35d93d3..fd177907a373 100644 --- a/test/filters/browser_tests.filter +++ b/test/filters/browser_tests.filter @@ -1939,9 +1939,10 @@ -ComponentManagerUpdateCheckBrowserTest.RegisterAndUnregisterTranslateKitLanguagePackComponent -ComponentManagerUpdateCheckBrowserTest.RegisterTranslateKitComponent -# We disable the ImageCopied/LinkCopied toast notifications +# We disable the AddToReadingList/ImageCopied/LinkCopied toast notifications -All/ContextMenuBrowserTest.ShowsToastOnImageCopied/* -All/ContextMenuBrowserTest.ShowsToastOnLinkCopied/* +-BrowserCommandsTest.AddingToReadingListOpensToast -BrowserCommandsTest.CopyingUrlOpensToast # Tests below this point have not been diagnosed or had issues created yet.