| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 ChromeNotifierService::CreateSyncDataFromNotification(*notification1); | 222 ChromeNotifierService::CreateSyncDataFromNotification(*notification1); |
| 223 scoped_ptr<SyncedNotification> notification2( | 223 scoped_ptr<SyncedNotification> notification2( |
| 224 notifier.CreateNotificationFromSyncData(sync_data)); | 224 notifier.CreateNotificationFromSyncData(sync_data)); |
| 225 EXPECT_TRUE(notification2.get()); | 225 EXPECT_TRUE(notification2.get()); |
| 226 EXPECT_TRUE(notification1->EqualsIgnoringReadState(*notification2)); | 226 EXPECT_TRUE(notification1->EqualsIgnoringReadState(*notification2)); |
| 227 EXPECT_EQ(notification1->GetReadState(), notification2->GetReadState()); | 227 EXPECT_EQ(notification1->GetReadState(), notification2->GetReadState()); |
| 228 } | 228 } |
| 229 | 229 |
| 230 // Model assocation: We have no local data, and no remote data. | 230 // Model assocation: We have no local data, and no remote data. |
| 231 TEST_F(ChromeNotifierServiceTest, ModelAssocBothEmpty) { | 231 TEST_F(ChromeNotifierServiceTest, ModelAssocBothEmpty) { |
| 232 | |
| 233 ChromeNotifierService notifier(profile_.get(), notification_manager()); | 232 ChromeNotifierService notifier(profile_.get(), notification_manager()); |
| 234 | 233 |
| 235 notifier.MergeDataAndStartSyncing( | 234 notifier.MergeDataAndStartSyncing( |
| 236 SYNCED_NOTIFICATIONS, | 235 SYNCED_NOTIFICATIONS, |
| 237 SyncDataList(), // Empty. | 236 SyncDataList(), // Empty. |
| 238 PassProcessor(), | 237 PassProcessor(), |
| 239 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())); | 238 scoped_ptr<syncer::SyncErrorFactory>(new syncer::SyncErrorFactoryMock())); |
| 240 | 239 |
| 241 EXPECT_EQ(0U, notifier.GetAllSyncData(SYNCED_NOTIFICATIONS).size()); | 240 EXPECT_EQ(0U, notifier.GetAllSyncData(SYNCED_NOTIFICATIONS).size()); |
| 242 EXPECT_EQ(0U, processor()->change_list_size()); | 241 EXPECT_EQ(0U, processor()->change_list_size()); |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 // notification_manager. | 580 // notification_manager. |
| 582 notifier.OnSyncedNotificationServiceEnabled(kSendingService1Name, false); | 581 notifier.OnSyncedNotificationServiceEnabled(kSendingService1Name, false); |
| 583 iter = find(notifier.enabled_sending_services_.begin(), | 582 iter = find(notifier.enabled_sending_services_.begin(), |
| 584 notifier.enabled_sending_services_.end(), | 583 notifier.enabled_sending_services_.end(), |
| 585 first_synced_notification_service_id); | 584 first_synced_notification_service_id); |
| 586 | 585 |
| 587 EXPECT_EQ(notifier.enabled_sending_services_.end(), iter); | 586 EXPECT_EQ(notifier.enabled_sending_services_.end(), iter); |
| 588 EXPECT_EQ(notification_manager()->dismissed_id(), std::string(kKey1)); | 587 EXPECT_EQ(notification_manager()->dismissed_id(), std::string(kKey1)); |
| 589 } | 588 } |
| 590 | 589 |
| 591 // http://crbug.com/341326 | 590 TEST_F(ChromeNotifierServiceTest, AddNewSendingServicesTest) { |
| 592 #if defined(TOOLKIT_GTK) | |
| 593 #define MAYBE_AddNewSendingServicesTest DISABLED_AddNewSendingServicesTest | |
| 594 #else | |
| 595 #define MAYBE_AddNewSendingServicesTest AddNewSendingServicesTest | |
| 596 #endif | |
| 597 TEST_F(ChromeNotifierServiceTest, MAYBE_AddNewSendingServicesTest) { | |
| 598 // This test will see if we get a new sending service after the first | 591 // This test will see if we get a new sending service after the first |
| 599 // notification for that service. | 592 // notification for that service. |
| 600 ChromeNotifierService notifier(profile_.get(), notification_manager()); | 593 ChromeNotifierService notifier(profile_.get(), notification_manager()); |
| 601 notifier.set_avoid_bitmap_fetching_for_test(true); | 594 notifier.set_avoid_bitmap_fetching_for_test(true); |
| 602 | 595 |
| 603 // We initially have no data. | 596 // We initially have no data. |
| 604 EXPECT_EQ(0U, notifier.enabled_sending_services_.size()); | 597 EXPECT_EQ(0U, notifier.enabled_sending_services_.size()); |
| 605 EXPECT_EQ(0U, notifier.GetAllSyncData(SYNCED_NOTIFICATIONS).size()); | 598 EXPECT_EQ(0U, notifier.GetAllSyncData(SYNCED_NOTIFICATIONS).size()); |
| 606 | 599 |
| 607 // Set up an ADD. | 600 // Set up an ADD. |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 | 673 |
| 681 notifier.ProcessSyncChanges(FROM_HERE, changes); | 674 notifier.ProcessSyncChanges(FROM_HERE, changes); |
| 682 | 675 |
| 683 // Since we added to |initialized_sending_services_| before receiving the | 676 // Since we added to |initialized_sending_services_| before receiving the |
| 684 // synced notification, we should not have enabled this service while | 677 // synced notification, we should not have enabled this service while |
| 685 // processing the sync change. | 678 // processing the sync change. |
| 686 EXPECT_EQ(0U, notifier.enabled_sending_services_.size()); | 679 EXPECT_EQ(0U, notifier.enabled_sending_services_.size()); |
| 687 EXPECT_EQ(0U, notification_manager()->added_notifications()); | 680 EXPECT_EQ(0U, notification_manager()->added_notifications()); |
| 688 } | 681 } |
| 689 | 682 |
| 690 #if defined(TOOLKIT_GTK) | 683 TEST_F(ChromeNotifierServiceTest, SetAddedAppIdsTest) { |
| 691 // TODO(petewil): crbug.com/358031 | |
| 692 #define MAYBE_SetAddedAppIdsTest DISABLED_SetAddedAppIdsTest | |
| 693 #else | |
| 694 #define MAYBE_SetAddedAppIdsTest SetAddedAppIdsTest | |
| 695 #endif | |
| 696 TEST_F(ChromeNotifierServiceTest, MAYBE_SetAddedAppIdsTest) { | |
| 697 ChromeNotifierService notifier(profile_.get(), notification_manager()); | 684 ChromeNotifierService notifier(profile_.get(), notification_manager()); |
| 698 notifier.set_avoid_bitmap_fetching_for_test(true); | 685 notifier.set_avoid_bitmap_fetching_for_test(true); |
| 699 | 686 |
| 700 // Add some notifications to our notification list. | 687 // Add some notifications to our notification list. |
| 701 scoped_ptr<SyncedNotification> n1(CreateNotification( | 688 scoped_ptr<SyncedNotification> n1(CreateNotification( |
| 702 kTitle1, kText1, kIconUrl1, kImageUrl1, kAppId1, kKey1, kUnread)); | 689 kTitle1, kText1, kIconUrl1, kImageUrl1, kAppId1, kKey1, kUnread)); |
| 703 n1->SetNotifierServiceForTest(¬ifier); | 690 n1->SetNotifierServiceForTest(¬ifier); |
| 704 notifier.AddForTest(n1.Pass()); | 691 notifier.AddForTest(n1.Pass()); |
| 705 | 692 |
| 706 EXPECT_EQ(static_cast<size_t>(0), | 693 EXPECT_EQ(static_cast<size_t>(0), |
| (...skipping 25 matching lines...) Expand all Loading... |
| 732 notifier.OnRemovedAppIds(removed_app_ids); | 719 notifier.OnRemovedAppIds(removed_app_ids); |
| 733 | 720 |
| 734 // Verify the notification was "removed" in the notification manager. | 721 // Verify the notification was "removed" in the notification manager. |
| 735 EXPECT_EQ(std::string(kKey1), notification_manager()->dismissed_id()); | 722 EXPECT_EQ(std::string(kKey1), notification_manager()->dismissed_id()); |
| 736 } | 723 } |
| 737 | 724 |
| 738 // TODO(petewil): Add a test that we do *not* get a welcome dialog unless we | 725 // TODO(petewil): Add a test that we do *not* get a welcome dialog unless we |
| 739 // have a valid app info for the notification. | 726 // have a valid app info for the notification. |
| 740 | 727 |
| 741 } // namespace notifier | 728 } // namespace notifier |
| OLD | NEW |