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" |
11 #include "net/url_request/url_request_test_util.h" | 11 #include "net/url_request/url_request_test_util.h" |
12 #include "sync/notifier/invalidation_version_tracker.h" | 12 #include "sync/notifier/invalidation_state_tracker.h" |
13 #include "sync/notifier/mock_sync_notifier_observer.h" | 13 #include "sync/notifier/mock_sync_notifier_observer.h" |
14 #include "sync/syncable/model_type.h" | 14 #include "sync/syncable/model_type.h" |
15 #include "sync/syncable/model_type_payload_map.h" | 15 #include "sync/syncable/model_type_payload_map.h" |
16 #include "sync/util/weak_handle.h" | 16 #include "sync/util/weak_handle.h" |
17 #include "testing/gmock/include/gmock/gmock.h" | 17 #include "testing/gmock/include/gmock/gmock.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 | 19 |
20 namespace sync_notifier { | 20 namespace sync_notifier { |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 using ::testing::InSequence; | 24 using ::testing::InSequence; |
25 using ::testing::StrictMock; | 25 using ::testing::StrictMock; |
26 | 26 |
27 class InvalidationNotifierTest : public testing::Test { | 27 class InvalidationNotifierTest : public testing::Test { |
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 browser_sync::MakeWeakHandle( | 38 browser_sync::MakeWeakHandle( |
39 base::WeakPtr<InvalidationVersionTracker>()), | 39 base::WeakPtr<InvalidationStateTracker>()), |
40 "fake_client_info")); | 40 "fake_client_info")); |
41 invalidation_notifier_->AddObserver(&mock_observer_); | 41 invalidation_notifier_->AddObserver(&mock_observer_); |
42 } | 42 } |
43 | 43 |
44 virtual void TearDown() { | 44 virtual void TearDown() { |
45 invalidation_notifier_->RemoveObserver(&mock_observer_); | 45 invalidation_notifier_->RemoveObserver(&mock_observer_); |
46 // Stopping the invalidation notifier stops its scheduler, which deletes any | 46 // Stopping the invalidation notifier stops its scheduler, which deletes any |
47 // pending tasks without running them. Some tasks "run and delete" another | 47 // 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. | 48 // 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 | 49 // Stopping does not schedule any tasks, so it's both necessary and |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 // Shouldn't trigger notification state change. | 93 // Shouldn't trigger notification state change. |
94 invalidation_notifier_->OnDisconnect(); | 94 invalidation_notifier_->OnDisconnect(); |
95 invalidation_notifier_->OnConnect(fake_base_task_.AsWeakPtr()); | 95 invalidation_notifier_->OnConnect(fake_base_task_.AsWeakPtr()); |
96 | 96 |
97 invalidation_notifier_->OnSessionStatusChanged(false); | 97 invalidation_notifier_->OnSessionStatusChanged(false); |
98 } | 98 } |
99 | 99 |
100 } // namespace | 100 } // namespace |
101 | 101 |
102 } // namespace sync_notifier | 102 } // namespace sync_notifier |
OLD | NEW |