OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/services/gcm/gcm_account_tracker.h" | 5 #include "chrome/browser/services/gcm/gcm_account_tracker.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 | 352 |
353 TEST_F(GCMAccountTrackerTest, GetTokenFailed) { | 353 TEST_F(GCMAccountTrackerTest, GetTokenFailed) { |
354 SignInAccount(kAccountId1); | 354 SignInAccount(kAccountId1); |
355 SignInAccount(kAccountId2); | 355 SignInAccount(kAccountId2); |
356 | 356 |
357 tracker()->Start(); | 357 tracker()->Start(); |
358 IssueAccessToken(kAccountId1); | 358 IssueAccessToken(kAccountId1); |
359 EXPECT_FALSE(driver()->update_accounts_called()); | 359 EXPECT_FALSE(driver()->update_accounts_called()); |
360 | 360 |
361 IssueError(kAccountId2); | 361 IssueError(kAccountId2); |
362 EXPECT_FALSE(driver()->update_accounts_called()); | |
363 | 362 |
364 EXPECT_EQ(1UL, tracker()->get_pending_token_request_count()); | 363 // Failed token is not retried any more. Account marked as removed. |
365 | 364 EXPECT_EQ(0UL, tracker()->get_pending_token_request_count()); |
366 IssueAccessToken(kAccountId2); | |
367 EXPECT_TRUE(driver()->update_accounts_called()); | 365 EXPECT_TRUE(driver()->update_accounts_called()); |
368 | 366 |
369 std::vector<GCMClient::AccountTokenInfo> expected_accounts; | 367 std::vector<GCMClient::AccountTokenInfo> expected_accounts; |
370 expected_accounts.push_back(MakeAccountToken(kAccountId1)); | 368 expected_accounts.push_back(MakeAccountToken(kAccountId1)); |
371 expected_accounts.push_back(MakeAccountToken(kAccountId2)); | |
372 VerifyAccountTokens(expected_accounts, driver()->accounts()); | 369 VerifyAccountTokens(expected_accounts, driver()->accounts()); |
373 } | 370 } |
374 | 371 |
375 TEST_F(GCMAccountTrackerTest, GetTokenFailedAccountRemoved) { | 372 TEST_F(GCMAccountTrackerTest, GetTokenFailedAccountRemoved) { |
376 SignInAccount(kAccountId1); | 373 SignInAccount(kAccountId1); |
377 SignInAccount(kAccountId2); | 374 SignInAccount(kAccountId2); |
378 | 375 |
379 tracker()->Start(); | 376 tracker()->Start(); |
380 IssueAccessToken(kAccountId1); | 377 IssueAccessToken(kAccountId1); |
381 IssueError(kAccountId2); | |
382 | 378 |
383 driver()->ResetResults(); | 379 driver()->ResetResults(); |
384 SignOutAccount(kAccountId2); | 380 SignOutAccount(kAccountId2); |
385 IssueError(kAccountId2); | 381 IssueError(kAccountId2); |
386 | 382 |
387 EXPECT_TRUE(driver()->update_accounts_called()); | 383 EXPECT_TRUE(driver()->update_accounts_called()); |
388 | 384 |
389 std::vector<GCMClient::AccountTokenInfo> expected_accounts; | 385 std::vector<GCMClient::AccountTokenInfo> expected_accounts; |
390 expected_accounts.push_back(MakeAccountToken(kAccountId1)); | 386 expected_accounts.push_back(MakeAccountToken(kAccountId1)); |
391 VerifyAccountTokens(expected_accounts, driver()->accounts()); | 387 VerifyAccountTokens(expected_accounts, driver()->accounts()); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 // but we have the update call. | 498 // but we have the update call. |
503 SignOutAccount(kAccountId1); | 499 SignOutAccount(kAccountId1); |
504 EXPECT_TRUE(driver()->update_accounts_called()); | 500 EXPECT_TRUE(driver()->update_accounts_called()); |
505 EXPECT_FALSE(IsTokenReportingRequired()); | 501 EXPECT_FALSE(IsTokenReportingRequired()); |
506 } | 502 } |
507 | 503 |
508 // TODO(fgorski): Add test for adding account after removal >> make sure it does | 504 // TODO(fgorski): Add test for adding account after removal >> make sure it does |
509 // not mark removal. | 505 // not mark removal. |
510 | 506 |
511 } // namespace gcm | 507 } // namespace gcm |
OLD | NEW |