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 "jingle/notifier/base/xmpp_connection.h" | 5 #include "jingle/notifier/base/xmpp_connection.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 | 68 |
69 MOCK_METHOD1(OnConnect, void(base::WeakPtr<buzz::XmppTaskParentInterface>)); | 69 MOCK_METHOD1(OnConnect, void(base::WeakPtr<buzz::XmppTaskParentInterface>)); |
70 MOCK_METHOD3(OnError, | 70 MOCK_METHOD3(OnError, |
71 void(buzz::XmppEngine::Error, int, const buzz::XmlElement*)); | 71 void(buzz::XmppEngine::Error, int, const buzz::XmlElement*)); |
72 }; | 72 }; |
73 | 73 |
74 class XmppConnectionTest : public testing::Test { | 74 class XmppConnectionTest : public testing::Test { |
75 protected: | 75 protected: |
76 XmppConnectionTest() | 76 XmppConnectionTest() |
77 : mock_pre_xmpp_auth_(new MockPreXmppAuth()), | 77 : mock_pre_xmpp_auth_(new MockPreXmppAuth()), |
78 url_request_context_getter_(new TestURLRequestContextGetter( | 78 url_request_context_getter_(new net::TestURLRequestContextGetter( |
79 message_loop_.message_loop_proxy())) {} | 79 message_loop_.message_loop_proxy())) {} |
80 | 80 |
81 virtual ~XmppConnectionTest() {} | 81 virtual ~XmppConnectionTest() {} |
82 | 82 |
83 virtual void TearDown() { | 83 virtual void TearDown() { |
84 // Clear out any messages posted by XmppConnection's destructor. | 84 // Clear out any messages posted by XmppConnection's destructor. |
85 message_loop_.RunAllPending(); | 85 message_loop_.RunAllPending(); |
86 } | 86 } |
87 | 87 |
88 // Needed by XmppConnection. | 88 // Needed by XmppConnection. |
89 MessageLoop message_loop_; | 89 MessageLoop message_loop_; |
90 MockXmppConnectionDelegate mock_xmpp_connection_delegate_; | 90 MockXmppConnectionDelegate mock_xmpp_connection_delegate_; |
91 scoped_ptr<MockPreXmppAuth> mock_pre_xmpp_auth_; | 91 scoped_ptr<MockPreXmppAuth> mock_pre_xmpp_auth_; |
92 scoped_refptr<TestURLRequestContextGetter> url_request_context_getter_; | 92 scoped_refptr<net::TestURLRequestContextGetter> url_request_context_getter_; |
93 }; | 93 }; |
94 | 94 |
95 TEST_F(XmppConnectionTest, CreateDestroy) { | 95 TEST_F(XmppConnectionTest, CreateDestroy) { |
96 XmppConnection xmpp_connection(buzz::XmppClientSettings(), | 96 XmppConnection xmpp_connection(buzz::XmppClientSettings(), |
97 url_request_context_getter_, | 97 url_request_context_getter_, |
98 &mock_xmpp_connection_delegate_, NULL); | 98 &mock_xmpp_connection_delegate_, NULL); |
99 } | 99 } |
100 | 100 |
101 #if !defined(_MSC_VER) || _MSC_VER < 1700 // http://crbug.com/158570 | 101 #if !defined(_MSC_VER) || _MSC_VER < 1700 // http://crbug.com/158570 |
102 TEST_F(XmppConnectionTest, ImmediateFailure) { | 102 TEST_F(XmppConnectionTest, ImmediateFailure) { |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 .WillByDefault(Return(TASK_STATE_ERROR)); | 244 .WillByDefault(Return(TASK_STATE_ERROR)); |
245 EXPECT_CALL(*task, ProcessStart()).Times(0); | 245 EXPECT_CALL(*task, ProcessStart()).Times(0); |
246 task->Start(); | 246 task->Start(); |
247 } | 247 } |
248 | 248 |
249 // This should destroy |task_pump|, but |task| still shouldn't run. | 249 // This should destroy |task_pump|, but |task| still shouldn't run. |
250 message_loop_.RunAllPending(); | 250 message_loop_.RunAllPending(); |
251 } | 251 } |
252 | 252 |
253 } // namespace notifier | 253 } // namespace notifier |
OLD | NEW |