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

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

Issue 10436013: [Sync] Make InvalidationNotifier use PushClient (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to head Created 8 years, 7 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"
11 #include "jingle/notifier/listener/fake_push_client.h"
11 #include "net/url_request/url_request_test_util.h" 12 #include "net/url_request/url_request_test_util.h"
12 #include "sync/notifier/invalidation_state_tracker.h" 13 #include "sync/notifier/invalidation_state_tracker.h"
13 #include "sync/notifier/mock_sync_notifier_observer.h" 14 #include "sync/notifier/mock_sync_notifier_observer.h"
14 #include "sync/syncable/model_type.h" 15 #include "sync/syncable/model_type.h"
15 #include "sync/syncable/model_type_payload_map.h" 16 #include "sync/syncable/model_type_payload_map.h"
16 #include "sync/util/weak_handle.h" 17 #include "sync/util/weak_handle.h"
17 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
19 20
20 namespace sync_notifier { 21 namespace sync_notifier {
21 22
22 namespace { 23 namespace {
23 24
24 using ::testing::InSequence; 25 using ::testing::InSequence;
25 using ::testing::StrictMock; 26 using ::testing::StrictMock;
26 27
27 class InvalidationNotifierTest : public testing::Test { 28 class InvalidationNotifierTest : public testing::Test {
28 protected: 29 protected:
29 virtual void SetUp() { 30 virtual void SetUp() {
30 notifier::NotifierOptions notifier_options; 31 notifier::NotifierOptions notifier_options;
31 // Note: URLRequestContextGetters are ref-counted. 32 // Note: URLRequestContextGetters are ref-counted.
32 notifier_options.request_context_getter = 33 notifier_options.request_context_getter =
33 new TestURLRequestContextGetter(message_loop_.message_loop_proxy()); 34 new TestURLRequestContextGetter(message_loop_.message_loop_proxy());
34 invalidation_notifier_.reset( 35 invalidation_notifier_.reset(
35 new InvalidationNotifier( 36 new InvalidationNotifier(
36 notifier_options, 37 scoped_ptr<notifier::PushClient>(new notifier::FakePushClient()),
37 InvalidationVersionMap(), 38 InvalidationVersionMap(),
38 browser_sync::MakeWeakHandle( 39 browser_sync::MakeWeakHandle(
39 base::WeakPtr<InvalidationStateTracker>()), 40 base::WeakPtr<InvalidationStateTracker>()),
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
(...skipping 29 matching lines...) Expand all
76 EXPECT_CALL(mock_observer_, StoreState("new_fake_state")); 77 EXPECT_CALL(mock_observer_, StoreState("new_fake_state"));
77 EXPECT_CALL(mock_observer_, 78 EXPECT_CALL(mock_observer_,
78 OnIncomingNotification(type_payloads, 79 OnIncomingNotification(type_payloads,
79 REMOTE_NOTIFICATION)); 80 REMOTE_NOTIFICATION));
80 EXPECT_CALL(mock_observer_, OnNotificationStateChange(false)); 81 EXPECT_CALL(mock_observer_, OnNotificationStateChange(false));
81 82
82 invalidation_notifier_->SetState("fake_state"); 83 invalidation_notifier_->SetState("fake_state");
83 invalidation_notifier_->SetUniqueId("fake_id"); 84 invalidation_notifier_->SetUniqueId("fake_id");
84 invalidation_notifier_->UpdateCredentials("foo@bar.com", "fake_token"); 85 invalidation_notifier_->UpdateCredentials("foo@bar.com", "fake_token");
85 86
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"); 89 invalidation_notifier_->WriteState("new_fake_state");
90 90
91 invalidation_notifier_->OnInvalidate(type_payloads); 91 invalidation_notifier_->OnInvalidate(type_payloads);
92 92
93 // Shouldn't trigger notification state change.
94 invalidation_notifier_->OnDisconnect();
95 invalidation_notifier_->OnConnect(fake_base_task_.AsWeakPtr());
96
97 invalidation_notifier_->OnSessionStatusChanged(false); 93 invalidation_notifier_->OnSessionStatusChanged(false);
98 } 94 }
99 95
100 } // namespace 96 } // namespace
101 97
102 } // namespace sync_notifier 98 } // namespace sync_notifier
OLDNEW
« no previous file with comments | « sync/notifier/invalidation_notifier.cc ('k') | sync/notifier/non_blocking_invalidation_notifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698