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

Side by Side Diff: jingle/notifier/base/xmpp_connection_unittest.cc

Issue 10382003: Changes needed to roll libjingle r141 (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: 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
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 "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 29 matching lines...) Expand all
40 using ::testing::SaveArg; 40 using ::testing::SaveArg;
41 41
42 class MockPreXmppAuth : public buzz::PreXmppAuth { 42 class MockPreXmppAuth : public buzz::PreXmppAuth {
43 public: 43 public:
44 virtual ~MockPreXmppAuth() {} 44 virtual ~MockPreXmppAuth() {}
45 45
46 MOCK_METHOD2(ChooseBestSaslMechanism, 46 MOCK_METHOD2(ChooseBestSaslMechanism,
47 std::string(const std::vector<std::string>&, bool)); 47 std::string(const std::vector<std::string>&, bool));
48 MOCK_METHOD1(CreateSaslMechanism, 48 MOCK_METHOD1(CreateSaslMechanism,
49 buzz::SaslMechanism*(const std::string&)); 49 buzz::SaslMechanism*(const std::string&));
50 MOCK_METHOD4(StartPreXmppAuth, 50 MOCK_METHOD5(StartPreXmppAuth,
51 void(const buzz::Jid&, 51 void(const buzz::Jid&,
52 const talk_base::SocketAddress&, 52 const talk_base::SocketAddress&,
53 const talk_base::CryptString&, 53 const talk_base::CryptString&,
54 const std::string&,
54 const std::string&)); 55 const std::string&));
55 MOCK_CONST_METHOD0(IsAuthDone, bool()); 56 MOCK_CONST_METHOD0(IsAuthDone, bool());
56 MOCK_CONST_METHOD0(IsAuthorized, bool()); 57 MOCK_CONST_METHOD0(IsAuthorized, bool());
57 MOCK_CONST_METHOD0(HadError, bool()); 58 MOCK_CONST_METHOD0(HadError, bool());
58 MOCK_CONST_METHOD0(GetError, int()); 59 MOCK_CONST_METHOD0(GetError, int());
59 MOCK_CONST_METHOD0(GetCaptchaChallenge, buzz::CaptchaChallenge()); 60 MOCK_CONST_METHOD0(GetCaptchaChallenge, buzz::CaptchaChallenge());
60 MOCK_CONST_METHOD0(GetAuthCookie, std::string()); 61 MOCK_CONST_METHOD0(GetAuthToken, std::string());
62 MOCK_CONST_METHOD0(GetAuthMechanism, std::string());
61 }; 63 };
62 64
63 class MockXmppConnectionDelegate : public XmppConnection::Delegate { 65 class MockXmppConnectionDelegate : public XmppConnection::Delegate {
64 public: 66 public:
65 virtual ~MockXmppConnectionDelegate() {} 67 virtual ~MockXmppConnectionDelegate() {}
66 68
67 MOCK_METHOD1(OnConnect, void(base::WeakPtr<buzz::XmppTaskParentInterface>)); 69 MOCK_METHOD1(OnConnect, void(base::WeakPtr<buzz::XmppTaskParentInterface>));
68 MOCK_METHOD3(OnError, 70 MOCK_METHOD3(OnError,
69 void(buzz::XmppEngine::Error, int, const buzz::XmlElement*)); 71 void(buzz::XmppEngine::Error, int, const buzz::XmlElement*));
70 }; 72 };
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 XmppConnection xmpp_connection(buzz::XmppClientSettings(), 108 XmppConnection xmpp_connection(buzz::XmppClientSettings(),
107 url_request_context_getter_, 109 url_request_context_getter_,
108 &mock_xmpp_connection_delegate_, NULL); 110 &mock_xmpp_connection_delegate_, NULL);
109 111
110 // We need to do this *before* |xmpp_connection| gets destroyed or 112 // We need to do this *before* |xmpp_connection| gets destroyed or
111 // our delegate won't be called. 113 // our delegate won't be called.
112 message_loop_.RunAllPending(); 114 message_loop_.RunAllPending();
113 } 115 }
114 116
115 TEST_F(XmppConnectionTest, PreAuthFailure) { 117 TEST_F(XmppConnectionTest, PreAuthFailure) {
116 EXPECT_CALL(*mock_pre_xmpp_auth_, StartPreXmppAuth(_, _, _, _)); 118 EXPECT_CALL(*mock_pre_xmpp_auth_, StartPreXmppAuth(_, _, _, _,_));
117 EXPECT_CALL(*mock_pre_xmpp_auth_, IsAuthDone()).WillOnce(Return(true)); 119 EXPECT_CALL(*mock_pre_xmpp_auth_, IsAuthDone()).WillOnce(Return(true));
118 EXPECT_CALL(*mock_pre_xmpp_auth_, IsAuthorized()).WillOnce(Return(false)); 120 EXPECT_CALL(*mock_pre_xmpp_auth_, IsAuthorized()).WillOnce(Return(false));
119 EXPECT_CALL(*mock_pre_xmpp_auth_, HadError()).WillOnce(Return(true)); 121 EXPECT_CALL(*mock_pre_xmpp_auth_, HadError()).WillOnce(Return(true));
120 EXPECT_CALL(*mock_pre_xmpp_auth_, GetError()).WillOnce(Return(5)); 122 EXPECT_CALL(*mock_pre_xmpp_auth_, GetError()).WillOnce(Return(5));
121 123
122 EXPECT_CALL(mock_xmpp_connection_delegate_, 124 EXPECT_CALL(mock_xmpp_connection_delegate_,
123 OnError(buzz::XmppEngine::ERROR_AUTH, 5, NULL)); 125 OnError(buzz::XmppEngine::ERROR_AUTH, 5, NULL));
124 126
125 XmppConnection xmpp_connection( 127 XmppConnection xmpp_connection(
126 buzz::XmppClientSettings(), url_request_context_getter_, 128 buzz::XmppClientSettings(), url_request_context_getter_,
127 &mock_xmpp_connection_delegate_, mock_pre_xmpp_auth_.release()); 129 &mock_xmpp_connection_delegate_, mock_pre_xmpp_auth_.release());
128 130
129 // We need to do this *before* |xmpp_connection| gets destroyed or 131 // We need to do this *before* |xmpp_connection| gets destroyed or
130 // our delegate won't be called. 132 // our delegate won't be called.
131 message_loop_.RunAllPending(); 133 message_loop_.RunAllPending();
132 } 134 }
133 135
134 TEST_F(XmppConnectionTest, FailureAfterPreAuth) { 136 TEST_F(XmppConnectionTest, FailureAfterPreAuth) {
135 EXPECT_CALL(*mock_pre_xmpp_auth_, StartPreXmppAuth(_, _, _, _)); 137 EXPECT_CALL(*mock_pre_xmpp_auth_, StartPreXmppAuth(_, _, _, _,_));
136 EXPECT_CALL(*mock_pre_xmpp_auth_, IsAuthDone()).WillOnce(Return(true)); 138 EXPECT_CALL(*mock_pre_xmpp_auth_, IsAuthDone()).WillOnce(Return(true));
137 EXPECT_CALL(*mock_pre_xmpp_auth_, IsAuthorized()).WillOnce(Return(true)); 139 EXPECT_CALL(*mock_pre_xmpp_auth_, IsAuthorized()).WillOnce(Return(true));
138 EXPECT_CALL(*mock_pre_xmpp_auth_, GetAuthCookie()).WillOnce(Return("")); 140 EXPECT_CALL(*mock_pre_xmpp_auth_, GetAuthMechanism()).WillOnce(Return(""));
141 EXPECT_CALL(*mock_pre_xmpp_auth_, GetAuthToken()).WillOnce(Return(""));
139 142
140 EXPECT_CALL(mock_xmpp_connection_delegate_, 143 EXPECT_CALL(mock_xmpp_connection_delegate_,
141 OnError(buzz::XmppEngine::ERROR_NONE, 0, NULL)); 144 OnError(buzz::XmppEngine::ERROR_NONE, 0, NULL));
142 145
143 XmppConnection xmpp_connection( 146 XmppConnection xmpp_connection(
144 buzz::XmppClientSettings(), url_request_context_getter_, 147 buzz::XmppClientSettings(), url_request_context_getter_,
145 &mock_xmpp_connection_delegate_, mock_pre_xmpp_auth_.release()); 148 &mock_xmpp_connection_delegate_, mock_pre_xmpp_auth_.release());
146 149
147 // We need to do this *before* |xmpp_connection| gets destroyed or 150 // We need to do this *before* |xmpp_connection| gets destroyed or
148 // our delegate won't be called. 151 // our delegate won't be called.
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 .WillByDefault(Return(TASK_STATE_ERROR)); 239 .WillByDefault(Return(TASK_STATE_ERROR));
237 EXPECT_CALL(*task, ProcessStart()).Times(0); 240 EXPECT_CALL(*task, ProcessStart()).Times(0);
238 task->Start(); 241 task->Start();
239 } 242 }
240 243
241 // This should destroy |task_pump|, but |task| still shouldn't run. 244 // This should destroy |task_pump|, but |task| still shouldn't run.
242 message_loop_.RunAllPending(); 245 message_loop_.RunAllPending();
243 } 246 }
244 247
245 } // namespace notifier 248 } // namespace notifier
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698