| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/ui/cocoa/notifications/message_center_tray_bridge.h" | 5 #import "chrome/browser/ui/cocoa/notifications/message_center_tray_bridge.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 } | 31 } |
| 32 | 32 |
| 33 MCStatusItemView* status_item() { return bridge_->status_item_view_.get(); } | 33 MCStatusItemView* status_item() { return bridge_->status_item_view_.get(); } |
| 34 | 34 |
| 35 protected: | 35 protected: |
| 36 base::MessageLoop message_loop_; | 36 base::MessageLoop message_loop_; |
| 37 message_center::MessageCenter* center_; // Weak, global. | 37 message_center::MessageCenter* center_; // Weak, global. |
| 38 scoped_ptr<MessageCenterTrayBridge> bridge_; | 38 scoped_ptr<MessageCenterTrayBridge> bridge_; |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 TEST_F(MessageCenterTrayBridgeTest, StatusItemOnlyWithNotifications) { | 41 TEST_F(MessageCenterTrayBridgeTest, StatusItemOnlyAfterFirstNotification) { |
| 42 EXPECT_FALSE(status_item()); | 42 EXPECT_FALSE(status_item()); |
| 43 | 43 |
| 44 message_center::RichNotificationData data; | 44 message_center::RichNotificationData data; |
| 45 data.priority = -1; | 45 data.priority = -1; |
| 46 scoped_ptr<message_center::Notification> notification( | 46 scoped_ptr<message_center::Notification> notification( |
| 47 new message_center::Notification( | 47 new message_center::Notification( |
| 48 message_center::NOTIFICATION_TYPE_SIMPLE, | 48 message_center::NOTIFICATION_TYPE_SIMPLE, |
| 49 "1", | 49 "1", |
| 50 ASCIIToUTF16("First notification"), | 50 ASCIIToUTF16("First notification"), |
| 51 ASCIIToUTF16("This is a simple test."), | 51 ASCIIToUTF16("This is a simple test."), |
| 52 gfx::Image(), | 52 gfx::Image(), |
| 53 string16(), | 53 string16(), |
| 54 std::string(), | 54 std::string(), |
| 55 data, | 55 data, |
| 56 NULL)); | 56 NULL)); |
| 57 center_->AddNotification(notification.Pass()); | 57 center_->AddNotification(notification.Pass()); |
| 58 | 58 |
| 59 base::RunLoop().RunUntilIdle(); | 59 base::RunLoop().RunUntilIdle(); |
| 60 | 60 |
| 61 EXPECT_TRUE(status_item()); | 61 EXPECT_TRUE(status_item()); |
| 62 EXPECT_EQ(1u, [status_item() unreadCount]); | 62 EXPECT_EQ(1u, [status_item() unreadCount]); |
| 63 | 63 |
| 64 center_->RemoveNotification("1", /*by_user=*/true); | 64 center_->RemoveNotification("1", /*by_user=*/true); |
| 65 | 65 |
| 66 base::RunLoop().RunUntilIdle(); | 66 base::RunLoop().RunUntilIdle(); |
| 67 | 67 |
| 68 EXPECT_FALSE(status_item()); | 68 EXPECT_TRUE(status_item()); |
| 69 } | 69 } |
| OLD | NEW |