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" | |
22 | 21 |
23 using sync_pb::SyncedNotificationSpecifics; | 22 using sync_pb::SyncedNotificationSpecifics; |
24 using sync_pb::EntitySpecifics; | 23 using sync_pb::EntitySpecifics; |
25 using syncer::SyncData; | 24 using syncer::SyncData; |
26 using syncer::SyncChange; | 25 using syncer::SyncChange; |
27 using syncer::SyncChangeList; | 26 using syncer::SyncChangeList; |
28 using syncer::SyncDataList; | 27 using syncer::SyncDataList; |
29 using syncer::SYNCED_NOTIFICATIONS; | 28 using syncer::SYNCED_NOTIFICATIONS; |
30 using notifier::SyncedNotification; | 29 using notifier::SyncedNotification; |
31 using notifier::ChromeNotifierService; | 30 using notifier::ChromeNotifierService; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 const char kButtonTwoUrl[] = "http://www.google.com/do-something2"; | 87 const char kButtonTwoUrl[] = "http://www.google.com/do-something2"; |
89 const char kContainedTitle1[] = "Today's Picnic moved"; | 88 const char kContainedTitle1[] = "Today's Picnic moved"; |
90 const char kContainedTitle2[] = "Group Run Today"; | 89 const char kContainedTitle2[] = "Group Run Today"; |
91 const char kContainedTitle3[] = "Starcraft Tonight"; | 90 const char kContainedTitle3[] = "Starcraft Tonight"; |
92 const char kContainedMessage1[] = "Due to rain, we will be inside the cafe."; | 91 const char kContainedMessage1[] = "Due to rain, we will be inside the cafe."; |
93 const char kContainedMessage2[] = "Meet at noon in the Gym."; | 92 const char kContainedMessage2[] = "Meet at noon in the Gym."; |
94 const char kContainedMessage3[] = "Let's play starcraft tonight on the LAN."; | 93 const char kContainedMessage3[] = "Let's play starcraft tonight on the LAN."; |
95 const int64 kFakeCreationTime = 42; | 94 const int64 kFakeCreationTime = 42; |
96 const int kProtobufPriority = static_cast<int>( | 95 const int kProtobufPriority = static_cast<int>( |
97 sync_pb::CoalescedSyncedNotification_Priority_LOW); | 96 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 |
100 const sync_pb::CoalescedSyncedNotification_ReadState kDismissed = | 103 const sync_pb::CoalescedSyncedNotification_ReadState kDismissed = |
101 sync_pb::CoalescedSyncedNotification_ReadState_DISMISSED; | 104 sync_pb::CoalescedSyncedNotification_ReadState_DISMISSED; |
102 const sync_pb::CoalescedSyncedNotification_ReadState kUnread = | 105 const sync_pb::CoalescedSyncedNotification_ReadState kUnread = |
103 sync_pb::CoalescedSyncedNotification_ReadState_UNREAD; | 106 sync_pb::CoalescedSyncedNotification_ReadState_UNREAD; |
104 | 107 |
105 // Extract notification id from syncer::SyncData. | 108 // Extract notification id from syncer::SyncData. |
106 std::string GetNotificationId(const SyncData& sync_data) { | 109 std::string GetNotificationId(const SyncData& sync_data) { |
107 SyncedNotificationSpecifics specifics = sync_data.GetSpecifics(). | 110 SyncedNotificationSpecifics specifics = sync_data.GetSpecifics(). |
108 synced_notification(); | 111 synced_notification(); |
109 | 112 |
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 EXPECT_EQ(kTitle2, notification1->GetTitle()); | 757 EXPECT_EQ(kTitle2, notification1->GetTitle()); |
755 | 758 |
756 // Ensure no new data will be sent to the remote store for notification1. | 759 // Ensure no new data will be sent to the remote store for notification1. |
757 EXPECT_EQ(0U, processor()->change_list_size()); | 760 EXPECT_EQ(0U, processor()->change_list_size()); |
758 EXPECT_FALSE(processor()->ContainsId(kKey1)); | 761 EXPECT_FALSE(processor()->ContainsId(kKey1)); |
759 } | 762 } |
760 | 763 |
761 // TODO(petewil): There are more tests to add, such as when we add an API | 764 // TODO(petewil): There are more tests to add, such as when we add an API |
762 // to allow data entry from the client, we might have a more up to date | 765 // to allow data entry from the client, we might have a more up to date |
763 // item on the client than the server, or we might have a merge conflict. | 766 // item on the client than the server, or we might have a merge conflict. |
OLD | NEW |