OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include <map> | 5 #include <map> |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/notifications/notification.h" | 10 #include "chrome/browser/notifications/notification.h" |
11 #include "chrome/browser/notifications/notification_ui_manager.h" | 11 #include "chrome/browser/notifications/notification_ui_manager.h" |
12 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" | 12 #include "chrome/browser/notifications/sync_notifier/chrome_notifier_service.h" |
13 #include "chrome/browser/notifications/sync_notifier/synced_notification.h" | 13 #include "chrome/browser/notifications/sync_notifier/synced_notification.h" |
14 #include "sync/api/sync_change.h" | 14 #include "sync/api/sync_change.h" |
15 #include "sync/api/sync_change_processor.h" | 15 #include "sync/api/sync_change_processor.h" |
16 #include "sync/api/sync_error_factory.h" | 16 #include "sync/api/sync_error_factory.h" |
17 #include "sync/api/sync_error_factory_mock.h" | 17 #include "sync/api/sync_error_factory_mock.h" |
18 #include "sync/protocol/sync.pb.h" | 18 #include "sync/protocol/sync.pb.h" |
19 #include "sync/protocol/synced_notification_specifics.pb.h" | 19 #include "sync/protocol/synced_notification_specifics.pb.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "ui/message_center/message_center_util.h" |
21 | 22 |
22 using sync_pb::SyncedNotificationSpecifics; | 23 using sync_pb::SyncedNotificationSpecifics; |
23 using sync_pb::EntitySpecifics; | 24 using sync_pb::EntitySpecifics; |
24 using syncer::SyncData; | 25 using syncer::SyncData; |
25 using syncer::SyncChange; | 26 using syncer::SyncChange; |
26 using syncer::SyncChangeList; | 27 using syncer::SyncChangeList; |
27 using syncer::SyncDataList; | 28 using syncer::SyncDataList; |
28 using syncer::SYNCED_NOTIFICATIONS; | 29 using syncer::SYNCED_NOTIFICATIONS; |
29 using notifier::SyncedNotification; | 30 using notifier::SyncedNotification; |
30 using notifier::ChromeNotifierService; | 31 using notifier::ChromeNotifierService; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 const char kButtonTwoUrl[] = "http://www.google.com/do-something2"; | 88 const char kButtonTwoUrl[] = "http://www.google.com/do-something2"; |
88 const char kContainedTitle1[] = "Today's Picnic moved"; | 89 const char kContainedTitle1[] = "Today's Picnic moved"; |
89 const char kContainedTitle2[] = "Group Run Today"; | 90 const char kContainedTitle2[] = "Group Run Today"; |
90 const char kContainedTitle3[] = "Starcraft Tonight"; | 91 const char kContainedTitle3[] = "Starcraft Tonight"; |
91 const char kContainedMessage1[] = "Due to rain, we will be inside the cafe."; | 92 const char kContainedMessage1[] = "Due to rain, we will be inside the cafe."; |
92 const char kContainedMessage2[] = "Meet at noon in the Gym."; | 93 const char kContainedMessage2[] = "Meet at noon in the Gym."; |
93 const char kContainedMessage3[] = "Let's play starcraft tonight on the LAN."; | 94 const char kContainedMessage3[] = "Let's play starcraft tonight on the LAN."; |
94 const int64 kFakeCreationTime = 42; | 95 const int64 kFakeCreationTime = 42; |
95 const int kProtobufPriority = static_cast<int>( | 96 const int kProtobufPriority = static_cast<int>( |
96 sync_pb::CoalescedSyncedNotification_Priority_LOW); | 97 sync_pb::CoalescedSyncedNotification_Priority_LOW); |
97 #if defined (ENABLE_MESSAGE_CENTER) | |
98 const int kNotificationPriority = static_cast<int>( | 98 const int kNotificationPriority = static_cast<int>( |
99 message_center::LOW_PRIORITY); | 99 message_center::LOW_PRIORITY); |
100 #else // ENABLE_MESSAGE_CENTER | |
101 const int kNotificationPriority = 1; | |
102 #endif // ENABLE_MESSAGE_CENTER | |
103 const sync_pb::CoalescedSyncedNotification_ReadState kDismissed = | 100 const sync_pb::CoalescedSyncedNotification_ReadState kDismissed = |
104 sync_pb::CoalescedSyncedNotification_ReadState_DISMISSED; | 101 sync_pb::CoalescedSyncedNotification_ReadState_DISMISSED; |
105 const sync_pb::CoalescedSyncedNotification_ReadState kUnread = | 102 const sync_pb::CoalescedSyncedNotification_ReadState kUnread = |
106 sync_pb::CoalescedSyncedNotification_ReadState_UNREAD; | 103 sync_pb::CoalescedSyncedNotification_ReadState_UNREAD; |
107 | 104 |
108 // Extract notification id from syncer::SyncData. | 105 // Extract notification id from syncer::SyncData. |
109 std::string GetNotificationId(const SyncData& sync_data) { | 106 std::string GetNotificationId(const SyncData& sync_data) { |
110 SyncedNotificationSpecifics specifics = sync_data.GetSpecifics(). | 107 SyncedNotificationSpecifics specifics = sync_data.GetSpecifics(). |
111 synced_notification(); | 108 synced_notification(); |
112 | 109 |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 EXPECT_EQ(kTitle2, notification1->GetTitle()); | 754 EXPECT_EQ(kTitle2, notification1->GetTitle()); |
758 | 755 |
759 // Ensure no new data will be sent to the remote store for notification1. | 756 // Ensure no new data will be sent to the remote store for notification1. |
760 EXPECT_EQ(0U, processor()->change_list_size()); | 757 EXPECT_EQ(0U, processor()->change_list_size()); |
761 EXPECT_FALSE(processor()->ContainsId(kKey1)); | 758 EXPECT_FALSE(processor()->ContainsId(kKey1)); |
762 } | 759 } |
763 | 760 |
764 // TODO(petewil): There are more tests to add, such as when we add an API | 761 // TODO(petewil): There are more tests to add, such as when we add an API |
765 // to allow data entry from the client, we might have a more up to date | 762 // to allow data entry from the client, we might have a more up to date |
766 // item on the client than the server, or we might have a merge conflict. | 763 // item on the client than the server, or we might have a merge conflict. |
OLD | NEW |