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/invalidation_notifier.h" | 5 #include "chrome/browser/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 "chrome/browser/sync/notifier/mock_sync_notifier_observer.h" | 9 #include "chrome/browser/sync/notifier/mock_sync_notifier_observer.h" |
10 #include "chrome/browser/sync/syncable/model_type.h" | 10 #include "chrome/browser/sync/syncable/model_type.h" |
11 #include "chrome/browser/sync/syncable/model_type_payload_map.h" | 11 #include "chrome/browser/sync/syncable/model_type_payload_map.h" |
12 #include "chrome/test/base/test_url_request_context_getter.h" | 12 #include "chrome/test/base/test_url_request_context_getter.h" |
13 #include "content/browser/browser_thread.h" | 13 #include "content/browser/browser_thread.h" |
14 #include "jingle/notifier/base/fake_base_task.h" | 14 #include "jingle/notifier/base/fake_base_task.h" |
15 #include "jingle/notifier/base/notifier_options.h" | |
15 #include "net/base/cert_verifier.h" | 16 #include "net/base/cert_verifier.h" |
16 #include "net/base/host_resolver.h" | 17 #include "net/base/host_resolver.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 public: | 29 public: |
29 InvalidationNotifierTest() : io_thread_(BrowserThread::IO, &message_loop_) {} | 30 InvalidationNotifierTest() : io_thread_(BrowserThread::IO, &message_loop_) {} |
30 | 31 |
31 protected: | 32 protected: |
32 virtual void SetUp() { | 33 virtual void SetUp() { |
33 request_context_getter_ = new TestURLRequestContextGetter; | |
34 notifier::NotifierOptions notifier_options; | 34 notifier::NotifierOptions notifier_options; |
35 notifier_options.request_context_getter = request_context_getter_; | 35 notifier_options.request_context_getter = |
36 new TestURLRequestContextGetter(); | |
36 invalidation_notifier_.reset(new InvalidationNotifier(notifier_options, | 37 invalidation_notifier_.reset(new InvalidationNotifier(notifier_options, |
Nicolas Zea
2011/08/26 21:19:14
If this takes ownership of the request_context_get
akalin
2011/08/26 22:42:27
It's ref-counted, so it's not owned by anything.
| |
37 "fake_client_info")); | 38 "fake_client_info")); |
38 invalidation_notifier_->AddObserver(&mock_observer_); | 39 invalidation_notifier_->AddObserver(&mock_observer_); |
39 } | 40 } |
40 | 41 |
41 virtual void TearDown() { | 42 virtual void TearDown() { |
42 invalidation_notifier_->RemoveObserver(&mock_observer_); | 43 invalidation_notifier_->RemoveObserver(&mock_observer_); |
43 invalidation_notifier_.reset(); | 44 invalidation_notifier_.reset(); |
44 request_context_getter_ = NULL; | |
45 } | 45 } |
46 | 46 |
47 MessageLoop message_loop_; | 47 MessageLoop message_loop_; |
48 scoped_refptr<net::URLRequestContextGetter> request_context_getter_; | |
49 scoped_ptr<InvalidationNotifier> invalidation_notifier_; | 48 scoped_ptr<InvalidationNotifier> invalidation_notifier_; |
50 StrictMock<MockSyncNotifierObserver> mock_observer_; | 49 StrictMock<MockSyncNotifierObserver> mock_observer_; |
51 notifier::FakeBaseTask fake_base_task_; | 50 notifier::FakeBaseTask fake_base_task_; |
52 // Since this test calls HostResolver code, we need an IO thread. | 51 // Since this test calls HostResolver code, we need an IO thread. |
53 BrowserThread io_thread_; | 52 BrowserThread io_thread_; |
54 }; | 53 }; |
55 | 54 |
56 TEST_F(InvalidationNotifierTest, Basic) { | 55 TEST_F(InvalidationNotifierTest, Basic) { |
57 InSequence dummy; | 56 InSequence dummy; |
58 | 57 |
(...skipping 20 matching lines...) Expand all Loading... | |
79 // Shouldn't trigger notification state change. | 78 // Shouldn't trigger notification state change. |
80 invalidation_notifier_->OnDisconnect(); | 79 invalidation_notifier_->OnDisconnect(); |
81 invalidation_notifier_->OnConnect(fake_base_task_.AsWeakPtr()); | 80 invalidation_notifier_->OnConnect(fake_base_task_.AsWeakPtr()); |
82 | 81 |
83 invalidation_notifier_->OnSessionStatusChanged(false); | 82 invalidation_notifier_->OnSessionStatusChanged(false); |
84 } | 83 } |
85 | 84 |
86 } // namespace | 85 } // namespace |
87 | 86 |
88 } // namespace sync_notifier | 87 } // namespace sync_notifier |
OLD | NEW |