Commit ea1d289e authored by Pâris MEULEMAN's avatar Pâris MEULEMAN Committed by Commit Bot

Add tests on Oauth2TokenServiceDelegateAndroid

This CL adds tests to Oauth2TokenServiceDelegateAndroid to improve
overall coverage and remove the need of the java
Oauth2TokenService.OAuth2TokenServiceObserver.

This was part of https://crev.com/c/1602715

Bug: 960281
Change-Id: Ie3027682128d6a1bc6acea3bab1b49b3d59989eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1609839
Commit-Queue: Pâris Meuleman <pmeuleman@chromium.org>
Reviewed-by: default avatarBoris Sazonov <bsazonov@chromium.org>
Auto-Submit: Pâris Meuleman <pmeuleman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#663027}
parent 2930eb12
......@@ -325,7 +325,10 @@ source_set("unit_tests") {
}
if (is_android) {
sources += [ "consistency_cookie_manager_unittest.cc" ]
sources += [
"consistency_cookie_manager_unittest.cc",
"oauth2_token_service_delegate_android_unittest.cc",
]
}
if (!enable_dice_support) {
......
......@@ -348,7 +348,12 @@ public final class OAuth2TokenService
}
@CalledByNative
private static void saveStoredAccounts(String[] accounts) {
/**
* Called by native to save the account IDs that have associated OAuth2 refresh tokens.
* This is called during updateAccountList to sync with getSystemAccountNames.
* @param accounts IDs to save.
*/
private static void setAccounts(String[] accounts) {
Set<String> set = new HashSet<>(Arrays.asList(accounts));
ContextUtils.getAppSharedPreferences()
.edit()
......
......@@ -150,16 +150,14 @@ OAuth2TokenServiceDelegateAndroid::OAuth2TokenServiceDelegateAndroid(
if (account_tracker_service_->GetMigrationState() ==
AccountTrackerService::MIGRATION_IN_PROGRESS) {
std::vector<std::string> accounts = GetAccounts();
std::vector<std::string> accounts_id;
std::vector<CoreAccountId> accounts_id;
for (auto account_name : accounts) {
AccountInfo account_info =
account_tracker_service_->FindAccountInfoByEmail(account_name);
DCHECK(!account_info.gaia.empty());
accounts_id.push_back(account_info.gaia);
}
ScopedJavaLocalRef<jobjectArray> java_accounts(
base::android::ToJavaArrayOfStrings(env, accounts_id));
Java_OAuth2TokenService_saveStoredAccounts(env, java_accounts);
SetAccounts(accounts_id);
}
if (!disable_interaction_with_system_accounts_) {
......@@ -244,6 +242,36 @@ OAuth2TokenServiceDelegateAndroid::GetSystemAccountNames() {
return account_names;
}
std::vector<CoreAccountId>
OAuth2TokenServiceDelegateAndroid::GetSystemAccounts() {
std::vector<CoreAccountId> ids;
for (const std::string& name : GetSystemAccountNames()) {
CoreAccountId id(MapAccountNameToAccountId(name));
if (!id.empty())
ids.push_back(std::move(id));
}
return ids;
}
std::vector<CoreAccountId>
OAuth2TokenServiceDelegateAndroid::GetValidAccounts() {
std::vector<CoreAccountId> ids;
for (const std::string& id : GetAccounts()) {
if (ValidateAccountId(id))
ids.emplace_back(id);
}
return ids;
}
void OAuth2TokenServiceDelegateAndroid::SetAccounts(
const std::vector<CoreAccountId>& accounts) {
JNIEnv* env = AttachCurrentThread();
std::vector<std::string> str_ids(accounts.begin(), accounts.end());
ScopedJavaLocalRef<jobjectArray> java_accounts(
base::android::ToJavaArrayOfStrings(env, str_ids));
Java_OAuth2TokenService_setAccounts(env, java_accounts);
}
OAuth2AccessTokenFetcher*
OAuth2TokenServiceDelegateAndroid::CreateAccessTokenFetcher(
const std::string& account_id,
......@@ -284,52 +312,33 @@ void OAuth2TokenServiceDelegateAndroid::UpdateAccountList(
// Clear any auth errors so that client can retry to get access tokens.
errors_.clear();
UpdateAccountList(MapAccountNameToAccountId(signed_in_account_name));
UpdateAccountList(MapAccountNameToAccountId(signed_in_account_name),
GetValidAccounts(), GetSystemAccounts());
}
void OAuth2TokenServiceDelegateAndroid::UpdateAccountList(
const std::string& signed_in_account_id) {
std::vector<std::string> curr_ids;
for (const std::string& curr_name : GetSystemAccountNames()) {
std::string curr_id(MapAccountNameToAccountId(curr_name));
if (!curr_id.empty())
curr_ids.push_back(curr_id);
}
std::vector<std::string> prev_ids;
for (const std::string& prev_id : GetAccounts()) {
if (ValidateAccountId(prev_id))
prev_ids.push_back(prev_id);
}
const CoreAccountId& signed_in_account_id,
const std::vector<CoreAccountId>& prev_ids,
const std::vector<CoreAccountId>& curr_ids) {
DVLOG(1) << "OAuth2TokenServiceDelegateAndroid::UpdateAccountList:"
<< " sigined_in_account_id=" << signed_in_account_id
<< " prev_ids=" << prev_ids.size()
<< " curr_ids=" << curr_ids.size();
std::vector<std::string> refreshed_ids;
std::vector<std::string> revoked_ids;
std::vector<CoreAccountId> refreshed_ids;
std::vector<CoreAccountId> revoked_ids;
bool keep_accounts = UpdateAccountList(
signed_in_account_id, prev_ids, curr_ids, &refreshed_ids, &revoked_ids);
ScopedBatchChange batch(this);
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobjectArray> java_accounts;
if (keep_accounts) {
java_accounts = base::android::ToJavaArrayOfStrings(env, curr_ids);
} else {
DCHECK(!base::FeatureList::IsEnabled(signin::kMiceFeature));
java_accounts =
base::android::ToJavaArrayOfStrings(env, std::vector<std::string>());
}
// Save the current accounts in the token service before calling
// FireRefreshToken* methods.
Java_OAuth2TokenService_saveStoredAccounts(env, java_accounts);
SetAccounts(keep_accounts ? curr_ids : std::vector<CoreAccountId>());
for (const std::string& refreshed_id : refreshed_ids)
for (const CoreAccountId& refreshed_id : refreshed_ids)
FireRefreshTokenAvailable(refreshed_id);
for (const std::string& revoked_id : revoked_ids)
for (const CoreAccountId& revoked_id : revoked_ids)
FireRefreshTokenRevoked(revoked_id);
if (fire_refresh_token_loaded_ == RT_WAIT_FOR_VALIDATION) {
fire_refresh_token_loaded_ = RT_LOADED;
......@@ -338,7 +347,7 @@ void OAuth2TokenServiceDelegateAndroid::UpdateAccountList(
fire_refresh_token_loaded_ = RT_HAS_BEEN_VALIDATED;
}
// Clear accounts no longer exist on device from AccountTrackerService.
// Clear accounts that no longer exist on device from AccountTrackerService.
std::vector<AccountInfo> accounts_info =
account_tracker_service_->GetAccounts();
for (const AccountInfo& info : accounts_info) {
......@@ -361,16 +370,16 @@ void OAuth2TokenServiceDelegateAndroid::UpdateAccountList(
}
bool OAuth2TokenServiceDelegateAndroid::UpdateAccountList(
const std::string& signed_in_id,
const std::vector<std::string>& prev_ids,
const std::vector<std::string>& curr_ids,
std::vector<std::string>* refreshed_ids,
std::vector<std::string>* revoked_ids) {
const CoreAccountId& signed_in_id,
const std::vector<CoreAccountId>& prev_ids,
const std::vector<CoreAccountId>& curr_ids,
std::vector<CoreAccountId>* refreshed_ids,
std::vector<CoreAccountId>* revoked_ids) {
bool keep_accounts = base::FeatureList::IsEnabled(signin::kMiceFeature) ||
base::ContainsValue(curr_ids, signed_in_id);
if (keep_accounts) {
// Revoke token for ids that have been removed from the device.
for (const std::string& prev_id : prev_ids) {
for (const CoreAccountId& prev_id : prev_ids) {
if (prev_id == signed_in_id)
continue;
if (!base::ContainsValue(curr_ids, prev_id)) {
......@@ -386,7 +395,7 @@ bool OAuth2TokenServiceDelegateAndroid::UpdateAccountList(
<< "refreshed=" << signed_in_id;
refreshed_ids->push_back(signed_in_id);
}
for (const std::string& curr_id : curr_ids) {
for (const CoreAccountId& curr_id : curr_ids) {
if (curr_id == signed_in_id)
continue;
DVLOG(1) << "OAuth2TokenServiceDelegateAndroid::UpdateAccountList:"
......@@ -400,7 +409,7 @@ bool OAuth2TokenServiceDelegateAndroid::UpdateAccountList(
<< "revoked=" << signed_in_id;
revoked_ids->push_back(signed_in_id);
}
for (const std::string& prev_id : prev_ids) {
for (const CoreAccountId& prev_id : prev_ids) {
if (prev_id == signed_in_id)
continue;
DVLOG(1) << "OAuth2TokenServiceDelegateAndroid::UpdateAccountList:"
......@@ -469,10 +478,7 @@ void OAuth2TokenServiceDelegateAndroid::RevokeAllCredentials() {
// Clear accounts in the token service before calling
// |FireRefreshTokenRevoked|.
JNIEnv* env = AttachCurrentThread();
ScopedJavaLocalRef<jobjectArray> java_accounts(
base::android::ToJavaArrayOfStrings(env, std::vector<std::string>()));
Java_OAuth2TokenService_saveStoredAccounts(env, java_accounts);
SetAccounts(std::vector<CoreAccountId>());
for (const std::string& account : accounts_to_revoke)
FireRefreshTokenRevoked(account);
......@@ -499,17 +505,18 @@ void OAuth2TokenServiceDelegateAndroid::ReloadAccountsFromSystem(
const std::string& primary_account_id) {
// UpdateAccountList() effectively synchronizes the accounts in the Token
// Service with those present at the system level.
UpdateAccountList(primary_account_id);
UpdateAccountList(primary_account_id, GetValidAccounts(),
GetSystemAccounts());
}
std::string OAuth2TokenServiceDelegateAndroid::MapAccountIdToAccountName(
const std::string& account_id) const {
const CoreAccountId& account_id) const {
return account_tracker_service_->GetAccountInfo(account_id).email;
}
std::string OAuth2TokenServiceDelegateAndroid::MapAccountNameToAccountId(
CoreAccountId OAuth2TokenServiceDelegateAndroid::MapAccountNameToAccountId(
const std::string& account_name) const {
std::string account_id =
CoreAccountId account_id =
account_tracker_service_->FindAccountInfoByEmail(account_name).account_id;
DCHECK(!account_id.empty() || account_name.empty())
<< "Can't find account id, account_name=" << account_name;
......
......@@ -55,9 +55,6 @@ class OAuth2TokenServiceDelegateAndroid : public OAuth2TokenServiceDelegate {
const GoogleServiceAuthError& error) override;
std::vector<std::string> GetAccounts() override;
// Lists account names at the OS level.
std::vector<std::string> GetSystemAccountNames();
void UpdateAccountList(
JNIEnv* env,
const base::android::JavaParamRef<jobject>& obj,
......@@ -67,7 +64,9 @@ class OAuth2TokenServiceDelegateAndroid : public OAuth2TokenServiceDelegate {
// android account ids and check the token status of each.
// NOTE: TokenAvailable notifications will be sent for all accounts, even if
// they were already known. See https://crbug.com/939470 for details.
void UpdateAccountList(const std::string& signed_in_account_id);
void UpdateAccountList(const CoreAccountId& signed_in_account_id,
const std::vector<CoreAccountId>& prev_ids,
const std::vector<CoreAccountId>& curr_ids);
// Overridden from OAuth2TokenService to complete signout of all
// OA2TService aware accounts.
......@@ -98,8 +97,9 @@ class OAuth2TokenServiceDelegateAndroid : public OAuth2TokenServiceDelegate {
void FireRefreshTokensLoaded() override;
private:
std::string MapAccountIdToAccountName(const std::string& account_id) const;
std::string MapAccountNameToAccountId(const std::string& account_name) const;
std::string MapAccountIdToAccountName(const CoreAccountId& account_id) const;
CoreAccountId MapAccountNameToAccountId(
const std::string& account_name) const;
enum RefreshTokenLoadStatus {
RT_LOAD_NOT_START,
......@@ -110,11 +110,20 @@ class OAuth2TokenServiceDelegateAndroid : public OAuth2TokenServiceDelegate {
// Return whether accounts are valid and we have access to all the tokens in
// |curr_ids|.
bool UpdateAccountList(const std::string& signed_in_id,
const std::vector<std::string>& prev_ids,
const std::vector<std::string>& curr_ids,
std::vector<std::string>* refreshed_ids,
std::vector<std::string>* revoked_ids);
bool UpdateAccountList(const CoreAccountId& signed_in_id,
const std::vector<CoreAccountId>& prev_ids,
const std::vector<CoreAccountId>& curr_ids,
std::vector<CoreAccountId>* refreshed_ids,
std::vector<CoreAccountId>* revoked_ids);
// Lists account names at the OS level.
std::vector<std::string> GetSystemAccountNames();
// As |GetSystemAccountNames| but returning account IDs.
std::vector<CoreAccountId> GetSystemAccounts();
// As |GetAccounts| but with only validated account IDs.
std::vector<CoreAccountId> GetValidAccounts();
// Set accounts using Java's Oauth2TokenService.setAccounts.
virtual void SetAccounts(const std::vector<CoreAccountId>& accounts);
base::android::ScopedJavaGlobalRef<jobject> java_ref_;
......
// Copyright (c) 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/signin/core/browser/oauth2_token_service_delegate_android.h"
#include "components/sync_preferences/testing_pref_service_syncable.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
using ::testing::_;
using ::testing::InSequence;
using ::testing::Return;
using ::testing::Sequence;
using ::testing::StrictMock;
namespace signin {
namespace {
const std::vector<CoreAccountId> kEmptyVector;
class OAuth2TokenServiceDelegateAndroidForTest
: public OAuth2TokenServiceDelegateAndroid {
public:
OAuth2TokenServiceDelegateAndroidForTest(
AccountTrackerService* account_tracker_service)
: OAuth2TokenServiceDelegateAndroid(account_tracker_service) {}
MOCK_METHOD1(SetAccounts, void(const std::vector<CoreAccountId>&));
};
class TestObserver : public OAuth2TokenService::Observer {
public:
MOCK_METHOD1(OnRefreshTokenAvailable, void(const std::string&));
MOCK_METHOD1(OnRefreshTokenRevoked, void(const std::string&));
MOCK_METHOD0(OnRefreshTokensLoaded, void());
};
} // namespace
class OAuth2TokenServiceDelegateAndroidTest : public testing::Test {
public:
OAuth2TokenServiceDelegateAndroidTest() {}
~OAuth2TokenServiceDelegateAndroidTest() override = default;
protected:
void SetUp() override {
testing::Test::SetUp();
AccountTrackerService::RegisterPrefs(pref_service_.registry());
account_tracker_service_.Initialize(&pref_service_, base::FilePath());
OAuth2TokenServiceDelegateAndroid::
set_disable_interaction_with_system_accounts();
delegate_ = std::make_unique<OAuth2TokenServiceDelegateAndroidForTest>(
&account_tracker_service_);
delegate_->AddObserver(&observer_);
CreateAndSeedAccounts();
}
void TearDown() override {
delegate_->RemoveObserver(&observer_);
testing::Test::TearDown();
}
AccountInfo CreateAccountInfo(const std::string& gaia_id,
const std::string& email) {
AccountInfo account_info;
account_info.gaia = gaia_id;
account_info.email = email;
account_info.full_name = "fullname";
account_info.given_name = "givenname";
account_info.hosted_domain = "example.com";
account_info.locale = "en";
account_info.picture_url = "https://example.com";
account_info.is_child_account = false;
account_info.account_id = account_tracker_service_.PickAccountIdForAccount(
account_info.gaia, account_info.email);
DCHECK(account_info.IsValid());
return account_info;
}
void CreateAndSeedAccounts() {
account1_ = CreateAccountInfo("gaia-id-user-1", "user-1@example.com");
account2_ = CreateAccountInfo("gaia-id-user-2", "user-2@example.com");
// SeedAccountInfo is required for
// OAuth2TokenServiceDelegateAndrod::MapAccountNameToAccountId
account_tracker_service_.SeedAccountInfo(account1_);
account_tracker_service_.SeedAccountInfo(account2_);
}
AccountTrackerService account_tracker_service_;
sync_preferences::TestingPrefServiceSyncable pref_service_;
std::unique_ptr<OAuth2TokenServiceDelegateAndroidForTest> delegate_;
StrictMock<TestObserver> observer_;
AccountInfo account1_;
AccountInfo account2_;
};
TEST_F(OAuth2TokenServiceDelegateAndroidTest,
UpdateAccountListWith0SystemAccount0AccountAndNotSignedIn) {
EXPECT_CALL(*delegate_, SetAccounts(kEmptyVector)).WillOnce(Return());
// No observer call expected
delegate_->UpdateAccountList(std::string(), {}, {});
EXPECT_TRUE(account_tracker_service_.GetAccounts().empty());
}
TEST_F(OAuth2TokenServiceDelegateAndroidTest,
UpdateAccountListWith1SystemAccount0AccountAndNotSignedIn) {
EXPECT_CALL(*delegate_, SetAccounts(kEmptyVector)).WillOnce(Return());
// No observer call expected
delegate_->UpdateAccountList(std::string(), {}, {account1_.account_id});
EXPECT_EQ(std::vector<AccountInfo>{account1_},
account_tracker_service_.GetAccounts());
}
TEST_F(OAuth2TokenServiceDelegateAndroidTest,
UpdateAccountListWith1SystemAccount1AccountAndNotSignedIn) {
Sequence seq;
EXPECT_CALL(*delegate_, SetAccounts(kEmptyVector))
.InSequence(seq)
.WillOnce(Return());
// Stored account from |GetAccounts| must fire a revoked event
EXPECT_CALL(observer_, OnRefreshTokenRevoked(account1_.account_id.id))
.InSequence(seq)
.WillOnce(Return());
delegate_->UpdateAccountList(std::string(), {account1_.account_id},
{account1_.account_id});
EXPECT_EQ(std::vector<AccountInfo>{account1_},
account_tracker_service_.GetAccounts());
}
TEST_F(OAuth2TokenServiceDelegateAndroidTest,
UpdateAccountListWith1SystemAccount0AccountAndSignedIn) {
Sequence seq;
EXPECT_CALL(*delegate_,
SetAccounts(std::vector<CoreAccountId>({account1_.account_id})))
.InSequence(seq)
.WillOnce(Return());
EXPECT_CALL(observer_, OnRefreshTokenAvailable(account1_.account_id.id))
.InSequence(seq)
.WillOnce(Return());
delegate_->UpdateAccountList(account1_.account_id, {},
{account1_.account_id});
EXPECT_EQ(std::vector<AccountInfo>{account1_},
account_tracker_service_.GetAccounts());
}
TEST_F(OAuth2TokenServiceDelegateAndroidTest,
UpdateAccountListWith1SystemAccount1AccountAndSignedIn) {
Sequence seq;
EXPECT_CALL(*delegate_,
SetAccounts(std::vector<CoreAccountId>({account1_.account_id})))
.InSequence(seq)
.WillOnce(Return());
EXPECT_CALL(observer_, OnRefreshTokenAvailable(account1_.account_id.id))
.InSequence(seq)
.WillOnce(Return());
delegate_->UpdateAccountList(account1_.account_id, {account1_.account_id},
{account1_.account_id});
EXPECT_EQ(std::vector<AccountInfo>{account1_},
account_tracker_service_.GetAccounts());
}
TEST_F(OAuth2TokenServiceDelegateAndroidTest,
UpdateAccountListWith1SystemAccount1AccountDifferentAndSignedIn) {
Sequence seq;
EXPECT_CALL(*delegate_,
SetAccounts(std::vector<CoreAccountId>({account1_.account_id})))
.InSequence(seq)
.WillOnce(Return());
// Previously stored account is removed, new account is available
EXPECT_CALL(observer_, OnRefreshTokenAvailable(account1_.account_id.id))
.InSequence(seq)
.WillOnce(Return());
EXPECT_CALL(observer_, OnRefreshTokenRevoked(account2_.account_id.id))
.InSequence(seq)
.WillOnce(Return());
delegate_->UpdateAccountList(account1_.account_id, {account2_.account_id},
{account1_.account_id});
EXPECT_EQ(std::vector<AccountInfo>{account1_},
account_tracker_service_.GetAccounts());
}
TEST_F(OAuth2TokenServiceDelegateAndroidTest,
UpdateAccountListWith0SystemAccount1AccountSignedIn) {
Sequence seq;
EXPECT_CALL(*delegate_, SetAccounts(kEmptyVector))
.InSequence(seq)
.WillOnce(Return());
EXPECT_CALL(observer_, OnRefreshTokenRevoked(account1_.account_id.id))
.InSequence(seq)
.WillOnce(Return());
delegate_->UpdateAccountList(account1_.account_id, {account1_.account_id},
{});
EXPECT_TRUE(account_tracker_service_.GetAccounts().empty());
}
TEST_F(OAuth2TokenServiceDelegateAndroidTest,
UpdateAccountListWith1SystemAccount0AccountAndSignedInDifferent) {
EXPECT_CALL(*delegate_, SetAccounts(kEmptyVector)).WillOnce(Return());
delegate_->UpdateAccountList(account2_.account_id, {},
{account1_.account_id});
EXPECT_EQ(std::vector<AccountInfo>{account1_},
account_tracker_service_.GetAccounts());
}
// Test Getsysaccounts return a user != from signed user while GetAccounts not
// empty
TEST_F(OAuth2TokenServiceDelegateAndroidTest,
UpdateAccountListWith1SystemAccount1AccountAndSignedInDifferent) {
Sequence seq;
EXPECT_CALL(*delegate_, SetAccounts(kEmptyVector))
.InSequence(seq)
.WillOnce(Return());
EXPECT_CALL(observer_, OnRefreshTokenRevoked(account1_.account_id.id))
.InSequence(seq)
.WillOnce(Return());
delegate_->UpdateAccountList(account2_.account_id, {account1_.account_id},
{account1_.account_id});
EXPECT_EQ(std::vector<AccountInfo>{account1_},
account_tracker_service_.GetAccounts());
}
TEST_F(OAuth2TokenServiceDelegateAndroidTest,
UpdateAccountListWith2SystemAccount0AccountAndSignedIn) {
Sequence seq;
EXPECT_CALL(*delegate_, SetAccounts(std::vector<CoreAccountId>(
{account1_.account_id, account2_.account_id})))
.InSequence(seq)
.WillOnce(Return());
// OnRefreshTokenAvailable fired, signed in account should go first.
EXPECT_CALL(observer_, OnRefreshTokenAvailable(account2_.account_id.id))
.InSequence(seq)
.WillOnce(Return());
EXPECT_CALL(observer_, OnRefreshTokenAvailable(account1_.account_id.id))
.InSequence(seq)
.WillOnce(Return());
delegate_->UpdateAccountList(account2_.account_id, {},
{account1_.account_id, account2_.account_id});
EXPECT_EQ(std::vector<AccountInfo>({account1_, account2_}),
account_tracker_service_.GetAccounts());
}
TEST_F(OAuth2TokenServiceDelegateAndroidTest,
UpdateAccountListWith2SystemAccount1AccountAndSignedIn) {
Sequence seq;
EXPECT_CALL(*delegate_, SetAccounts(std::vector<CoreAccountId>(
{account1_.account_id, account2_.account_id})))
.InSequence(seq)
.WillOnce(Return());
// OnRefreshTokenAvailable fired, signed in account should go first.
EXPECT_CALL(observer_, OnRefreshTokenAvailable(account1_.account_id.id))
.InSequence(seq)
.WillOnce(Return());
EXPECT_CALL(observer_, OnRefreshTokenAvailable(account2_.account_id.id))
.InSequence(seq)
.WillOnce(Return());
delegate_->UpdateAccountList(account1_.account_id, {account2_.account_id},
{account1_.account_id, account2_.account_id});
EXPECT_EQ(std::vector<AccountInfo>({account1_, account2_}),
account_tracker_service_.GetAccounts());
}
TEST_F(OAuth2TokenServiceDelegateAndroidTest,
UpdateAccountListWith1SystemAccount2AccountAndSignedIn) {
Sequence seq;
EXPECT_CALL(*delegate_,
SetAccounts(std::vector<CoreAccountId>({account1_.account_id})))
.InSequence(seq)
.WillOnce(Return());
// OnRefreshTokenAvailable fired, signed in account should go first.
EXPECT_CALL(observer_, OnRefreshTokenAvailable(account1_.account_id.id))
.InSequence(seq)
.WillOnce(Return());
EXPECT_CALL(observer_, OnRefreshTokenRevoked(account2_.account_id.id))
.InSequence(seq)
.WillOnce(Return());
delegate_->UpdateAccountList(account1_.account_id,
{account1_.account_id, account2_.account_id},
{account1_.account_id});
EXPECT_EQ(std::vector<AccountInfo>({account1_}),
account_tracker_service_.GetAccounts());
}
} // namespace signin
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