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

Side by Side Diff: sync/notifier/invalidation_notifier_unittest.cc

Issue 10451060: sync: migrate invalidation state from syncable::Directory to InvalidationStorage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: init Created 8 years, 6 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) 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 17 matching lines...) Expand all
28 protected: 28 protected:
29 virtual void SetUp() { 29 virtual void SetUp() {
30 notifier::NotifierOptions notifier_options; 30 notifier::NotifierOptions notifier_options;
31 // Note: URLRequestContextGetters are ref-counted. 31 // Note: URLRequestContextGetters are ref-counted.
32 notifier_options.request_context_getter = 32 notifier_options.request_context_getter =
33 new TestURLRequestContextGetter(message_loop_.message_loop_proxy()); 33 new TestURLRequestContextGetter(message_loop_.message_loop_proxy());
34 invalidation_notifier_.reset( 34 invalidation_notifier_.reset(
35 new InvalidationNotifier( 35 new InvalidationNotifier(
36 notifier_options, 36 notifier_options,
37 InvalidationVersionMap(), 37 InvalidationVersionMap(),
38 std::string(), // initial_invalidation_state
38 browser_sync::MakeWeakHandle( 39 browser_sync::MakeWeakHandle(
39 base::WeakPtr<InvalidationStateTracker>()), 40 base::WeakPtr<InvalidationStateTracker>()),
Nicolas Zea 2012/05/29 23:32:53 Seems like this would be a good place to test the
tim (not reviewing) 2012/05/30 02:02:47 Done, thanks!
40 "fake_client_info")); 41 "fake_client_info"));
41 invalidation_notifier_->AddObserver(&mock_observer_); 42 invalidation_notifier_->AddObserver(&mock_observer_);
42 } 43 }
43 44
44 virtual void TearDown() { 45 virtual void TearDown() {
45 invalidation_notifier_->RemoveObserver(&mock_observer_); 46 invalidation_notifier_->RemoveObserver(&mock_observer_);
46 // Stopping the invalidation notifier stops its scheduler, which deletes any 47 // Stopping the invalidation notifier stops its scheduler, which deletes any
47 // pending tasks without running them. Some tasks "run and delete" another 48 // pending tasks without running them. Some tasks "run and delete" another
48 // task, so they must be run in order to avoid leaking the inner task. 49 // task, so they must be run in order to avoid leaking the inner task.
49 // Stopping does not schedule any tasks, so it's both necessary and 50 // Stopping does not schedule any tasks, so it's both necessary and
(...skipping 16 matching lines...) Expand all
66 #endif 67 #endif
67 TEST_F(InvalidationNotifierTest, MAYBE_Basic) { 68 TEST_F(InvalidationNotifierTest, MAYBE_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_->OnConnect(fake_base_task_.AsWeakPtr()); 86 invalidation_notifier_->OnConnect(fake_base_task_.AsWeakPtr());
87 invalidation_notifier_->OnSessionStatusChanged(true); 87 invalidation_notifier_->OnSessionStatusChanged(true);
88 88
89 invalidation_notifier_->WriteState("new_fake_state");
90
91 invalidation_notifier_->OnInvalidate(type_payloads); 89 invalidation_notifier_->OnInvalidate(type_payloads);
92 90
93 // Shouldn't trigger notification state change. 91 // Shouldn't trigger notification state change.
94 invalidation_notifier_->OnDisconnect(); 92 invalidation_notifier_->OnDisconnect();
95 invalidation_notifier_->OnConnect(fake_base_task_.AsWeakPtr()); 93 invalidation_notifier_->OnConnect(fake_base_task_.AsWeakPtr());
96 94
97 invalidation_notifier_->OnSessionStatusChanged(false); 95 invalidation_notifier_->OnSessionStatusChanged(false);
98 } 96 }
99 97
100 } // namespace 98 } // namespace
101 99
102 } // namespace sync_notifier 100 } // namespace sync_notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698