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 "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 "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
11 #include "chrome/browser/sync/notifier/invalidation_version_tracker.h" | 11 #include "chrome/browser/sync/notifier/invalidation_version_tracker.h" |
12 #include "chrome/browser/sync/notifier/mock_sync_notifier_observer.h" | 12 #include "chrome/browser/sync/notifier/mock_sync_notifier_observer.h" |
13 #include "chrome/browser/sync/syncable/model_type.h" | 13 #include "chrome/browser/sync/syncable/model_type.h" |
14 #include "chrome/browser/sync/syncable/model_type_payload_map.h" | 14 #include "chrome/browser/sync/syncable/model_type_payload_map.h" |
15 #include "chrome/browser/sync/util/weak_handle.h" | 15 #include "chrome/browser/sync/util/weak_handle.h" |
16 #include "chrome/test/base/test_url_request_context_getter.h" | |
17 #include "content/test/test_browser_thread.h" | 16 #include "content/test/test_browser_thread.h" |
18 #include "jingle/notifier/base/fake_base_task.h" | 17 #include "jingle/notifier/base/fake_base_task.h" |
| 18 #include "net/url_request/url_request_test_util.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 | 21 |
22 namespace sync_notifier { | 22 namespace sync_notifier { |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 using ::testing::InSequence; | 26 using ::testing::InSequence; |
27 using ::testing::StrictMock; | 27 using ::testing::StrictMock; |
28 using content::BrowserThread; | 28 using content::BrowserThread; |
29 | 29 |
30 class NonBlockingInvalidationNotifierTest : public testing::Test { | 30 class NonBlockingInvalidationNotifierTest : public testing::Test { |
31 public: | 31 public: |
32 NonBlockingInvalidationNotifierTest() | 32 NonBlockingInvalidationNotifierTest() |
33 : io_thread_(BrowserThread::IO) {} | 33 : io_thread_(BrowserThread::IO) {} |
34 | 34 |
35 protected: | 35 protected: |
36 virtual void SetUp() { | 36 virtual void SetUp() { |
37 base::Thread::Options options; | 37 base::Thread::Options options; |
38 options.message_loop_type = MessageLoop::TYPE_IO; | 38 options.message_loop_type = MessageLoop::TYPE_IO; |
39 io_thread_.StartIOThread(); | 39 io_thread_.StartIOThread(); |
40 request_context_getter_ = new TestURLRequestContextGetter; | 40 request_context_getter_ = |
| 41 new TestURLRequestContextGetter( |
| 42 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
41 notifier::NotifierOptions notifier_options; | 43 notifier::NotifierOptions notifier_options; |
42 notifier_options.request_context_getter = request_context_getter_; | 44 notifier_options.request_context_getter = request_context_getter_; |
43 invalidation_notifier_.reset( | 45 invalidation_notifier_.reset( |
44 new NonBlockingInvalidationNotifier( | 46 new NonBlockingInvalidationNotifier( |
45 notifier_options, | 47 notifier_options, |
46 InvalidationVersionMap(), | 48 InvalidationVersionMap(), |
47 browser_sync::MakeWeakHandle( | 49 browser_sync::MakeWeakHandle( |
48 base::WeakPtr<sync_notifier::InvalidationVersionTracker>()), | 50 base::WeakPtr<sync_notifier::InvalidationVersionTracker>()), |
49 "fake_client_info")); | 51 "fake_client_info")); |
50 invalidation_notifier_->AddObserver(&mock_observer_); | 52 invalidation_notifier_->AddObserver(&mock_observer_); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 invalidation_notifier_->OnIncomingNotification(type_payloads, | 92 invalidation_notifier_->OnIncomingNotification(type_payloads, |
91 REMOTE_NOTIFICATION); | 93 REMOTE_NOTIFICATION); |
92 invalidation_notifier_->OnNotificationStateChange(false); | 94 invalidation_notifier_->OnNotificationStateChange(false); |
93 | 95 |
94 ui_loop_.RunAllPending(); | 96 ui_loop_.RunAllPending(); |
95 } | 97 } |
96 | 98 |
97 } // namespace | 99 } // namespace |
98 | 100 |
99 } // namespace sync_notifier | 101 } // namespace sync_notifier |
OLD | NEW |