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

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

Issue 12704002: Support for auth code based authentication flow for both app and web UI driven flow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase4 Created 7 years, 9 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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "chrome/browser/chromeos/cros/cros_library.h" 10 #include "chrome/browser/chromeos/cros/cros_library.h"
(...skipping 17 matching lines...) Expand all
28 using ::testing::_; 28 using ::testing::_;
29 using content::BrowserThread; 29 using content::BrowserThread;
30 30
31 namespace chromeos { 31 namespace chromeos {
32 32
33 class OnlineAttemptTest : public testing::Test { 33 class OnlineAttemptTest : public testing::Test {
34 public: 34 public:
35 OnlineAttemptTest() 35 OnlineAttemptTest()
36 : message_loop_(MessageLoop::TYPE_UI), 36 : message_loop_(MessageLoop::TYPE_UI),
37 ui_thread_(BrowserThread::UI, &message_loop_), 37 ui_thread_(BrowserThread::UI, &message_loop_),
38 state_("", "", "", "", "", User::USER_TYPE_REGULAR, false), 38 state_(UserCredentials(), "", "", "", User::USER_TYPE_REGULAR, false),
39 resolver_(new MockAuthAttemptStateResolver) { 39 resolver_(new MockAuthAttemptStateResolver) {
40 } 40 }
41 41
42 virtual ~OnlineAttemptTest() {} 42 virtual ~OnlineAttemptTest() {}
43 43
44 virtual void SetUp() { 44 virtual void SetUp() {
45 attempt_.reset(new OnlineAttempt(&state_, resolver_.get())); 45 attempt_.reset(new OnlineAttempt(&state_, resolver_.get()));
46 } 46 }
47 47
48 virtual void TearDown() { 48 virtual void TearDown() {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 GoogleServiceAuthError::HOSTED_NOT_ALLOWED))); 161 GoogleServiceAuthError::HOSTED_NOT_ALLOWED)));
162 TestingProfile profile; 162 TestingProfile profile;
163 163
164 EXPECT_CALL(*(resolver_.get()), Resolve()) 164 EXPECT_CALL(*(resolver_.get()), Resolve())
165 .WillOnce(Invoke(OnlineAttemptTest::Quit)) 165 .WillOnce(Invoke(OnlineAttemptTest::Quit))
166 .RetiresOnSaturation(); 166 .RetiresOnSaturation();
167 167
168 // This is how we inject fake URLFetcher objects, with a factory. 168 // This is how we inject fake URLFetcher objects, with a factory.
169 MockURLFetcherFactory<HostedFetcher> factory; 169 MockURLFetcherFactory<HostedFetcher> factory;
170 170
171 TestAttemptState local_state("", "", "", "", "", 171 TestAttemptState local_state(UserCredentials(), "", "", "",
172 User::USER_TYPE_REGULAR, true); 172 User::USER_TYPE_REGULAR, true);
173 attempt_.reset(new OnlineAttempt(&local_state, resolver_.get())); 173 attempt_.reset(new OnlineAttempt(&local_state, resolver_.get()));
174 attempt_->Initiate(&profile); 174 attempt_->Initiate(&profile);
175 BrowserThread::PostTask( 175 BrowserThread::PostTask(
176 BrowserThread::UI, FROM_HERE, 176 BrowserThread::UI, FROM_HERE,
177 base::Bind(&OnlineAttemptTest::RunThreadTest)); 177 base::Bind(&OnlineAttemptTest::RunThreadTest));
178 178
179 MessageLoop::current()->Run(); 179 MessageLoop::current()->Run();
180 180
181 EXPECT_EQ(error, local_state.online_outcome()); 181 EXPECT_EQ(error, local_state.online_outcome());
182 EXPECT_EQ(LoginFailure::NETWORK_AUTH_FAILED, 182 EXPECT_EQ(LoginFailure::NETWORK_AUTH_FAILED,
183 local_state.online_outcome().reason()); 183 local_state.online_outcome().reason());
184 } 184 }
185 185
186 TEST_F(OnlineAttemptTest, FullLogin) { 186 TEST_F(OnlineAttemptTest, FullLogin) {
187 TestingProfile profile; 187 TestingProfile profile;
188 188
189 EXPECT_CALL(*(resolver_.get()), Resolve()) 189 EXPECT_CALL(*(resolver_.get()), Resolve())
190 .WillOnce(Invoke(OnlineAttemptTest::Quit)) 190 .WillOnce(Invoke(OnlineAttemptTest::Quit))
191 .RetiresOnSaturation(); 191 .RetiresOnSaturation();
192 192
193 // This is how we inject fake URLFetcher objects, with a factory. 193 // This is how we inject fake URLFetcher objects, with a factory.
194 MockURLFetcherFactory<SuccessFetcher> factory; 194 MockURLFetcherFactory<SuccessFetcher> factory;
195 195
196 TestAttemptState local_state("", "", "", "", "", 196 TestAttemptState local_state(UserCredentials(), "", "", "",
197 User::USER_TYPE_REGULAR, true); 197 User::USER_TYPE_REGULAR, true);
198 attempt_.reset(new OnlineAttempt(&local_state, resolver_.get())); 198 attempt_.reset(new OnlineAttempt(&local_state, resolver_.get()));
199 attempt_->Initiate(&profile); 199 attempt_->Initiate(&profile);
200 BrowserThread::PostTask( 200 BrowserThread::PostTask(
201 BrowserThread::UI, FROM_HERE, 201 BrowserThread::UI, FROM_HERE,
202 base::Bind(&OnlineAttemptTest::RunThreadTest)); 202 base::Bind(&OnlineAttemptTest::RunThreadTest));
203 203
204 MessageLoop::current()->Run(); 204 MessageLoop::current()->Run();
205 205
206 EXPECT_EQ(LoginFailure::LoginFailureNone(), local_state.online_outcome()); 206 EXPECT_EQ(LoginFailure::LoginFailureNone(), local_state.online_outcome());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 attempt_->weak_factory_.GetWeakPtr(), 251 attempt_->weak_factory_.GetWeakPtr(),
252 error)); 252 error));
253 253
254 // Force UI thread to finish tasks so I can verify |state_|. 254 // Force UI thread to finish tasks so I can verify |state_|.
255 message_loop_.RunUntilIdle(); 255 message_loop_.RunUntilIdle();
256 EXPECT_TRUE(GoogleServiceAuthError::AuthErrorNone() == 256 EXPECT_TRUE(GoogleServiceAuthError::AuthErrorNone() ==
257 state_.online_outcome().error()); 257 state_.online_outcome().error());
258 } 258 }
259 259
260 } // namespace chromeos 260 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/online_attempt_host.cc ('k') | chrome/browser/chromeos/login/parallel_authenticator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698