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

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

Issue 11421172: jingle: Update the calls from RunAllPending() to RunUntilIdle(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 net::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_.RunUntilIdle();
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<net::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) {
103 // ChromeAsyncSocket::Connect() will always return false since we're 103 // ChromeAsyncSocket::Connect() will always return false since we're
104 // not setting a valid host, but this gets bubbled up as ERROR_NONE 104 // not setting a valid host, but this gets bubbled up as ERROR_NONE
105 // due to XmppClient's inconsistent error-handling. 105 // due to XmppClient's inconsistent error-handling.
106 EXPECT_CALL(mock_xmpp_connection_delegate_, 106 EXPECT_CALL(mock_xmpp_connection_delegate_,
107 OnError(buzz::XmppEngine::ERROR_NONE, 0, NULL)); 107 OnError(buzz::XmppEngine::ERROR_NONE, 0, NULL));
108 108
109 XmppConnection xmpp_connection(buzz::XmppClientSettings(), 109 XmppConnection xmpp_connection(buzz::XmppClientSettings(),
110 url_request_context_getter_, 110 url_request_context_getter_,
111 &mock_xmpp_connection_delegate_, NULL); 111 &mock_xmpp_connection_delegate_, NULL);
112 112
113 // We need to do this *before* |xmpp_connection| gets destroyed or 113 // We need to do this *before* |xmpp_connection| gets destroyed or
114 // our delegate won't be called. 114 // our delegate won't be called.
115 message_loop_.RunAllPending(); 115 message_loop_.RunUntilIdle();
116 } 116 }
117 117
118 TEST_F(XmppConnectionTest, PreAuthFailure) { 118 TEST_F(XmppConnectionTest, PreAuthFailure) {
119 EXPECT_CALL(*mock_pre_xmpp_auth_, StartPreXmppAuth(_, _, _, _,_)); 119 EXPECT_CALL(*mock_pre_xmpp_auth_, StartPreXmppAuth(_, _, _, _,_));
120 EXPECT_CALL(*mock_pre_xmpp_auth_, IsAuthDone()).WillOnce(Return(true)); 120 EXPECT_CALL(*mock_pre_xmpp_auth_, IsAuthDone()).WillOnce(Return(true));
121 EXPECT_CALL(*mock_pre_xmpp_auth_, IsAuthorized()).WillOnce(Return(false)); 121 EXPECT_CALL(*mock_pre_xmpp_auth_, IsAuthorized()).WillOnce(Return(false));
122 EXPECT_CALL(*mock_pre_xmpp_auth_, HadError()).WillOnce(Return(true)); 122 EXPECT_CALL(*mock_pre_xmpp_auth_, HadError()).WillOnce(Return(true));
123 EXPECT_CALL(*mock_pre_xmpp_auth_, GetError()).WillOnce(Return(5)); 123 EXPECT_CALL(*mock_pre_xmpp_auth_, GetError()).WillOnce(Return(5));
124 124
125 EXPECT_CALL(mock_xmpp_connection_delegate_, 125 EXPECT_CALL(mock_xmpp_connection_delegate_,
126 OnError(buzz::XmppEngine::ERROR_AUTH, 5, NULL)); 126 OnError(buzz::XmppEngine::ERROR_AUTH, 5, NULL));
127 127
128 XmppConnection xmpp_connection( 128 XmppConnection xmpp_connection(
129 buzz::XmppClientSettings(), url_request_context_getter_, 129 buzz::XmppClientSettings(), url_request_context_getter_,
130 &mock_xmpp_connection_delegate_, mock_pre_xmpp_auth_.release()); 130 &mock_xmpp_connection_delegate_, mock_pre_xmpp_auth_.release());
131 131
132 // We need to do this *before* |xmpp_connection| gets destroyed or 132 // We need to do this *before* |xmpp_connection| gets destroyed or
133 // our delegate won't be called. 133 // our delegate won't be called.
134 message_loop_.RunAllPending(); 134 message_loop_.RunUntilIdle();
135 } 135 }
136 136
137 TEST_F(XmppConnectionTest, FailureAfterPreAuth) { 137 TEST_F(XmppConnectionTest, FailureAfterPreAuth) {
138 EXPECT_CALL(*mock_pre_xmpp_auth_, StartPreXmppAuth(_, _, _, _,_)); 138 EXPECT_CALL(*mock_pre_xmpp_auth_, StartPreXmppAuth(_, _, _, _,_));
139 EXPECT_CALL(*mock_pre_xmpp_auth_, IsAuthDone()).WillOnce(Return(true)); 139 EXPECT_CALL(*mock_pre_xmpp_auth_, IsAuthDone()).WillOnce(Return(true));
140 EXPECT_CALL(*mock_pre_xmpp_auth_, IsAuthorized()).WillOnce(Return(true)); 140 EXPECT_CALL(*mock_pre_xmpp_auth_, IsAuthorized()).WillOnce(Return(true));
141 EXPECT_CALL(*mock_pre_xmpp_auth_, GetAuthMechanism()).WillOnce(Return("")); 141 EXPECT_CALL(*mock_pre_xmpp_auth_, GetAuthMechanism()).WillOnce(Return(""));
142 EXPECT_CALL(*mock_pre_xmpp_auth_, GetAuthToken()).WillOnce(Return("")); 142 EXPECT_CALL(*mock_pre_xmpp_auth_, GetAuthToken()).WillOnce(Return(""));
143 143
144 EXPECT_CALL(mock_xmpp_connection_delegate_, 144 EXPECT_CALL(mock_xmpp_connection_delegate_,
145 OnError(buzz::XmppEngine::ERROR_NONE, 0, NULL)); 145 OnError(buzz::XmppEngine::ERROR_NONE, 0, NULL));
146 146
147 XmppConnection xmpp_connection( 147 XmppConnection xmpp_connection(
148 buzz::XmppClientSettings(), url_request_context_getter_, 148 buzz::XmppClientSettings(), url_request_context_getter_,
149 &mock_xmpp_connection_delegate_, mock_pre_xmpp_auth_.release()); 149 &mock_xmpp_connection_delegate_, mock_pre_xmpp_auth_.release());
150 150
151 // We need to do this *before* |xmpp_connection| gets destroyed or 151 // We need to do this *before* |xmpp_connection| gets destroyed or
152 // our delegate won't be called. 152 // our delegate won't be called.
153 message_loop_.RunAllPending(); 153 message_loop_.RunUntilIdle();
154 } 154 }
155 155
156 TEST_F(XmppConnectionTest, RaisedError) { 156 TEST_F(XmppConnectionTest, RaisedError) {
157 EXPECT_CALL(mock_xmpp_connection_delegate_, 157 EXPECT_CALL(mock_xmpp_connection_delegate_,
158 OnError(buzz::XmppEngine::ERROR_NONE, 0, NULL)); 158 OnError(buzz::XmppEngine::ERROR_NONE, 0, NULL));
159 159
160 XmppConnection xmpp_connection(buzz::XmppClientSettings(), 160 XmppConnection xmpp_connection(buzz::XmppClientSettings(),
161 url_request_context_getter_, 161 url_request_context_getter_,
162 &mock_xmpp_connection_delegate_, NULL); 162 &mock_xmpp_connection_delegate_, NULL);
163 163
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 // We have to do this since the state enum is protected in 240 // We have to do this since the state enum is protected in
241 // talk_base::Task. 241 // talk_base::Task.
242 const int TASK_STATE_ERROR = 3; 242 const int TASK_STATE_ERROR = 3;
243 ON_CALL(*task, ProcessStart()) 243 ON_CALL(*task, ProcessStart())
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_.RunUntilIdle();
251 } 251 }
252 252
253 } // namespace notifier 253 } // namespace notifier
OLDNEW
« no previous file with comments | « jingle/glue/thread_wrapper_unittest.cc ('k') | jingle/notifier/communicator/single_login_attempt_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698