Commit fda159c4 authored by Anastasiia N's avatar Anastasiia N Committed by Commit Bot

Re-enable AccountManagerUIHandlerTest tests

Fix creation and destruction of testing profile and user manager in
AccountManagerUIHandlerTest.

Bug: 1131834, 1131819
Change-Id: I5c7dbf396f5e48cec3285796a6f6a5f60b71d43d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2438059Reviewed-by: default avatarKush Sinha <sinhak@chromium.org>
Commit-Queue: Anastasiia N <anastasiian@chromium.org>
Cr-Commit-Position: refs/heads/master@{#813123}
parent 86c8f94e
...@@ -126,8 +126,6 @@ class AccountManagerUIHandlerTest ...@@ -126,8 +126,6 @@ class AccountManagerUIHandlerTest
delete; delete;
void SetUpOnMainThread() override { void SetUpOnMainThread() override {
user_manager_enabler_ = std::make_unique<user_manager::ScopedUserManager>(
std::make_unique<chromeos::FakeChromeUserManager>());
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
TestingProfile::Builder profile_builder; TestingProfile::Builder profile_builder;
profile_builder.SetPath(temp_dir_.GetPath().AppendASCII("TestProfile")); profile_builder.SetPath(temp_dir_.GetPath().AppendASCII("TestProfile"));
...@@ -138,6 +136,7 @@ class AccountManagerUIHandlerTest ...@@ -138,6 +136,7 @@ class AccountManagerUIHandlerTest
} }
profile_ = profile_builder.Build(); profile_ = profile_builder.Build();
auto user_manager = std::make_unique<chromeos::FakeChromeUserManager>();
const user_manager::User* user; const user_manager::User* user;
if (GetDeviceAccountInfo().user_type == if (GetDeviceAccountInfo().user_type ==
user_manager::UserType::USER_TYPE_ACTIVE_DIRECTORY) { user_manager::UserType::USER_TYPE_ACTIVE_DIRECTORY) {
...@@ -156,6 +155,12 @@ class AccountManagerUIHandlerTest ...@@ -156,6 +155,12 @@ class AccountManagerUIHandlerTest
GetDeviceAccountInfo().id), GetDeviceAccountInfo().id),
true, GetDeviceAccountInfo().user_type, profile_.get()); true, GetDeviceAccountInfo().user_type, profile_.get());
} }
primary_account_id_ = user->GetAccountId();
user_manager->LoginUser(primary_account_id_);
ProfileHelper::Get()->SetUserToProfileMappingForTesting(user,
profile_.get());
user_manager_enabler_ = std::make_unique<user_manager::ScopedUserManager>(
std::move(user_manager));
identity_manager_ = IdentityManagerFactory::GetForProfile(profile_.get()); identity_manager_ = IdentityManagerFactory::GetForProfile(profile_.get());
...@@ -178,7 +183,9 @@ class AccountManagerUIHandlerTest ...@@ -178,7 +183,9 @@ class AccountManagerUIHandlerTest
void TearDownOnMainThread() override { void TearDownOnMainThread() override {
handler_.reset(); handler_.reset();
ProfileHelper::Get()->RemoveUserFromListForTesting(primary_account_id_);
profile_.reset(); profile_.reset();
base::RunLoop().RunUntilIdle();
user_manager_enabler_.reset(); user_manager_enabler_.reset();
} }
...@@ -223,12 +230,12 @@ class AccountManagerUIHandlerTest ...@@ -223,12 +230,12 @@ class AccountManagerUIHandlerTest
chromeos::AccountManager* account_manager_ = nullptr; chromeos::AccountManager* account_manager_ = nullptr;
signin::IdentityManager* identity_manager_ = nullptr; signin::IdentityManager* identity_manager_ = nullptr;
content::TestWebUI web_ui_; content::TestWebUI web_ui_;
AccountId primary_account_id_;
std::unique_ptr<TestingAccountManagerUIHandler> handler_; std::unique_ptr<TestingAccountManagerUIHandler> handler_;
}; };
// TODO(https://crbug.com/1131834): Re-enable flaky test.
IN_PROC_BROWSER_TEST_P(AccountManagerUIHandlerTest, IN_PROC_BROWSER_TEST_P(AccountManagerUIHandlerTest,
DISABLED_OnGetAccountsNoSecondaryAccounts) { OnGetAccountsNoSecondaryAccounts) {
const std::vector<AccountManager::Account> account_manager_accounts = const std::vector<AccountManager::Account> account_manager_accounts =
GetAccountsFromAccountManager(); GetAccountsFromAccountManager();
// Only Primary account. // Only Primary account.
...@@ -271,9 +278,8 @@ IN_PROC_BROWSER_TEST_P(AccountManagerUIHandlerTest, ...@@ -271,9 +278,8 @@ IN_PROC_BROWSER_TEST_P(AccountManagerUIHandlerTest,
} }
} }
// TODO(https://crbug.com/1131819): Re-enable flaky test.
IN_PROC_BROWSER_TEST_P(AccountManagerUIHandlerTest, IN_PROC_BROWSER_TEST_P(AccountManagerUIHandlerTest,
DISABLED_OnGetAccountsWithSecondaryAccounts) { OnGetAccountsWithSecondaryAccounts) {
UpsertAccount("secondary1@example.com"); UpsertAccount("secondary1@example.com");
UpsertAccount("secondary2@example.com"); UpsertAccount("secondary2@example.com");
const std::vector<AccountManager::Account> account_manager_accounts = const std::vector<AccountManager::Account> account_manager_accounts =
......
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