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/sync_notifier_factory.h" | 5 #include "chrome/browser/sync/notifier/sync_notifier_factory.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
14 #include "chrome/browser/sync/notifier/invalidation_version_tracker.h" | 14 #include "chrome/browser/sync/notifier/invalidation_version_tracker.h" |
15 #include "chrome/browser/sync/notifier/mock_sync_notifier_observer.h" | 15 #include "chrome/browser/sync/notifier/mock_sync_notifier_observer.h" |
16 #include "chrome/browser/sync/notifier/sync_notifier.h" | 16 #include "chrome/browser/sync/notifier/sync_notifier.h" |
17 #include "chrome/browser/sync/syncable/model_type.h" | 17 #include "chrome/browser/sync/syncable/model_type.h" |
18 #include "chrome/browser/sync/syncable/model_type_payload_map.h" | 18 #include "chrome/browser/sync/syncable/model_type_payload_map.h" |
19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
20 #include "chrome/test/base/test_url_request_context_getter.h" | |
21 #include "content/test/test_browser_thread.h" | 20 #include "content/test/test_browser_thread.h" |
| 21 #include "net/url_request/url_request_test_util.h" |
22 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
24 | 24 |
25 namespace sync_notifier { | 25 namespace sync_notifier { |
26 namespace { | 26 namespace { |
27 | 27 |
28 using ::testing::Mock; | 28 using ::testing::Mock; |
29 using ::testing::NiceMock; | 29 using ::testing::NiceMock; |
30 using ::testing::StrictMock; | 30 using ::testing::StrictMock; |
31 using content::BrowserThread; | 31 using content::BrowserThread; |
32 | 32 |
33 class SyncNotifierFactoryTest : public testing::Test { | 33 class SyncNotifierFactoryTest : public testing::Test { |
34 protected: | 34 protected: |
35 SyncNotifierFactoryTest() | 35 SyncNotifierFactoryTest() |
36 : ui_thread_(BrowserThread::UI, &message_loop_), | 36 : ui_thread_(BrowserThread::UI, &message_loop_), |
37 io_thread_(BrowserThread::IO, &message_loop_), | 37 io_thread_(BrowserThread::IO, &message_loop_), |
38 command_line_(CommandLine::NO_PROGRAM) {} | 38 command_line_(CommandLine::NO_PROGRAM) {} |
39 virtual ~SyncNotifierFactoryTest() {} | 39 virtual ~SyncNotifierFactoryTest() {} |
40 | 40 |
41 virtual void SetUp() OVERRIDE { | 41 virtual void SetUp() OVERRIDE { |
42 request_context_getter_ = new TestURLRequestContextGetter; | 42 request_context_getter_ = |
| 43 new TestURLRequestContextGetter( |
| 44 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); |
43 factory_.reset(new SyncNotifierFactory( | 45 factory_.reset(new SyncNotifierFactory( |
44 "fake_client_info", | 46 "fake_client_info", |
45 request_context_getter_, | 47 request_context_getter_, |
46 base::WeakPtr<sync_notifier::InvalidationVersionTracker>(), | 48 base::WeakPtr<sync_notifier::InvalidationVersionTracker>(), |
47 command_line_)); | 49 command_line_)); |
48 message_loop_.RunAllPending(); | 50 message_loop_.RunAllPending(); |
49 } | 51 } |
50 | 52 |
51 virtual void TearDown() OVERRIDE { | 53 virtual void TearDown() OVERRIDE { |
52 Mock::VerifyAndClearExpectations(&mock_observer_); | 54 Mock::VerifyAndClearExpectations(&mock_observer_); |
(...skipping 23 matching lines...) Expand all Loading... |
76 TEST_F(SyncNotifierFactoryTest, Basic_P2P) { | 78 TEST_F(SyncNotifierFactoryTest, Basic_P2P) { |
77 command_line_.AppendSwitchASCII(switches::kSyncNotificationMethod, "p2p"); | 79 command_line_.AppendSwitchASCII(switches::kSyncNotificationMethod, "p2p"); |
78 scoped_ptr<SyncNotifier> notifier(factory_->CreateSyncNotifier()); | 80 scoped_ptr<SyncNotifier> notifier(factory_->CreateSyncNotifier()); |
79 ASSERT_TRUE(notifier.get()); | 81 ASSERT_TRUE(notifier.get()); |
80 notifier->AddObserver(&mock_observer_); | 82 notifier->AddObserver(&mock_observer_); |
81 notifier->RemoveObserver(&mock_observer_); | 83 notifier->RemoveObserver(&mock_observer_); |
82 } | 84 } |
83 | 85 |
84 } // namespace | 86 } // namespace |
85 } // namespace sync_notifier | 87 } // namespace sync_notifier |
OLD | NEW |