| 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 "sync/notifier/invalidation_notifier.h" | 5 #include "sync/notifier/invalidation_notifier.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "jingle/notifier/base/fake_base_task.h" | 9 #include "jingle/notifier/base/fake_base_task.h" |
| 10 #include "jingle/notifier/base/notifier_options.h" | 10 #include "jingle/notifier/base/notifier_options.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 TEST_F(InvalidationNotifierTest, Basic) { | 74 TEST_F(InvalidationNotifierTest, Basic) { |
| 75 CreateAndObserveNotifier("fake_state"); | 75 CreateAndObserveNotifier("fake_state"); |
| 76 InSequence dummy; | 76 InSequence dummy; |
| 77 | 77 |
| 78 syncable::ModelTypePayloadMap type_payloads; | 78 syncable::ModelTypePayloadMap type_payloads; |
| 79 type_payloads[syncable::PREFERENCES] = "payload"; | 79 type_payloads[syncable::PREFERENCES] = "payload"; |
| 80 type_payloads[syncable::BOOKMARKS] = ""; | 80 type_payloads[syncable::BOOKMARKS] = ""; |
| 81 type_payloads[syncable::AUTOFILL] = ""; | 81 type_payloads[syncable::AUTOFILL] = ""; |
| 82 | 82 |
| 83 EXPECT_CALL(mock_observer_, OnNotificationStateChange(true)); | 83 EXPECT_CALL(mock_observer_, OnNotificationsEnabled()); |
| 84 EXPECT_CALL(mock_observer_, | 84 EXPECT_CALL(mock_observer_, |
| 85 OnIncomingNotification(type_payloads, | 85 OnIncomingNotification(type_payloads, |
| 86 REMOTE_NOTIFICATION)); | 86 REMOTE_NOTIFICATION)); |
| 87 EXPECT_CALL(mock_observer_, OnNotificationStateChange(false)); | 87 EXPECT_CALL(mock_observer_, |
| 88 OnNotificationsDisabled(TRANSIENT_NOTIFICATION_ERROR)); |
| 89 EXPECT_CALL(mock_observer_, |
| 90 OnNotificationsDisabled(NOTIFICATION_CREDENTIALS_REJECTED)); |
| 88 // Note no expectation on mock_tracker_, as we initialized with | 91 // Note no expectation on mock_tracker_, as we initialized with |
| 89 // non-empty initial_invalidation_state above. | 92 // non-empty initial_invalidation_state above. |
| 90 | 93 |
| 91 // TODO(tim): This call should be a no-op, Remove once bug 124140 and | 94 // TODO(tim): This call should be a no-op, Remove once bug 124140 and |
| 92 // associated issues are fixed. | 95 // associated issues are fixed. |
| 93 invalidation_notifier_->SetStateDeprecated("fake_state"); | 96 invalidation_notifier_->SetStateDeprecated("fake_state"); |
| 94 invalidation_notifier_->SetUniqueId("fake_id"); | 97 invalidation_notifier_->SetUniqueId("fake_id"); |
| 95 invalidation_notifier_->UpdateCredentials("foo@bar.com", "fake_token"); | 98 invalidation_notifier_->UpdateCredentials("foo@bar.com", "fake_token"); |
| 96 | 99 |
| 97 invalidation_notifier_->OnSessionStatusChanged(true); | 100 invalidation_notifier_->OnNotificationsEnabled(); |
| 98 | 101 |
| 99 invalidation_notifier_->OnInvalidate(type_payloads); | 102 invalidation_notifier_->OnInvalidate(type_payloads); |
| 100 | 103 |
| 101 invalidation_notifier_->OnSessionStatusChanged(false); | 104 invalidation_notifier_->OnNotificationsDisabled( |
| 105 TRANSIENT_NOTIFICATION_ERROR); |
| 106 invalidation_notifier_->OnNotificationsDisabled( |
| 107 NOTIFICATION_CREDENTIALS_REJECTED); |
| 102 } | 108 } |
| 103 | 109 |
| 104 TEST_F(InvalidationNotifierTest, MigrateState) { | 110 TEST_F(InvalidationNotifierTest, MigrateState) { |
| 105 CreateAndObserveNotifier(std::string()); | 111 CreateAndObserveNotifier(std::string()); |
| 106 InSequence dummy; | 112 InSequence dummy; |
| 107 | 113 |
| 108 EXPECT_CALL(mock_tracker_, SetInvalidationState("fake_state")); | 114 EXPECT_CALL(mock_tracker_, SetInvalidationState("fake_state")); |
| 109 invalidation_notifier_->SetStateDeprecated("fake_state"); | 115 invalidation_notifier_->SetStateDeprecated("fake_state"); |
| 110 | 116 |
| 111 // Should do nothing. | 117 // Should do nothing. |
| 112 invalidation_notifier_->SetStateDeprecated("spurious_fake_state"); | 118 invalidation_notifier_->SetStateDeprecated("spurious_fake_state"); |
| 113 | 119 |
| 114 // Pretend Chrome shut down. | 120 // Pretend Chrome shut down. |
| 115 ResetNotifier(); | 121 ResetNotifier(); |
| 116 | 122 |
| 117 CreateAndObserveNotifier("fake_state"); | 123 CreateAndObserveNotifier("fake_state"); |
| 118 // Should do nothing. | 124 // Should do nothing. |
| 119 invalidation_notifier_->SetStateDeprecated("more_spurious_fake_state"); | 125 invalidation_notifier_->SetStateDeprecated("more_spurious_fake_state"); |
| 120 } | 126 } |
| 121 | 127 |
| 122 } // namespace | 128 } // namespace |
| 123 | 129 |
| 124 } // namespace sync_notifier | 130 } // namespace sync_notifier |
| OLD | NEW |