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

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

Issue 10408067: [net] Switch TestURLRequestContext to use MockCachingHostResolver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased to trunk. 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
« no previous file with comments | « sync/notifier/DEPS ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/p2p_notifier.h" 5 #include "sync/notifier/p2p_notifier.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "jingle/notifier/base/fake_base_task.h" 12 #include "jingle/notifier/base/fake_base_task.h"
13 #include "jingle/notifier/base/notifier_options.h" 13 #include "jingle/notifier/base/notifier_options.h"
14 #include "jingle/notifier/listener/push_client.h" 14 #include "jingle/notifier/listener/push_client.h"
15 #include "net/base/mock_host_resolver.h"
15 #include "net/url_request/url_request_test_util.h" 16 #include "net/url_request/url_request_test_util.h"
16 #include "sync/notifier/mock_sync_notifier_observer.h" 17 #include "sync/notifier/mock_sync_notifier_observer.h"
17 #include "sync/syncable/model_type.h" 18 #include "sync/syncable/model_type.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::_; 25 using ::testing::_;
25 using ::testing::Mock; 26 using ::testing::Mock;
26 using ::testing::StrictMock; 27 using ::testing::StrictMock;
27 28
29 class MyTestURLRequestContext : public TestURLRequestContext {
30 public:
31 MyTestURLRequestContext() : TestURLRequestContext(true) {
32 context_storage_.set_host_resolver(new net::HangingHostResolver());
33 Init();
34 }
35 virtual ~MyTestURLRequestContext() {}
36 };
37
28 class P2PNotifierTest : public testing::Test { 38 class P2PNotifierTest : public testing::Test {
29 protected: 39 protected:
30 P2PNotifierTest() { 40 P2PNotifierTest() {
31 notifier_options_.request_context_getter = 41 notifier_options_.request_context_getter =
32 new TestURLRequestContextGetter(message_loop_.message_loop_proxy()); 42 new TestURLRequestContextGetter(
43 message_loop_.message_loop_proxy(),
44 scoped_ptr<TestURLRequestContext>(new MyTestURLRequestContext()));
33 } 45 }
34 46
35 virtual ~P2PNotifierTest() {} 47 virtual ~P2PNotifierTest() {}
36 48
37 virtual void SetUp() OVERRIDE { 49 virtual void SetUp() OVERRIDE {
38 p2p_notifier_.reset(new P2PNotifier(notifier_options_, NOTIFY_OTHERS)); 50 p2p_notifier_.reset(new P2PNotifier(notifier_options_, NOTIFY_OTHERS));
39 p2p_notifier_->AddObserver(&mock_observer_); 51 p2p_notifier_->AddObserver(&mock_observer_);
40 } 52 }
41 53
42 virtual void TearDown() OVERRIDE { 54 virtual void TearDown() OVERRIDE {
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 Mock::VerifyAndClearExpectations(&mock_observer_); 266 Mock::VerifyAndClearExpectations(&mock_observer_);
255 p2p_notifier_->SendNotificationDataForTest( 267 p2p_notifier_->SendNotificationDataForTest(
256 P2PNotificationData("sender2", NOTIFY_ALL, syncable::ModelTypeSet())); 268 P2PNotificationData("sender2", NOTIFY_ALL, syncable::ModelTypeSet()));
257 269
258 message_loop_.RunAllPending(); 270 message_loop_.RunAllPending();
259 } 271 }
260 272
261 } // namespace 273 } // namespace
262 274
263 } // namespace sync_notifier 275 } // namespace sync_notifier
OLDNEW
« no previous file with comments | « sync/notifier/DEPS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698