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

Unified Diff: ui/message_center/views/message_popup_collection_unittest.cc

Issue 1913433004: Supporting shrinking/enlarging for notifications (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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
Index: ui/message_center/views/message_popup_collection_unittest.cc
diff --git a/ui/message_center/views/message_popup_collection_unittest.cc b/ui/message_center/views/message_popup_collection_unittest.cc
index 75fc26968ed8a140247929e28844fb179dea5213..a2b46836968db90bcaec4b94bc7399a46edab32f 100644
--- a/ui/message_center/views/message_popup_collection_unittest.cc
+++ b/ui/message_center/views/message_popup_collection_unittest.cc
@@ -7,6 +7,7 @@
#include <stddef.h>
#include <list>
+#include <memory>
Jun Mukai 2016/05/04 17:00:09 Is this necessary?
dyaroshev 2016/05/05 14:13:19 Done.
#include <utility>
#include "base/message_loop/message_loop.h"
@@ -26,6 +27,22 @@
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"
+namespace {
+
+std::unique_ptr<message_center::Notification> CreateTestNotification(
+ std::string id,
+ std::string text) {
+ return base::WrapUnique(new message_center::Notification(
+ message_center::NOTIFICATION_TYPE_BASE_FORMAT, id,
+ base::UTF8ToUTF16("test title"), base::ASCIIToUTF16(text), gfx::Image(),
+ base::string16() /* display_source */, GURL(),
+ message_center::NotifierId(message_center::NotifierId::APPLICATION, id),
+ message_center::RichNotificationData(),
+ new message_center::NotificationDelegate()));
+}
+
+} // namespace
+
namespace message_center {
namespace test {
@@ -520,5 +537,47 @@ TEST_F(MessagePopupCollectionTest, CloseNonClosableNotifications) {
#endif // defined(OS_CHROMEOS)
+// When notifications were displayed on top, change of notification
+// size didn't affect corresponding widget.
+TEST_F(MessagePopupCollectionTest, ChangingNotificationSize) {
+ // Simulate a taskbar at the top.
+ SetDisplayInfo(gfx::Rect(0, 10, 600, 390), // Work-area.
+ gfx::Rect(0, 0, 600, 400)); // Display-bounds.
+
+ std::string id = AddNotification();
Jun Mukai 2016/05/04 17:00:09 const std::string&
dyaroshev 2016/05/05 14:13:19 not apliable anymore
+ WaitForTransitionsDone();
+
+ ToastContentsView* toast = GetToast(id);
+ ASSERT_TRUE(toast);
+
+ struct {
+ std::string name;
+ std::string text;
+ } test_cases[] = {
+ {"shrinking", ""}, {"enlarging", "abc\ndef\nghk\n"},
+ };
stevenjb 2016/05/04 23:39:02 Should we also test a smaller notification after t
dyaroshev 2016/05/05 14:13:19 Done.
+
+ for (const auto& test_case : test_cases) {
+ EXPECT_EQ(toast->bounds(), GetWidget(id)->GetWindowBoundsInScreen())
+ << test_case.name << " before update";
+
+ MessageCenter::Get()->UpdateNotification(
+ id, CreateTestNotification(id, test_case.text));
+ EXPECT_EQ(toast->bounds(), GetWidget(id)->GetWindowBoundsInScreen())
+ << test_case.name << " before transition";
+
+ WaitForTransitionsDone();
+ EXPECT_EQ(toast->bounds(), GetWidget(id)->GetWindowBoundsInScreen())
+ << test_case.name << " after transition";
+ }
+
+ CloseAllToasts();
+ WaitForTransitionsDone();
+
+ // Restore simulated taskbar position to bottom.
+ SetDisplayInfo(gfx::Rect(0, 0, 600, 390), // Work-area.
+ gfx::Rect(0, 0, 600, 400)); // Display-bounds.
Jun Mukai 2016/05/04 17:00:09 I believe you don't have to reset it. If necessary
dyaroshev 2016/05/05 14:13:19 I removed it in other tests too.
+}
+
} // namespace test
} // namespace message_center
« no previous file with comments | « no previous file | ui/message_center/views/toast_contents_view.h » ('j') | ui/message_center/views/toast_contents_view.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698