Commit 5560ed3a authored by Mario Sanchez Prada's avatar Mario Sanchez Prada Committed by Commit Bot

Convert oauth2_browsertest.cc away from ProfileOAuth2TokenService

Replace usage of PO2TS APIs with calls to IdentityManager's methods.

Bug: 905280
Change-Id: I5ea837b30e2ca44ca3e44ef012d81aff57acc636
Reviewed-on: https://chromium-review.googlesource.com/c/1338105Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Commit-Queue: Mario Sanchez Prada <mario@igalia.com>
Cr-Commit-Position: refs/heads/master@{#608816}
parent 9877c4bd
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
#include "chrome/browser/extensions/chrome_extension_test_notification_observer.h" #include "chrome/browser/extensions/chrome_extension_test_notification_observer.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/signin/account_tracker_service_factory.h" #include "chrome/browser/signin/account_tracker_service_factory.h"
#include "chrome/browser/signin/profile_oauth2_token_service_factory.h" #include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/signin_error_controller_factory.h" #include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_tabstrip.h" #include "chrome/browser/ui/browser_tabstrip.h"
...@@ -44,7 +44,6 @@ ...@@ -44,7 +44,6 @@
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/signin/core/browser/account_tracker_service.h" #include "components/signin/core/browser/account_tracker_service.h"
#include "components/signin/core/browser/fake_auth_status_provider.h" #include "components/signin/core/browser/fake_auth_status_provider.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/browser/signin_error_controller.h" #include "components/signin/core/browser/signin_error_controller.h"
#include "components/user_manager/user.h" #include "components/user_manager/user.h"
#include "components/user_manager/user_manager.h" #include "components/user_manager/user_manager.h"
...@@ -61,6 +60,7 @@ ...@@ -61,6 +60,7 @@
#include "net/test/embedded_test_server/http_response.h" #include "net/test/embedded_test_server/http_response.h"
#include "net/url_request/url_request_context.h" #include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h" #include "net/url_request/url_request_context_getter.h"
#include "services/identity/public/cpp/identity_manager.h"
using net::test_server::BasicHttpResponse; using net::test_server::BasicHttpResponse;
using net::test_server::HttpRequest; using net::test_server::HttpRequest;
...@@ -299,9 +299,9 @@ class OAuth2Test : public OobeBaseTest { ...@@ -299,9 +299,9 @@ class OAuth2Test : public OobeBaseTest {
WaitForMergeSessionCompletion(OAuth2LoginManager::SESSION_RESTORE_DONE); WaitForMergeSessionCompletion(OAuth2LoginManager::SESSION_RESTORE_DONE);
// Check for existence of refresh token. // Check for existence of refresh token.
ProfileOAuth2TokenService* token_service = identity::IdentityManager* identity_manager =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile); IdentityManagerFactory::GetForProfile(profile);
EXPECT_TRUE(token_service->RefreshTokenIsAvailable(account_id)); EXPECT_TRUE(identity_manager->HasAccountWithRefreshToken(account_id));
EXPECT_EQ(GetOAuthStatusFromLocalState(account_id), EXPECT_EQ(GetOAuthStatusFromLocalState(account_id),
user_manager::User::OAUTH2_TOKEN_STATUS_VALID); user_manager::User::OAUTH2_TOKEN_STATUS_VALID);
...@@ -498,9 +498,9 @@ IN_PROC_BROWSER_TEST_F(OAuth2Test, PRE_PRE_PRE_MergeSession) { ...@@ -498,9 +498,9 @@ IN_PROC_BROWSER_TEST_F(OAuth2Test, PRE_PRE_PRE_MergeSession) {
/*is_under_advanced_protectionis_true=*/false); /*is_under_advanced_protectionis_true=*/false);
// Check for existence of refresh token. // Check for existence of refresh token.
std::string account_id = PickAccountId(profile(), kTestGaiaId, kTestEmail); std::string account_id = PickAccountId(profile(), kTestGaiaId, kTestEmail);
ProfileOAuth2TokenService* token_service = identity::IdentityManager* identity_manager =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile()); IdentityManagerFactory::GetForProfile(profile());
EXPECT_TRUE(token_service->RefreshTokenIsAvailable(account_id)); EXPECT_TRUE(identity_manager->HasAccountWithRefreshToken(account_id));
EXPECT_EQ(GetOAuthStatusFromLocalState(account_id), EXPECT_EQ(GetOAuthStatusFromLocalState(account_id),
user_manager::User::OAUTH2_TOKEN_STATUS_VALID); user_manager::User::OAUTH2_TOKEN_STATUS_VALID);
...@@ -603,11 +603,11 @@ IN_PROC_BROWSER_TEST_F(OAuth2Test, DISABLED_OverlappingContinueSessionRestore) { ...@@ -603,11 +603,11 @@ IN_PROC_BROWSER_TEST_F(OAuth2Test, DISABLED_OverlappingContinueSessionRestore) {
GetSessionRestoreStrategy()); GetSessionRestoreStrategy());
// Checks that refresh token is not yet loaded. // Checks that refresh token is not yet loaded.
ProfileOAuth2TokenService* token_service = identity::IdentityManager* identity_manager =
ProfileOAuth2TokenServiceFactory::GetForProfile(profile()); IdentityManagerFactory::GetForProfile(profile());
const std::string account_id = const std::string account_id =
PickAccountId(profile(), kTestGaiaId, kTestEmail); PickAccountId(profile(), kTestGaiaId, kTestEmail);
EXPECT_FALSE(token_service->RefreshTokenIsAvailable(account_id)); EXPECT_FALSE(identity_manager->HasAccountWithRefreshToken(account_id));
// Invokes ContinueSessionRestore multiple times and there should be // Invokes ContinueSessionRestore multiple times and there should be
// no DCHECK failures. // no DCHECK failures.
...@@ -621,7 +621,7 @@ IN_PROC_BROWSER_TEST_F(OAuth2Test, DISABLED_OverlappingContinueSessionRestore) { ...@@ -621,7 +621,7 @@ IN_PROC_BROWSER_TEST_F(OAuth2Test, DISABLED_OverlappingContinueSessionRestore) {
// Session restore can finish normally and token is loaded. // Session restore can finish normally and token is loaded.
WaitForMergeSessionCompletion(OAuth2LoginManager::SESSION_RESTORE_DONE); WaitForMergeSessionCompletion(OAuth2LoginManager::SESSION_RESTORE_DONE);
EXPECT_TRUE(token_service->RefreshTokenIsAvailable(account_id)); EXPECT_TRUE(identity_manager->HasAccountWithRefreshToken(account_id));
} }
// Tests that user session is terminated if merge session fails for an online // Tests that user session is terminated if merge session fails for an online
......
...@@ -1869,6 +1869,7 @@ test("browser_tests") { ...@@ -1869,6 +1869,7 @@ test("browser_tests") {
"//components/user_manager:test_support", "//components/user_manager:test_support",
"//content/public/common:feature_h264_with_openh264_ffmpeg", "//content/public/common:feature_h264_with_openh264_ffmpeg",
"//services/audio/public/cpp:test_support", "//services/audio/public/cpp:test_support",
"//services/identity/public/cpp",
"//services/network/public/mojom", "//services/network/public/mojom",
"//services/preferences/public/cpp", "//services/preferences/public/cpp",
"//services/preferences/public/mojom", "//services/preferences/public/mojom",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment