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

Side by Side Diff: chrome/browser/signin/mutable_profile_oauth2_token_service_delegate_unittest.cc

Issue 2946693002: Use GN buildflags and features to configure account consistency (Closed)
Patch Set: fix Created 3 years, 6 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/signin/chrome_signin_helper.cc ('k') | chrome/browser/ui/BUILD.gn » ('j') | 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/signin/mutable_profile_oauth2_token_service_delegate.h" 5 #include "chrome/browser/signin/mutable_profile_oauth2_token_service_delegate.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "components/os_crypt/os_crypt_mocker.h" 18 #include "components/os_crypt/os_crypt_mocker.h"
19 #include "components/prefs/pref_registry_simple.h" 19 #include "components/prefs/pref_registry_simple.h"
20 #include "components/prefs/scoped_user_pref_update.h" 20 #include "components/prefs/scoped_user_pref_update.h"
21 #include "components/prefs/testing_pref_service.h" 21 #include "components/prefs/testing_pref_service.h"
22 #include "components/signin/core/browser/profile_oauth2_token_service.h" 22 #include "components/signin/core/browser/profile_oauth2_token_service.h"
23 #include "components/signin/core/browser/signin_error_controller.h" 23 #include "components/signin/core/browser/signin_error_controller.h"
24 #include "components/signin/core/browser/test_signin_client.h" 24 #include "components/signin/core/browser/test_signin_client.h"
25 #include "components/signin/core/browser/webdata/token_web_data.h" 25 #include "components/signin/core/browser/webdata/token_web_data.h"
26 #include "components/signin/core/common/profile_management_switches.h" 26 #include "components/signin/core/common/profile_management_switches.h"
27 #include "components/signin/core/common/signin_features.h"
27 #include "components/signin/core/common/signin_pref_names.h" 28 #include "components/signin/core/common/signin_pref_names.h"
28 #include "google_apis/gaia/gaia_constants.h" 29 #include "google_apis/gaia/gaia_constants.h"
29 #include "google_apis/gaia/gaia_urls.h" 30 #include "google_apis/gaia/gaia_urls.h"
30 #include "google_apis/gaia/google_service_auth_error.h" 31 #include "google_apis/gaia/google_service_auth_error.h"
31 #include "google_apis/gaia/oauth2_access_token_consumer.h" 32 #include "google_apis/gaia/oauth2_access_token_consumer.h"
32 #include "google_apis/gaia/oauth2_token_service_test_util.h" 33 #include "google_apis/gaia/oauth2_token_service_test_util.h"
33 #include "net/http/http_status_code.h" 34 #include "net/http/http_status_code.h"
34 #include "net/url_request/test_url_fetcher_factory.h" 35 #include "net/url_request/test_url_fetcher_factory.h"
35 #include "testing/gtest/include/gtest/gtest.h" 36 #include "testing/gtest/include/gtest/gtest.h"
36 37
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 347
347 oauth2_service_delegate_->RevokeAllCredentials(); 348 oauth2_service_delegate_->RevokeAllCredentials();
348 EXPECT_EQ(0, token_available_count_); 349 EXPECT_EQ(0, token_available_count_);
349 EXPECT_EQ(2, token_revoked_count_); 350 EXPECT_EQ(2, token_revoked_count_);
350 EXPECT_EQ(0, tokens_loaded_count_); 351 EXPECT_EQ(0, tokens_loaded_count_);
351 EXPECT_EQ(1, start_batch_changes_); 352 EXPECT_EQ(1, start_batch_changes_);
352 EXPECT_EQ(1, end_batch_changes_); 353 EXPECT_EQ(1, end_batch_changes_);
353 ResetObserverCounts(); 354 ResetObserverCounts();
354 } 355 }
355 356
357 #if BUILDFLAG(ENABLE_DICE_SUPPORT)
356 TEST_F(MutableProfileOAuth2TokenServiceDelegateTest, 358 TEST_F(MutableProfileOAuth2TokenServiceDelegateTest,
357 PersistenceLoadCredentialsEmptyPrimaryAccountId_DiceEnabled) { 359 PersistenceLoadCredentialsEmptyPrimaryAccountId_DiceEnabled) {
358 switches::EnableAccountConsistencyDiceForTesting( 360 switches::EnableAccountConsistencyDiceForTesting(
359 base::CommandLine::ForCurrentProcess()); 361 base::CommandLine::ForCurrentProcess());
360 362
361 // Ensure DB is clean. 363 // Ensure DB is clean.
362 oauth2_service_delegate_->RevokeAllCredentials(); 364 oauth2_service_delegate_->RevokeAllCredentials();
363 ResetObserverCounts(); 365 ResetObserverCounts();
364 // Perform a load from an empty DB. 366 // Perform a load from an empty DB.
365 EXPECT_EQ(OAuth2TokenServiceDelegate::LOAD_CREDENTIALS_NOT_STARTED, 367 EXPECT_EQ(OAuth2TokenServiceDelegate::LOAD_CREDENTIALS_NOT_STARTED,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 EXPECT_TRUE(oauth2_service_delegate_->RefreshTokenIsAvailable("account_id2")); 405 EXPECT_TRUE(oauth2_service_delegate_->RefreshTokenIsAvailable("account_id2"));
404 406
405 oauth2_service_delegate_->RevokeAllCredentials(); 407 oauth2_service_delegate_->RevokeAllCredentials();
406 EXPECT_EQ(0, token_available_count_); 408 EXPECT_EQ(0, token_available_count_);
407 EXPECT_EQ(2, token_revoked_count_); 409 EXPECT_EQ(2, token_revoked_count_);
408 EXPECT_EQ(0, tokens_loaded_count_); 410 EXPECT_EQ(0, tokens_loaded_count_);
409 EXPECT_EQ(1, start_batch_changes_); 411 EXPECT_EQ(1, start_batch_changes_);
410 EXPECT_EQ(1, end_batch_changes_); 412 EXPECT_EQ(1, end_batch_changes_);
411 ResetObserverCounts(); 413 ResetObserverCounts();
412 } 414 }
415 #endif // BUILDFLAG(ENABLE_DICE_SUPPORT)
413 416
414 TEST_F(MutableProfileOAuth2TokenServiceDelegateTest, PersistanceNotifications) { 417 TEST_F(MutableProfileOAuth2TokenServiceDelegateTest, PersistanceNotifications) {
415 oauth2_service_delegate_->UpdateCredentials("account_id", "refresh_token"); 418 oauth2_service_delegate_->UpdateCredentials("account_id", "refresh_token");
416 ExpectOneTokenAvailableNotification(); 419 ExpectOneTokenAvailableNotification();
417 420
418 oauth2_service_delegate_->UpdateCredentials("account_id", "refresh_token"); 421 oauth2_service_delegate_->UpdateCredentials("account_id", "refresh_token");
419 ExpectNoNotifications(); 422 ExpectNoNotifications();
420 423
421 oauth2_service_delegate_->UpdateCredentials("account_id", "refresh_token2"); 424 oauth2_service_delegate_->UpdateCredentials("account_id", "refresh_token2");
422 ExpectOneTokenAvailableNotification(); 425 ExpectOneTokenAvailableNotification();
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 EXPECT_EQ(1, tokens_loaded_count_); 772 EXPECT_EQ(1, tokens_loaded_count_);
770 EXPECT_EQ(2, token_available_count_); 773 EXPECT_EQ(2, token_available_count_);
771 EXPECT_EQ(0, token_revoked_count_); 774 EXPECT_EQ(0, token_revoked_count_);
772 EXPECT_EQ(1, start_batch_changes_); 775 EXPECT_EQ(1, start_batch_changes_);
773 EXPECT_EQ(1, end_batch_changes_); 776 EXPECT_EQ(1, end_batch_changes_);
774 EXPECT_TRUE( 777 EXPECT_TRUE(
775 oauth2_service_delegate_->RefreshTokenIsAvailable(primary_account)); 778 oauth2_service_delegate_->RefreshTokenIsAvailable(primary_account));
776 EXPECT_TRUE( 779 EXPECT_TRUE(
777 oauth2_service_delegate_->RefreshTokenIsAvailable(secondary_account)); 780 oauth2_service_delegate_->RefreshTokenIsAvailable(secondary_account));
778 } 781 }
OLDNEW
« no previous file with comments | « chrome/browser/signin/chrome_signin_helper.cc ('k') | chrome/browser/ui/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698