Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(499)

Unified Diff: ash/system/toast/toast_manager_unittest.cc

Issue 2506583005: Hide dismiss button on toast when doing partial screenshot using stylus tools. (Closed)
Patch Set: Add DCHECK Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/common/system/toast/toast_overlay.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/system/toast/toast_manager_unittest.cc
diff --git a/ash/system/toast/toast_manager_unittest.cc b/ash/system/toast/toast_manager_unittest.cc
index e946930819a66d4d0468c72a041e910975fde25f..4317a4f32e656379bcd8ca9042fab488f22c236e 100644
--- a/ash/system/toast/toast_manager_unittest.cc
+++ b/ash/system/toast/toast_manager_unittest.cc
@@ -54,12 +54,18 @@ class ToastManagerTest : public test::AshTestBase {
return overlay ? overlay->widget_for_testing() : nullptr;
}
+ ToastOverlayButton* GetDismissButton() {
+ ToastOverlay* overlay = GetCurrentOverlay();
+ DCHECK(overlay);
+ return overlay->dismiss_button_for_testing();
+ }
+
base::string16 GetCurrentText() {
ToastOverlay* overlay = GetCurrentOverlay();
return overlay ? overlay->text_ : base::string16();
}
- base::string16 GetCurrentDismissText() {
+ base::Optional<base::string16> GetCurrentDismissText() {
ToastOverlay* overlay = GetCurrentOverlay();
return overlay ? overlay->dismiss_text_ : base::string16();
}
@@ -77,12 +83,17 @@ class ToastManagerTest : public test::AshTestBase {
return id;
}
- std::string ShowToastWithDismiss(const std::string& text,
- int32_t duration,
- const std::string& dismiss_text) {
+ std::string ShowToastWithDismiss(
+ const std::string& text,
+ int32_t duration,
+ const base::Optional<std::string>& dismiss_text) {
+ base::Optional<base::string16> localized_dismiss;
+ if (dismiss_text.has_value())
+ localized_dismiss = base::ASCIIToUTF16(dismiss_text.value());
+
std::string id = "TOAST_ID_" + base::UintToString(serial_++);
- manager()->Show(ToastData(id, base::ASCIIToUTF16(text), duration,
- base::ASCIIToUTF16(dismiss_text)));
+ manager()->Show(
+ ToastData(id, base::ASCIIToUTF16(text), duration, localized_dismiss));
return id;
}
@@ -137,6 +148,12 @@ TEST_F(ToastManagerTest, ShowAndCloseManuallyDuringAnimation) {
EXPECT_TRUE(GetCurrentOverlay() != nullptr);
}
+TEST_F(ToastManagerTest, NullMessageHasNoDismissButton) {
+ ShowToastWithDismiss("DUMMY", 10, base::Optional<std::string>());
+ base::RunLoop().RunUntilIdle();
+ EXPECT_FALSE(GetDismissButton());
+}
+
TEST_F(ToastManagerTest, QueueMessage) {
ShowToast("DUMMY1", 10);
ShowToast("DUMMY2", 10);
« no previous file with comments | « ash/common/system/toast/toast_overlay.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698