Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / ui / message_center / cocoa / tray_view_controller_unittest.mm
index 6977ece..156f719 100644 (file)
@@ -8,7 +8,7 @@
 #include "base/message_loop/message_loop.h"
 #include "base/run_loop.h"
 #include "base/strings/utf_string_conversions.h"
-#import "ui/base/test/ui_cocoa_test_helper.h"
+#import "ui/gfx/test/ui_cocoa_test_helper.h"
 #include "ui/message_center/fake_notifier_settings_provider.h"
 #include "ui/message_center/message_center.h"
 #include "ui/message_center/message_center_impl.h"
@@ -98,7 +98,10 @@ TEST_F(TrayViewControllerTest, AddRemoveOne) {
   center_->RemoveNotification("1", true);
   [tray_ onMessageCenterTrayChanged];
   EXPECT_EQ(0u, [[view subviews] count]);
-  EXPECT_CGFLOAT_EQ(0, NSHeight([view frame]));
+  // The empty tray is now 100px tall to accommodate
+  // the empty message.
+  EXPECT_CGFLOAT_EQ(message_center::kMinScrollViewHeight,
+                    NSHeight([view frame]));
 }
 
 TEST_F(TrayViewControllerTest, AddThreeClearAll) {
@@ -146,7 +149,10 @@ TEST_F(TrayViewControllerTest, AddThreeClearAll) {
   [tray_ onMessageCenterTrayChanged];
 
   EXPECT_EQ(0u, [[view subviews] count]);
-  EXPECT_CGFLOAT_EQ(0, NSHeight([view frame]));
+  // The empty tray is now 100px tall to accommodate
+  // the empty message.
+  EXPECT_CGFLOAT_EQ(message_center::kMinScrollViewHeight,
+                    NSHeight([view frame]));
 }
 
 TEST_F(TrayViewControllerTest, NoClearAllWhenNoNotifications) {
@@ -244,4 +250,30 @@ TEST_F(TrayViewControllerTest, Settings) {
   EXPECT_EQ(trayHeight, NSHeight([[tray_ view] frame]));
 }
 
+TEST_F(TrayViewControllerTest, EmptyCenter) {
+  EXPECT_FALSE([[tray_ emptyDescription] isHidden]);
+
+  // With no notifications, the divider should be hidden.
+  EXPECT_TRUE([[tray_ divider] isHidden]);
+  EXPECT_TRUE([[tray_ scrollView] isHidden]);
+
+  scoped_ptr<message_center::Notification> notification;
+  notification.reset(new message_center::Notification(
+      message_center::NOTIFICATION_TYPE_SIMPLE,
+      "1",
+      ASCIIToUTF16("First notification"),
+      ASCIIToUTF16("This is a simple test."),
+      gfx::Image(),
+      base::string16(),
+      DummyNotifierId(),
+      message_center::RichNotificationData(),
+      NULL));
+  center_->AddNotification(notification.Pass());
+  [tray_ onMessageCenterTrayChanged];
+
+  EXPECT_FALSE([[tray_ divider] isHidden]);
+  EXPECT_FALSE([[tray_ scrollView] isHidden]);
+  EXPECT_TRUE([[tray_ emptyDescription] isHidden]);
+}
+
 }  // namespace message_center