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

Side by Side Diff: chrome/browser/services/gcm/gcm_account_tracker_unittest.cc

Issue 878713002: Fix to the GCM Account Tracker flooding on a stale refresh token (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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
« no previous file with comments | « chrome/browser/services/gcm/gcm_account_tracker.cc ('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 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
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
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
OLDNEW
« no previous file with comments | « chrome/browser/services/gcm/gcm_account_tracker.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698