| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "blimp/client/core/session/identity_source.h" | 5 #include "blimp/client/core/session/identity_source.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 GoogleServiceAuthError error( | 256 GoogleServiceAuthError error( |
| 257 GoogleServiceAuthError::State::CONNECTION_FAILED); | 257 GoogleServiceAuthError::State::CONNECTION_FAILED); |
| 258 | 258 |
| 259 EXPECT_CALL(mock_blimp_delegate, OnAuthenticationError(error)) | 259 EXPECT_CALL(mock_blimp_delegate, OnAuthenticationError(error)) |
| 260 .WillOnce(Return()); | 260 .WillOnce(Return()); |
| 261 token_service->IssueErrorForAllPendingRequestsForAccount(account, error); | 261 token_service->IssueErrorForAllPendingRequestsForAccount(account, error); |
| 262 | 262 |
| 263 DCHECK_EQ(auth.Failed(), 1); | 263 DCHECK_EQ(auth.Failed(), 1); |
| 264 } | 264 } |
| 265 | 265 |
| 266 TEST_F(IdentitySourceTest, CheckUserName) { |
| 267 TestBlimpClientContextDelegate mock_blimp_delegate; |
| 268 MockIdentitySource auth( |
| 269 mock_blimp_delegate.CreateIdentityProvider(), |
| 270 base::Bind(&TestBlimpClientContextDelegate::OnAuthenticationError, |
| 271 base::Unretained(&mock_blimp_delegate)), |
| 272 base::Bind(&MockIdentitySource::MockTokenCall, base::Unretained(&auth))); |
| 273 |
| 274 FakeIdentityProvider* id_provider = |
| 275 static_cast<FakeIdentityProvider*>(auth.GetIdentityProvider()); |
| 276 std::string account = "mock_account"; |
| 277 |
| 278 // Verify the user name before the login. |
| 279 EXPECT_EQ("", auth.GetActiveUsername()); |
| 280 |
| 281 // Log in the mock user. |
| 282 id_provider->LogIn(account); |
| 283 |
| 284 // Verify that the identity source can return the correct user name. |
| 285 EXPECT_EQ(account, auth.GetActiveUsername()); |
| 286 |
| 287 // Verify the user name after the logout. |
| 288 id_provider->LogOut(); |
| 289 EXPECT_EQ("", auth.GetActiveUsername()); |
| 290 } |
| 291 |
| 266 } // namespace | 292 } // namespace |
| 267 } // namespace client | 293 } // namespace client |
| 268 } // namespace blimp | 294 } // namespace blimp |
| OLD | NEW |