Commit 7dbf5736 authored by Jan Krcal's avatar Jan Krcal Committed by Commit Bot

[Wallet] Fix waiting in single client wallet integration tests

Some of the the single client wallet tests used imprecise and possibly
flaky waiting routines -- waiting for PDM to trigger
OnPersonalDataChanged() once. This can signify that it has reloaded new
data from the WebDB but this notification is also triggered in various
other situation so it can mean nothing.

This CL removes this approach from all remaining tests (except for one
where there's no better solution and where it arguably cannot cause
flakiness) The CL replaces the previous approach with a more robust
waiting loop that waits for such notifications until PDM has provably
loaded new data. This CL also cleans up various helper functions.

The CL only re-enables one disabled test, other tests will be enabled by
follow-up CLs provided we see no new flakes.

Bug: 1001975
Change-Id: I555a72ec07f0884285a39f0bdb5d184f70147fd9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1998520
Commit-Queue: Maxim Kolosovskiy <kolos@chromium.org>
Reviewed-by: default avatarMaxim Kolosovskiy <kolos@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Auto-Submit: Jan Krcal <jkrcal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733308}
parent 07c6eeca
......@@ -471,12 +471,7 @@ void PersonalDataManager::OnWebDataServiceRequestDone(
// If all requests have responded, then all personal data is loaded.
// We need to check if the server database is set here, because we won't have
// the server data yet if we don't have the database.
if (pending_profiles_query_ == 0 && pending_creditcards_query_ == 0 &&
pending_server_profiles_query_ == 0 &&
pending_server_creditcards_query_ == 0 &&
pending_server_creditcard_cloud_token_data_query_ == 0 &&
pending_customer_data_query_ == 0 &&
database_helper_->GetServerDatabase()) {
if (!HasPendingQueries() && database_helper_->GetServerDatabase()) {
// On initial data load, is_data_loaded_ will be false here.
if (!is_data_loaded_) {
// If sync is enabled for addresses, defer running cleanups until address
......@@ -1674,6 +1669,10 @@ void PersonalDataManager::CancelPendingServerQueries() {
CancelPendingServerQuery(&pending_server_creditcard_cloud_token_data_query_);
}
bool PersonalDataManager::HasPendingQueriesForTesting() {
return HasPendingQueries();
}
void PersonalDataManager::LoadPaymentsCustomerData() {
if (!database_helper_->GetServerDatabase())
return;
......@@ -2517,6 +2516,14 @@ void PersonalDataManager::ClearOnGoingProfileChanges() {
ongoing_profile_changes_.clear();
}
bool PersonalDataManager::HasPendingQueries() {
return pending_profiles_query_ != 0 || pending_creditcards_query_ != 0 ||
pending_server_profiles_query_ != 0 ||
pending_server_creditcards_query_ != 0 ||
pending_server_creditcard_cloud_token_data_query_ != 0 ||
pending_customer_data_query_ != 0;
}
void PersonalDataManager::MigrateUserOptedInWalletSyncTransportIfNeeded() {
CoreAccountInfo primary_account =
sync_service_->GetAuthenticatedAccountInfo();
......
......@@ -342,6 +342,9 @@ class PersonalDataManager : public KeyedService,
// Cancels any pending queries to the server web database.
void CancelPendingServerQueries();
// Returns if there are any pending queries to the web database.
bool HasPendingQueriesForTesting();
// This function assumes |credit_card| contains the full PAN. Returns |true|
// if the card number of |credit_card| is equal to any local card or any
// unmasked server card known by the browser, or |TypeAndLastFourDigits| of
......@@ -716,6 +719,9 @@ class PersonalDataManager : public KeyedService,
// Clear |ongoing_profile_changes_|.
void ClearOnGoingProfileChanges();
// Returns if there are any pending queries to the web database.
bool HasPendingQueries();
// Migrates the user opted in to wallet sync transport. This is needed while
// migrating from using email to Gaia ID as th account identifier.
void MigrateUserOptedInWalletSyncTransportIfNeeded();
......
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