OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/sync/notifier/non_blocking_invalidation_notifier.h" | 5 #include "chrome/browser/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 "chrome/browser/sync/notifier/invalidation_version_tracker.h" | 10 #include "chrome/browser/sync/notifier/invalidation_version_tracker.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 MessageLoop ui_loop_; | 60 MessageLoop ui_loop_; |
61 content::TestBrowserThread io_thread_; | 61 content::TestBrowserThread io_thread_; |
62 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | 62 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; |
63 scoped_ptr<NonBlockingInvalidationNotifier> invalidation_notifier_; | 63 scoped_ptr<NonBlockingInvalidationNotifier> invalidation_notifier_; |
64 StrictMock<MockSyncNotifierObserver> mock_observer_; | 64 StrictMock<MockSyncNotifierObserver> mock_observer_; |
65 notifier::FakeBaseTask fake_base_task_; | 65 notifier::FakeBaseTask fake_base_task_; |
66 }; | 66 }; |
67 | 67 |
68 TEST_F(NonBlockingInvalidationNotifierTest, Basic) { | 68 TEST_F(NonBlockingInvalidationNotifierTest, Basic) { |
69 syncable::ModelTypeSet types; | 69 InSequence dummy; |
70 types.insert(syncable::BOOKMARKS); | |
71 types.insert(syncable::AUTOFILL); | |
72 | 70 |
| 71 syncable::ModelTypePayloadMap type_payloads; |
| 72 type_payloads[syncable::PREFERENCES] = "payload"; |
| 73 type_payloads[syncable::BOOKMARKS] = ""; |
| 74 type_payloads[syncable::AUTOFILL] = ""; |
| 75 |
| 76 EXPECT_CALL(mock_observer_, OnNotificationStateChange(true)); |
| 77 EXPECT_CALL(mock_observer_, StoreState("new_fake_state")); |
| 78 EXPECT_CALL(mock_observer_, OnIncomingNotification(type_payloads)); |
| 79 EXPECT_CALL(mock_observer_, OnNotificationStateChange(false)); |
| 80 |
| 81 invalidation_notifier_->SetState("fake_state"); |
73 invalidation_notifier_->SetUniqueId("fake_id"); | 82 invalidation_notifier_->SetUniqueId("fake_id"); |
74 invalidation_notifier_->SetState("fake_state"); | |
75 invalidation_notifier_->UpdateCredentials("foo@bar.com", "fake_token"); | 83 invalidation_notifier_->UpdateCredentials("foo@bar.com", "fake_token"); |
76 invalidation_notifier_->UpdateEnabledTypes(types); | 84 |
| 85 invalidation_notifier_->OnNotificationStateChange(true); |
| 86 invalidation_notifier_->StoreState("new_fake_state"); |
| 87 invalidation_notifier_->OnIncomingNotification(type_payloads); |
| 88 invalidation_notifier_->OnNotificationStateChange(false); |
| 89 |
| 90 ui_loop_.RunAllPending(); |
77 } | 91 } |
78 | 92 |
79 // TODO(akalin): Add synchronous operations for testing to | |
80 // NonBlockingInvalidationNotifierTest and use that to test it. | |
81 | |
82 } // namespace | 93 } // namespace |
83 | 94 |
84 } // namespace sync_notifier | 95 } // namespace sync_notifier |
OLD | NEW |