| 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/non_blocking_invalidation_notifier.h" | 5 #include "sync/notifier/non_blocking_invalidation_notifier.h" |
| 6 | 6 |
| 7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 options.message_loop_type = MessageLoop::TYPE_IO; | 35 options.message_loop_type = MessageLoop::TYPE_IO; |
| 36 io_thread_.StartWithOptions(options); | 36 io_thread_.StartWithOptions(options); |
| 37 request_context_getter_ = | 37 request_context_getter_ = |
| 38 new TestURLRequestContextGetter(io_thread_.message_loop_proxy()); | 38 new TestURLRequestContextGetter(io_thread_.message_loop_proxy()); |
| 39 notifier::NotifierOptions notifier_options; | 39 notifier::NotifierOptions notifier_options; |
| 40 notifier_options.request_context_getter = request_context_getter_; | 40 notifier_options.request_context_getter = request_context_getter_; |
| 41 invalidation_notifier_.reset( | 41 invalidation_notifier_.reset( |
| 42 new NonBlockingInvalidationNotifier( | 42 new NonBlockingInvalidationNotifier( |
| 43 notifier_options, | 43 notifier_options, |
| 44 InvalidationVersionMap(), | 44 InvalidationVersionMap(), |
| 45 std::string(), // initial_invalidation_state |
| 45 browser_sync::MakeWeakHandle( | 46 browser_sync::MakeWeakHandle( |
| 46 base::WeakPtr<sync_notifier::InvalidationStateTracker>()), | 47 base::WeakPtr<sync_notifier::InvalidationStateTracker>()), |
| 47 "fake_client_info")); | 48 "fake_client_info")); |
| 48 invalidation_notifier_->AddObserver(&mock_observer_); | 49 invalidation_notifier_->AddObserver(&mock_observer_); |
| 49 } | 50 } |
| 50 | 51 |
| 51 virtual void TearDown() { | 52 virtual void TearDown() { |
| 52 invalidation_notifier_->RemoveObserver(&mock_observer_); | 53 invalidation_notifier_->RemoveObserver(&mock_observer_); |
| 53 invalidation_notifier_.reset(); | 54 invalidation_notifier_.reset(); |
| 54 request_context_getter_ = NULL; | 55 request_context_getter_ = NULL; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 66 | 67 |
| 67 TEST_F(NonBlockingInvalidationNotifierTest, Basic) { | 68 TEST_F(NonBlockingInvalidationNotifierTest, Basic) { |
| 68 InSequence dummy; | 69 InSequence dummy; |
| 69 | 70 |
| 70 syncable::ModelTypePayloadMap type_payloads; | 71 syncable::ModelTypePayloadMap type_payloads; |
| 71 type_payloads[syncable::PREFERENCES] = "payload"; | 72 type_payloads[syncable::PREFERENCES] = "payload"; |
| 72 type_payloads[syncable::BOOKMARKS] = ""; | 73 type_payloads[syncable::BOOKMARKS] = ""; |
| 73 type_payloads[syncable::AUTOFILL] = ""; | 74 type_payloads[syncable::AUTOFILL] = ""; |
| 74 | 75 |
| 75 EXPECT_CALL(mock_observer_, OnNotificationStateChange(true)); | 76 EXPECT_CALL(mock_observer_, OnNotificationStateChange(true)); |
| 76 EXPECT_CALL(mock_observer_, StoreState("new_fake_state")); | |
| 77 EXPECT_CALL(mock_observer_, | 77 EXPECT_CALL(mock_observer_, |
| 78 OnIncomingNotification(type_payloads, | 78 OnIncomingNotification(type_payloads, |
| 79 REMOTE_NOTIFICATION)); | 79 REMOTE_NOTIFICATION)); |
| 80 EXPECT_CALL(mock_observer_, OnNotificationStateChange(false)); | 80 EXPECT_CALL(mock_observer_, OnNotificationStateChange(false)); |
| 81 | 81 |
| 82 invalidation_notifier_->SetState("fake_state"); | 82 invalidation_notifier_->SetStateDeprecated("fake_state"); |
| 83 invalidation_notifier_->SetUniqueId("fake_id"); | 83 invalidation_notifier_->SetUniqueId("fake_id"); |
| 84 invalidation_notifier_->UpdateCredentials("foo@bar.com", "fake_token"); | 84 invalidation_notifier_->UpdateCredentials("foo@bar.com", "fake_token"); |
| 85 | 85 |
| 86 invalidation_notifier_->OnNotificationStateChange(true); | 86 invalidation_notifier_->OnNotificationStateChange(true); |
| 87 invalidation_notifier_->StoreState("new_fake_state"); | |
| 88 invalidation_notifier_->OnIncomingNotification(type_payloads, | 87 invalidation_notifier_->OnIncomingNotification(type_payloads, |
| 89 REMOTE_NOTIFICATION); | 88 REMOTE_NOTIFICATION); |
| 90 invalidation_notifier_->OnNotificationStateChange(false); | 89 invalidation_notifier_->OnNotificationStateChange(false); |
| 91 | 90 |
| 92 ui_loop_.RunAllPending(); | 91 ui_loop_.RunAllPending(); |
| 93 } | 92 } |
| 94 | 93 |
| 95 } // namespace | 94 } // namespace |
| 96 | 95 |
| 97 } // namespace sync_notifier | 96 } // namespace sync_notifier |
| OLD | NEW |