Moved some message center constants to message_center_constants.h.

BUG=NONE

Review URL: https://chromiumcodereview.appspot.com/14327004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195077 0039d316-1c4b-4281-b951-d872f2087c98
parent 561f748a
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
#include "base/stringprintf.h" #include "base/stringprintf.h"
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "ui/message_center/message_center_constants.h"
#include "ui/message_center/message_center_tray.h" #include "ui/message_center/message_center_tray.h"
#include "ui/message_center/message_center_util.h" #include "ui/message_center/message_center_util.h"
#include "ui/message_center/notification_list.h" #include "ui/message_center/notification_list.h"
...@@ -146,7 +147,7 @@ using message_center::NotificationList; ...@@ -146,7 +147,7 @@ using message_center::NotificationList;
TEST_F(WebNotificationTrayTest, DISABLED_ManyMessageCenterNotifications) { TEST_F(WebNotificationTrayTest, DISABLED_ManyMessageCenterNotifications) {
// Add the max visible notifications +1, ensure the correct visible number. // Add the max visible notifications +1, ensure the correct visible number.
size_t notifications_to_add = size_t notifications_to_add =
NotificationList::kMaxVisibleMessageCenterNotifications + 1; message_center::kMaxVisibleMessageCenterNotifications + 1;
for (size_t i = 0; i < notifications_to_add; ++i) { for (size_t i = 0; i < notifications_to_add; ++i) {
std::string id = base::StringPrintf("test_id%d", static_cast<int>(i)); std::string id = base::StringPrintf("test_id%d", static_cast<int>(i));
AddNotification(id); AddNotification(id);
...@@ -157,7 +158,7 @@ TEST_F(WebNotificationTrayTest, DISABLED_ManyMessageCenterNotifications) { ...@@ -157,7 +158,7 @@ TEST_F(WebNotificationTrayTest, DISABLED_ManyMessageCenterNotifications) {
EXPECT_TRUE(GetTray()->message_center_bubble() != NULL); EXPECT_TRUE(GetTray()->message_center_bubble() != NULL);
EXPECT_EQ(notifications_to_add, EXPECT_EQ(notifications_to_add,
GetMessageCenter()->NotificationCount()); GetMessageCenter()->NotificationCount());
EXPECT_EQ(NotificationList::kMaxVisibleMessageCenterNotifications, EXPECT_EQ(message_center::kMaxVisibleMessageCenterNotifications,
GetTray()->GetMessageCenterBubbleForTest()-> GetTray()->GetMessageCenterBubbleForTest()->
NumMessageViewsForTest()); NumMessageViewsForTest());
} }
...@@ -166,7 +167,7 @@ TEST_F(WebNotificationTrayTest, DISABLED_ManyMessageCenterNotifications) { ...@@ -166,7 +167,7 @@ TEST_F(WebNotificationTrayTest, DISABLED_ManyMessageCenterNotifications) {
TEST_F(WebNotificationTrayTest, DISABLED_ManyPopupNotifications) { TEST_F(WebNotificationTrayTest, DISABLED_ManyPopupNotifications) {
// Add the max visible popup notifications +1, ensure the correct num visible. // Add the max visible popup notifications +1, ensure the correct num visible.
size_t notifications_to_add = size_t notifications_to_add =
NotificationList::kMaxVisiblePopupNotifications + 1; message_center::kMaxVisiblePopupNotifications + 1;
for (size_t i = 0; i < notifications_to_add; ++i) { for (size_t i = 0; i < notifications_to_add; ++i) {
std::string id = base::StringPrintf("test_id%d", static_cast<int>(i)); std::string id = base::StringPrintf("test_id%d", static_cast<int>(i));
AddNotification(id); AddNotification(id);
...@@ -180,9 +181,9 @@ TEST_F(WebNotificationTrayTest, DISABLED_ManyPopupNotifications) { ...@@ -180,9 +181,9 @@ TEST_F(WebNotificationTrayTest, DISABLED_ManyPopupNotifications) {
if (message_center::IsRichNotificationEnabled()) { if (message_center::IsRichNotificationEnabled()) {
NotificationList::PopupNotifications popups = NotificationList::PopupNotifications popups =
GetMessageCenter()->GetPopupNotifications(); GetMessageCenter()->GetPopupNotifications();
EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications, popups.size()); EXPECT_EQ(message_center::kMaxVisiblePopupNotifications, popups.size());
} else { } else {
EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications, EXPECT_EQ(message_center::kMaxVisiblePopupNotifications,
GetTray()->GetPopupBubbleForTest()->NumMessageViewsForTest()); GetTray()->GetPopupBubbleForTest()->NumMessageViewsForTest());
} }
} }
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "chrome/test/base/in_process_browser_test.h" #include "chrome/test/base/in_process_browser_test.h"
#include "content/public/test/test_utils.h" #include "content/public/test/test_utils.h"
#include "ui/message_center/message_center_constants.h"
#include "ui/message_center/message_center_tray.h" #include "ui/message_center/message_center_tray.h"
#include "ui/message_center/notification_list.h" #include "ui/message_center/notification_list.h"
#include "ui/message_center/notification_types.h" #include "ui/message_center/notification_types.h"
...@@ -130,8 +131,7 @@ IN_PROC_BROWSER_TEST_F(WebNotificationTrayWinTest, ...@@ -130,8 +131,7 @@ IN_PROC_BROWSER_TEST_F(WebNotificationTrayWinTest,
message_center::MessageCenter* message_center = tray->message_center(); message_center::MessageCenter* message_center = tray->message_center();
// Add the max visible notifications +1, ensure the correct visible number. // Add the max visible notifications +1, ensure the correct visible number.
size_t notifications_to_add = size_t notifications_to_add = kMaxVisibleMessageCenterNotifications + 1;
NotificationList::kMaxVisibleMessageCenterNotifications + 1;
for (size_t i = 0; i < notifications_to_add; ++i) { for (size_t i = 0; i < notifications_to_add; ++i) {
std::string id = base::StringPrintf("test_id%d", static_cast<int>(i)); std::string id = base::StringPrintf("test_id%d", static_cast<int>(i));
AddNotification(id); AddNotification(id);
...@@ -142,7 +142,7 @@ IN_PROC_BROWSER_TEST_F(WebNotificationTrayWinTest, ...@@ -142,7 +142,7 @@ IN_PROC_BROWSER_TEST_F(WebNotificationTrayWinTest,
EXPECT_TRUE(tray->message_center_bubble_.get() != NULL); EXPECT_TRUE(tray->message_center_bubble_.get() != NULL);
EXPECT_EQ(notifications_to_add, EXPECT_EQ(notifications_to_add,
message_center->NotificationCount()); message_center->NotificationCount());
EXPECT_EQ(NotificationList::kMaxVisibleMessageCenterNotifications, EXPECT_EQ(kMaxVisibleMessageCenterNotifications,
tray->GetMessageCenterBubbleForTest()->NumMessageViewsForTest()); tray->GetMessageCenterBubbleForTest()->NumMessageViewsForTest());
} }
...@@ -151,8 +151,7 @@ IN_PROC_BROWSER_TEST_F(WebNotificationTrayWinTest, ManyPopupNotifications) { ...@@ -151,8 +151,7 @@ IN_PROC_BROWSER_TEST_F(WebNotificationTrayWinTest, ManyPopupNotifications) {
message_center::MessageCenter* message_center = tray->message_center(); message_center::MessageCenter* message_center = tray->message_center();
// Add the max visible popup notifications +1, ensure the correct num visible. // Add the max visible popup notifications +1, ensure the correct num visible.
size_t notifications_to_add = size_t notifications_to_add = kMaxVisiblePopupNotifications + 1;
NotificationList::kMaxVisiblePopupNotifications + 1;
for (size_t i = 0; i < notifications_to_add; ++i) { for (size_t i = 0; i < notifications_to_add; ++i) {
std::string id = base::StringPrintf("test_id%d", static_cast<int>(i)); std::string id = base::StringPrintf("test_id%d", static_cast<int>(i));
AddNotification(id); AddNotification(id);
...@@ -165,7 +164,7 @@ IN_PROC_BROWSER_TEST_F(WebNotificationTrayWinTest, ManyPopupNotifications) { ...@@ -165,7 +164,7 @@ IN_PROC_BROWSER_TEST_F(WebNotificationTrayWinTest, ManyPopupNotifications) {
message_center->NotificationCount()); message_center->NotificationCount());
NotificationList::PopupNotifications popups = NotificationList::PopupNotifications popups =
message_center->GetPopupNotifications(); message_center->GetPopupNotifications();
EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications, popups.size()); EXPECT_EQ(kMaxVisiblePopupNotifications, popups.size());
} }
} // namespace message_center } // namespace message_center
...@@ -14,6 +14,10 @@ const int kNotificationIconSize = 80; ...@@ -14,6 +14,10 @@ const int kNotificationIconSize = 80;
const int kNotificationPreferredImageSize = kNotificationWidth; const int kNotificationPreferredImageSize = kNotificationWidth;
const int kSettingsIconSize = 16; const int kSettingsIconSize = 16;
// Limits.
const size_t kMaxVisibleMessageCenterNotifications = 100;
const size_t kMaxVisiblePopupNotifications = 3;
// Within a notification /////////////////////////////////////////////////////// // Within a notification ///////////////////////////////////////////////////////
// Pixel dimensions. // Pixel dimensions.
......
...@@ -19,6 +19,10 @@ MESSAGE_CENTER_EXPORT extern const int kNotificationIconSize; ...@@ -19,6 +19,10 @@ MESSAGE_CENTER_EXPORT extern const int kNotificationIconSize;
MESSAGE_CENTER_EXPORT extern const int kNotificationPreferredImageSize; MESSAGE_CENTER_EXPORT extern const int kNotificationPreferredImageSize;
MESSAGE_CENTER_EXPORT extern const int kSettingsIconSize; MESSAGE_CENTER_EXPORT extern const int kSettingsIconSize;
// Limits.
MESSAGE_CENTER_EXPORT extern const size_t kMaxVisiblePopupNotifications;
MESSAGE_CENTER_EXPORT extern const size_t kMaxVisibleMessageCenterNotifications;
// Within a notification /////////////////////////////////////////////////////// // Within a notification ///////////////////////////////////////////////////////
// Pixel dimensions (H = horizontal, V = vertical). // Pixel dimensions (H = horizontal, V = vertical).
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/time.h" #include "base/time.h"
#include "base/values.h" #include "base/values.h"
#include "ui/message_center/message_center_constants.h"
#include "ui/message_center/notification.h" #include "ui/message_center/notification.h"
#include "ui/message_center/notification_types.h" #include "ui/message_center/notification_types.h"
...@@ -35,9 +36,6 @@ bool CompareTimestampSerial::operator()(Notification* n1, Notification* n2) { ...@@ -35,9 +36,6 @@ bool CompareTimestampSerial::operator()(Notification* n1, Notification* n2) {
return false; return false;
} }
const size_t NotificationList::kMaxVisibleMessageCenterNotifications = 100;
const size_t NotificationList::kMaxVisiblePopupNotifications = 3;
NotificationList::NotificationList() NotificationList::NotificationList()
: message_center_visible_(false), : message_center_visible_(false),
unread_count_(0), unread_count_(0),
......
...@@ -128,9 +128,6 @@ class MESSAGE_CENTER_EXPORT NotificationList { ...@@ -128,9 +128,6 @@ class MESSAGE_CENTER_EXPORT NotificationList {
size_t NotificationCount() const; size_t NotificationCount() const;
size_t unread_count() const { return unread_count_; } size_t unread_count() const { return unread_count_; }
static const size_t kMaxVisiblePopupNotifications;
static const size_t kMaxVisibleMessageCenterNotifications;
private: private:
friend class test::NotificationListTest; friend class test::NotificationListTest;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/message_center/message_center_constants.h"
#include "ui/message_center/notification_types.h" #include "ui/message_center/notification_types.h"
namespace message_center { namespace message_center {
...@@ -188,21 +189,18 @@ TEST_F(NotificationListTest, GetNotificationsBySourceOrExtensions) { ...@@ -188,21 +189,18 @@ TEST_F(NotificationListTest, GetNotificationsBySourceOrExtensions) {
TEST_F(NotificationListTest, OldPopupShouldNotBeHidden) { TEST_F(NotificationListTest, OldPopupShouldNotBeHidden) {
std::vector<std::string> ids; std::vector<std::string> ids;
for (size_t i = 0; i <= NotificationList::kMaxVisiblePopupNotifications; for (size_t i = 0; i <= kMaxVisiblePopupNotifications; i++)
i++) {
ids.push_back(AddNotification(NULL)); ids.push_back(AddNotification(NULL));
}
NotificationList::PopupNotifications popups = NotificationList::PopupNotifications popups =
notification_list()->GetPopupNotifications(); notification_list()->GetPopupNotifications();
// The popup should contain the oldest kMaxVisiblePopupNotifications. Newer // The popup should contain the oldest kMaxVisiblePopupNotifications. Newer
// one should come earlier in the popup list. It means, the last element // one should come earlier in the popup list. It means, the last element
// of |popups| should be the firstly added one, and so on. // of |popups| should be the firstly added one, and so on.
EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications, popups.size()); EXPECT_EQ(kMaxVisiblePopupNotifications, popups.size());
NotificationList::PopupNotifications::const_reverse_iterator iter = NotificationList::PopupNotifications::const_reverse_iterator iter =
popups.rbegin(); popups.rbegin();
for (size_t i = 0; i < NotificationList::kMaxVisiblePopupNotifications; for (size_t i = 0; i < kMaxVisiblePopupNotifications; ++i, ++iter) {
++i, ++iter) {
EXPECT_EQ(ids[i], (*iter)->id()) << i; EXPECT_EQ(ids[i], (*iter)->id()) << i;
} }
...@@ -218,27 +216,25 @@ TEST_F(NotificationListTest, Priority) { ...@@ -218,27 +216,25 @@ TEST_F(NotificationListTest, Priority) {
ASSERT_EQ(0u, notification_list()->unread_count()); ASSERT_EQ(0u, notification_list()->unread_count());
// Default priority has the limit on the number of the popups. // Default priority has the limit on the number of the popups.
for (size_t i = 0; i <= NotificationList::kMaxVisiblePopupNotifications; for (size_t i = 0; i <= kMaxVisiblePopupNotifications; ++i)
++i) {
AddNotification(NULL); AddNotification(NULL);
} EXPECT_EQ(kMaxVisiblePopupNotifications + 1,
EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications + 1,
notification_list()->NotificationCount()); notification_list()->NotificationCount());
EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications, GetPopupCounts()); EXPECT_EQ(kMaxVisiblePopupNotifications, GetPopupCounts());
// Low priority: not visible to popups. // Low priority: not visible to popups.
notification_list()->SetMessageCenterVisible(true, NULL); notification_list()->SetMessageCenterVisible(true, NULL);
notification_list()->SetMessageCenterVisible(false, NULL); notification_list()->SetMessageCenterVisible(false, NULL);
EXPECT_EQ(0u, notification_list()->unread_count()); EXPECT_EQ(0u, notification_list()->unread_count());
AddPriorityNotification(LOW_PRIORITY); AddPriorityNotification(LOW_PRIORITY);
EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications + 2, EXPECT_EQ(kMaxVisiblePopupNotifications + 2,
notification_list()->NotificationCount()); notification_list()->NotificationCount());
EXPECT_EQ(1u, notification_list()->unread_count()); EXPECT_EQ(1u, notification_list()->unread_count());
EXPECT_EQ(0u, GetPopupCounts()); EXPECT_EQ(0u, GetPopupCounts());
// Minimum priority: doesn't update the unread count. // Minimum priority: doesn't update the unread count.
AddPriorityNotification(MIN_PRIORITY); AddPriorityNotification(MIN_PRIORITY);
EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications + 3, EXPECT_EQ(kMaxVisiblePopupNotifications + 3,
notification_list()->NotificationCount()); notification_list()->NotificationCount());
EXPECT_EQ(1u, notification_list()->unread_count()); EXPECT_EQ(1u, notification_list()->unread_count());
EXPECT_EQ(0u, GetPopupCounts()); EXPECT_EQ(0u, GetPopupCounts());
...@@ -246,18 +242,13 @@ TEST_F(NotificationListTest, Priority) { ...@@ -246,18 +242,13 @@ TEST_F(NotificationListTest, Priority) {
notification_list()->RemoveAllNotifications(); notification_list()->RemoveAllNotifications();
// Higher priority: no limits to the number of popups. // Higher priority: no limits to the number of popups.
for (size_t i = 0; i < NotificationList::kMaxVisiblePopupNotifications * 2; for (size_t i = 0; i < kMaxVisiblePopupNotifications * 2; ++i)
++i) {
AddPriorityNotification(HIGH_PRIORITY); AddPriorityNotification(HIGH_PRIORITY);
} for (size_t i = 0; i < kMaxVisiblePopupNotifications * 2; ++i)
for (size_t i = 0; i < NotificationList::kMaxVisiblePopupNotifications * 2;
++i) {
AddPriorityNotification(MAX_PRIORITY); AddPriorityNotification(MAX_PRIORITY);
} EXPECT_EQ(kMaxVisiblePopupNotifications * 4,
EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications * 4,
notification_list()->NotificationCount()); notification_list()->NotificationCount());
EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications * 4, EXPECT_EQ(kMaxVisiblePopupNotifications * 4, GetPopupCounts());
GetPopupCounts());
} }
TEST_F(NotificationListTest, HasPopupsWithPriority) { TEST_F(NotificationListTest, HasPopupsWithPriority) {
...@@ -390,8 +381,7 @@ TEST_F(NotificationListTest, MarkSinglePopupAsShown) { ...@@ -390,8 +381,7 @@ TEST_F(NotificationListTest, MarkSinglePopupAsShown) {
std::string id2 = AddNotification(NULL); std::string id2 = AddNotification(NULL);
std::string id3 = AddNotification(NULL); std::string id3 = AddNotification(NULL);
ASSERT_EQ(3u, notification_list()->NotificationCount()); ASSERT_EQ(3u, notification_list()->NotificationCount());
ASSERT_EQ(std::min(static_cast<size_t>(3u), ASSERT_EQ(std::min(static_cast<size_t>(3u), kMaxVisiblePopupNotifications),
NotificationList::kMaxVisiblePopupNotifications),
GetPopupCounts()); GetPopupCounts());
notification_list()->MarkSinglePopupAsShown(id2, true); notification_list()->MarkSinglePopupAsShown(id2, true);
......
...@@ -391,10 +391,8 @@ void MessageCenterView::SetNotifications( ...@@ -391,10 +391,8 @@ void MessageCenterView::SetNotifications(
for (NotificationList::Notifications::const_iterator iter = for (NotificationList::Notifications::const_iterator iter =
notifications.begin(); iter != notifications.end(); ++iter) { notifications.begin(); iter != notifications.end(); ++iter) {
AddNotification(*(*iter)); AddNotification(*(*iter));
if (message_views_.size() >= if (message_views_.size() >= kMaxVisibleMessageCenterNotifications)
NotificationList::kMaxVisibleMessageCenterNotifications) {
break; break;
}
} }
if (message_views_.empty()) { if (message_views_.empty()) {
views::Label* label = new views::Label(l10n_util::GetStringUTF16( views::Label* label = new views::Label(l10n_util::GetStringUTF16(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment