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

Side by Side Diff: chrome/browser/chromeos/login/online_attempt_unittest.cc

Issue 5844002: Reland 69237 - Fix raw_scoped_refptr_mismatch_checker.h." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 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
« no previous file with comments | « base/template_util.h ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <string> 5 #include <string>
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/ref_counted.h" 8 #include "base/ref_counted.h"
9 #include "chrome/browser/browser_thread.h" 9 #include "chrome/browser/browser_thread.h"
10 #include "chrome/browser/chromeos/cros/mock_library_loader.h" 10 #include "chrome/browser/chromeos/cros/mock_library_loader.h"
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 130
131 // This is how we inject fake URLFetcher objects, with a factory. 131 // This is how we inject fake URLFetcher objects, with a factory.
132 // This factory creates fake URLFetchers that Start() a fake fetch attempt 132 // This factory creates fake URLFetchers that Start() a fake fetch attempt
133 // and then come back on the IO thread saying they've been canceled. 133 // and then come back on the IO thread saying they've been canceled.
134 MockFactory<GotCanceledFetcher> factory; 134 MockFactory<GotCanceledFetcher> factory;
135 URLFetcher::set_factory(&factory); 135 URLFetcher::set_factory(&factory);
136 136
137 BrowserThread::PostTask( 137 BrowserThread::PostTask(
138 BrowserThread::IO, FROM_HERE, 138 BrowserThread::IO, FROM_HERE,
139 NewRunnableFunction(&OnlineAttemptTest::RunThreadTest, 139 NewRunnableFunction(&OnlineAttemptTest::RunThreadTest,
140 attempt_.get(), &profile)); 140 attempt_, &profile));
141 141
142 MessageLoop::current()->Run(); 142 MessageLoop::current()->Run();
143 143
144 EXPECT_TRUE(error == state_.online_outcome().error()); 144 EXPECT_TRUE(error == state_.online_outcome().error());
145 EXPECT_EQ(LoginFailure::NETWORK_AUTH_FAILED, 145 EXPECT_EQ(LoginFailure::NETWORK_AUTH_FAILED,
146 state_.online_outcome().reason()); 146 state_.online_outcome().reason());
147 URLFetcher::set_factory(NULL); 147 URLFetcher::set_factory(NULL);
148 } 148 }
149 149
150 TEST_F(OnlineAttemptTest, LoginTimeout) { 150 TEST_F(OnlineAttemptTest, LoginTimeout) {
151 LoginFailure error(LoginFailure::LOGIN_TIMED_OUT); 151 LoginFailure error(LoginFailure::LOGIN_TIMED_OUT);
152 TestingProfile profile; 152 TestingProfile profile;
153 153
154 EXPECT_CALL(*(resolver_.get()), Resolve()) 154 EXPECT_CALL(*(resolver_.get()), Resolve())
155 .WillOnce(Invoke(OnlineAttemptTest::Quit)) 155 .WillOnce(Invoke(OnlineAttemptTest::Quit))
156 .RetiresOnSaturation(); 156 .RetiresOnSaturation();
157 157
158 // This is how we inject fake URLFetcher objects, with a factory. 158 // This is how we inject fake URLFetcher objects, with a factory.
159 // This factory creates fake URLFetchers that Start() a fake fetch attempt 159 // This factory creates fake URLFetchers that Start() a fake fetch attempt
160 // and then come back on the IO thread saying they've been canceled. 160 // and then come back on the IO thread saying they've been canceled.
161 MockFactory<ExpectCanceledFetcher> factory; 161 MockFactory<ExpectCanceledFetcher> factory;
162 URLFetcher::set_factory(&factory); 162 URLFetcher::set_factory(&factory);
163 163
164 BrowserThread::PostTask( 164 BrowserThread::PostTask(
165 BrowserThread::IO, FROM_HERE, 165 BrowserThread::IO, FROM_HERE,
166 NewRunnableFunction(&OnlineAttemptTest::RunThreadTest, 166 NewRunnableFunction(&OnlineAttemptTest::RunThreadTest,
167 attempt_.get(), &profile)); 167 attempt_, &profile));
168 168
169 // Post a task to cancel the login attempt. 169 // Post a task to cancel the login attempt.
170 CancelLogin(attempt_.get()); 170 CancelLogin(attempt_.get());
171 171
172 MessageLoop::current()->Run(); 172 MessageLoop::current()->Run();
173 173
174 EXPECT_EQ(LoginFailure::LOGIN_TIMED_OUT, state_.online_outcome().reason()); 174 EXPECT_EQ(LoginFailure::LOGIN_TIMED_OUT, state_.online_outcome().reason());
175 URLFetcher::set_factory(NULL); 175 URLFetcher::set_factory(NULL);
176 } 176 }
177 177
(...skipping 10 matching lines...) Expand all
188 188
189 // This is how we inject fake URLFetcher objects, with a factory. 189 // This is how we inject fake URLFetcher objects, with a factory.
190 MockFactory<HostedFetcher> factory; 190 MockFactory<HostedFetcher> factory;
191 URLFetcher::set_factory(&factory); 191 URLFetcher::set_factory(&factory);
192 192
193 TestAttemptState local_state("", "", "", "", "", true); 193 TestAttemptState local_state("", "", "", "", "", true);
194 attempt_ = new OnlineAttempt(&local_state, resolver_.get()); 194 attempt_ = new OnlineAttempt(&local_state, resolver_.get());
195 BrowserThread::PostTask( 195 BrowserThread::PostTask(
196 BrowserThread::IO, FROM_HERE, 196 BrowserThread::IO, FROM_HERE,
197 NewRunnableFunction(&OnlineAttemptTest::RunThreadTest, 197 NewRunnableFunction(&OnlineAttemptTest::RunThreadTest,
198 attempt_.get(), &profile)); 198 attempt_, &profile));
199 199
200 MessageLoop::current()->Run(); 200 MessageLoop::current()->Run();
201 201
202 EXPECT_EQ(error, local_state.online_outcome()); 202 EXPECT_EQ(error, local_state.online_outcome());
203 EXPECT_EQ(LoginFailure::NETWORK_AUTH_FAILED, 203 EXPECT_EQ(LoginFailure::NETWORK_AUTH_FAILED,
204 local_state.online_outcome().reason()); 204 local_state.online_outcome().reason());
205 URLFetcher::set_factory(NULL); 205 URLFetcher::set_factory(NULL);
206 } 206 }
207 207
208 TEST_F(OnlineAttemptTest, FullLogin) { 208 TEST_F(OnlineAttemptTest, FullLogin) {
209 TestingProfile profile; 209 TestingProfile profile;
210 210
211 EXPECT_CALL(*(resolver_.get()), Resolve()) 211 EXPECT_CALL(*(resolver_.get()), Resolve())
212 .WillOnce(Invoke(OnlineAttemptTest::Quit)) 212 .WillOnce(Invoke(OnlineAttemptTest::Quit))
213 .RetiresOnSaturation(); 213 .RetiresOnSaturation();
214 214
215 // This is how we inject fake URLFetcher objects, with a factory. 215 // This is how we inject fake URLFetcher objects, with a factory.
216 MockFactory<SuccessFetcher> factory; 216 MockFactory<SuccessFetcher> factory;
217 URLFetcher::set_factory(&factory); 217 URLFetcher::set_factory(&factory);
218 218
219 TestAttemptState local_state("", "", "", "", "", true); 219 TestAttemptState local_state("", "", "", "", "", true);
220 attempt_ = new OnlineAttempt(&local_state, resolver_.get()); 220 attempt_ = new OnlineAttempt(&local_state, resolver_.get());
221 BrowserThread::PostTask( 221 BrowserThread::PostTask(
222 BrowserThread::IO, FROM_HERE, 222 BrowserThread::IO, FROM_HERE,
223 NewRunnableFunction(&OnlineAttemptTest::RunThreadTest, 223 NewRunnableFunction(&OnlineAttemptTest::RunThreadTest,
224 attempt_.get(), &profile)); 224 attempt_, &profile));
225 225
226 MessageLoop::current()->Run(); 226 MessageLoop::current()->Run();
227 227
228 EXPECT_EQ(LoginFailure::None(), local_state.online_outcome()); 228 EXPECT_EQ(LoginFailure::None(), local_state.online_outcome());
229 URLFetcher::set_factory(NULL); 229 URLFetcher::set_factory(NULL);
230 } 230 }
231 231
232 TEST_F(OnlineAttemptTest, LoginNetFailure) { 232 TEST_F(OnlineAttemptTest, LoginNetFailure) {
233 RunFailureTest( 233 RunFailureTest(
234 GoogleServiceAuthError::FromConnectionError(net::ERR_CONNECTION_RESET)); 234 GoogleServiceAuthError::FromConnectionError(net::ERR_CONNECTION_RESET));
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 error)); 275 error));
276 276
277 // Force IO thread to finish tasks so I can verify |state_|. 277 // Force IO thread to finish tasks so I can verify |state_|.
278 io_thread_.Stop(); 278 io_thread_.Stop();
279 EXPECT_TRUE(GoogleServiceAuthError::None() == 279 EXPECT_TRUE(GoogleServiceAuthError::None() ==
280 state_.online_outcome().error()); 280 state_.online_outcome().error());
281 EXPECT_TRUE(GaiaAuthConsumer::ClientLoginResult() == state_.credentials()); 281 EXPECT_TRUE(GaiaAuthConsumer::ClientLoginResult() == state_.credentials());
282 } 282 }
283 283
284 } // namespace chromeos 284 } // namespace chromeos
OLDNEW
« no previous file with comments | « base/template_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698