Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: trunk/src/chrome/browser/notifications/sync_notifier/synced_notification_unittest.cc

Issue 14631021: Revert 199625 "Remove ENABLE_MESSAGE_CENTER" (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include <string> 5 #include <string>
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 "chrome/browser/notifications/notification.h" 9 #include "chrome/browser/notifications/notification.h"
10 #include "chrome/browser/notifications/notification_ui_manager.h" 10 #include "chrome/browser/notifications/notification_ui_manager.h"
11 #include "chrome/browser/notifications/sync_notifier/synced_notification.h" 11 #include "chrome/browser/notifications/sync_notifier/synced_notification.h"
12 #include "sync/api/sync_data.h" 12 #include "sync/api/sync_data.h"
13 #include "sync/protocol/sync.pb.h" 13 #include "sync/protocol/sync.pb.h"
14 #include "sync/protocol/synced_notification_specifics.pb.h" 14 #include "sync/protocol/synced_notification_specifics.pb.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #if defined(ENABLE_MESSAGE_CENTER)
16 #include "ui/message_center/message_center_util.h" 17 #include "ui/message_center/message_center_util.h"
17 #include "ui/message_center/notification_types.h" 18 #include "ui/message_center/notification_types.h"
19 #endif // ENABLE_MESSAGE_CENTER
18 20
19 using syncer::SyncData; 21 using syncer::SyncData;
20 using notifier::SyncedNotification; 22 using notifier::SyncedNotification;
21 using sync_pb::EntitySpecifics; 23 using sync_pb::EntitySpecifics;
22 using sync_pb::SyncedNotificationSpecifics; 24 using sync_pb::SyncedNotificationSpecifics;
23 25
24 namespace { 26 namespace {
25 27
26 const uint64 kFakeCreationTime = 42; 28 const uint64 kFakeCreationTime = 42;
27 const int kProtobufPriority = static_cast<int>( 29 const int kProtobufPriority = static_cast<int>(
28 sync_pb::CoalescedSyncedNotification_Priority_LOW); 30 sync_pb::CoalescedSyncedNotification_Priority_LOW);
31 #if defined (ENABLE_MESSAGE_CENTER)
29 const int kNotificationPriority = static_cast<int>( 32 const int kNotificationPriority = static_cast<int>(
30 message_center::LOW_PRIORITY); 33 message_center::LOW_PRIORITY);
34 #else // ENABLE_MESSAGE_CENTER
35 const int kNotificationPriority = 1;
36 #endif // ENABLE_MESSAGE_CENTER
31 37
32 bool UseRichNotifications() { 38 bool UseRichNotifications() {
39 #if defined(ENABLE_MESSAGE_CENTER)
33 return message_center::IsRichNotificationEnabled(); 40 return message_center::IsRichNotificationEnabled();
41 #else // ENABLE_MESSAGE_CENTER
42 return false;
43 #endif // ENABLE_MESSAGE_CENTER
34 } 44 }
35 45
36 const char kTitle1[] = "New appointment at 2:15"; 46 const char kTitle1[] = "New appointment at 2:15";
37 const char kTitle2[] = "Email from Mark: Upcoming Ski trip"; 47 const char kTitle2[] = "Email from Mark: Upcoming Ski trip";
38 const char kTitle3[] = "Weather alert - light rain tonight."; 48 const char kTitle3[] = "Weather alert - light rain tonight.";
39 const char kAppId1[] = "fboilmbenheemaomgaeehigklolhkhnf"; 49 const char kAppId1[] = "fboilmbenheemaomgaeehigklolhkhnf";
40 const char kAppId2[] = "fbcmoldooppoahjhfflnmljoanccekpf"; 50 const char kAppId2[] = "fbcmoldooppoahjhfflnmljoanccekpf";
41 const char kKey1[] = "foo"; 51 const char kKey1[] = "foo";
42 const char kKey2[] = "bar"; 52 const char kKey2[] = "bar";
43 const char kText1[] = "Space Needle, 12:00 pm"; 53 const char kText1[] = "Space Needle, 12:00 pm";
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 EXPECT_TRUE(notification5->EqualsIgnoringReadState(*notification2_)); 565 EXPECT_TRUE(notification5->EqualsIgnoringReadState(*notification2_));
556 EXPECT_EQ(notification5->GetReadState(), notification2_->GetReadState()); 566 EXPECT_EQ(notification5->GetReadState(), notification2_->GetReadState());
557 EXPECT_FALSE(notification5->EqualsIgnoringReadState(*notification1_)); 567 EXPECT_FALSE(notification5->EqualsIgnoringReadState(*notification1_));
558 } 568 }
559 569
560 TEST_F(SyncedNotificationTest, ShowTest) { 570 TEST_F(SyncedNotificationTest, ShowTest) {
561 571
562 if (!UseRichNotifications()) 572 if (!UseRichNotifications())
563 return; 573 return;
564 574
575 #if defined(ENABLE_MESSAGE_CENTER)
576
565 StubNotificationUIManager notification_manager; 577 StubNotificationUIManager notification_manager;
566 578
567 // Call the method under test using the pre-populated data. 579 // Call the method under test using the pre-populated data.
568 notification1_->Show(&notification_manager, NULL, NULL); 580 notification1_->Show(&notification_manager, NULL, NULL);
569 581
570 // Check the base fields of the notification. 582 // Check the base fields of the notification.
571 EXPECT_EQ(message_center::NOTIFICATION_TYPE_IMAGE, 583 EXPECT_EQ(message_center::NOTIFICATION_TYPE_IMAGE,
572 notification_manager.notification().type()); 584 notification_manager.notification().type());
573 EXPECT_EQ(kTitle1, 585 EXPECT_EQ(kTitle1,
574 UTF16ToUTF8(notification_manager.notification().title())); 586 UTF16ToUTF8(notification_manager.notification().title()));
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 UTF8ToUTF16(kContainedMessage3)); 628 UTF8ToUTF16(kContainedMessage3));
617 items->Append(item1); 629 items->Append(item1);
618 items->Append(item2); 630 items->Append(item2);
619 items->Append(item3); 631 items->Append(item3);
620 expected_fields.Set(message_center::kItemsKey, items); 632 expected_fields.Set(message_center::kItemsKey, items);
621 633
622 EXPECT_TRUE(expected_fields.Equals(actual_fields)) 634 EXPECT_TRUE(expected_fields.Equals(actual_fields))
623 << "Expected: " << expected_fields 635 << "Expected: " << expected_fields
624 << ", but actual: " << *actual_fields; 636 << ", but actual: " << *actual_fields;
625 637
638 #endif // ENABLE_MESSAGE_CENTER
639
626 } 640 }
627 641
628 // TODO(petewil): Add a test for a notification being read and or deleted. 642 // TODO(petewil): Add a test for a notification being read and or deleted.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698