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

Unified Diff: components/autofill/core/browser/personal_data_manager_unittest.cc

Issue 2666313003: [Autofill] Make use of the test clock for Flaky test SaveImportedProfile (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/autofill/core/browser/personal_data_manager_unittest.cc
diff --git a/components/autofill/core/browser/personal_data_manager_unittest.cc b/components/autofill/core/browser/personal_data_manager_unittest.cc
index 272dcce1f2124fc8e0688f1984b744707b426975..f3f78d104f52cd349e83afd8b808241dee3ad0d1 100644
--- a/components/autofill/core/browser/personal_data_manager_unittest.cc
+++ b/components/autofill/core/browser/personal_data_manager_unittest.cc
@@ -4254,14 +4254,7 @@ TEST_F(PersonalDataManagerTest, DontDuplicateServerCard) {
// Tests the SaveImportedProfile method with different profiles to make sure the
// merge logic works correctly.
-// Flaky on TSan, see crbug.com/686226.
-#if defined(THREAD_SANITIZER)
-#define MAYBE_SaveImportedProfile DISABLED_SaveImportedProfile
-#else
-#define MAYBE_SaveImportedProfile SaveImportedProfile
-#endif
-
-TEST_F(PersonalDataManagerTest, MAYBE_SaveImportedProfile) {
+TEST_F(PersonalDataManagerTest, SaveImportedProfile) {
typedef struct {
autofill::ServerFieldType field_type;
std::string field_value;
@@ -4523,7 +4516,13 @@ TEST_F(PersonalDataManagerTest, MAYBE_SaveImportedProfile) {
{{COMPANY_NAME, "Stark Inc."}}},
};
+ // Create the test clock.
+ TestAutofillClock test_clock;
+
for (TestCase test_case : test_cases) {
+ // Set the time to a specific value.
+ test_clock.SetNow(kArbitraryTime);
+
SetupReferenceProfile();
const std::vector<AutofillProfile*>& initial_profiles =
personal_data_->GetProfiles();
@@ -4534,6 +4533,9 @@ TEST_F(PersonalDataManagerTest, MAYBE_SaveImportedProfile) {
change.field_type, base::UTF8ToUTF16(change.field_value));
}
+ // Set the time to a bigger value.
+ test_clock.SetNow(kSomeLaterTime);
+
AutofillProfile profile2(base::GenerateGUID(), "https://www.example.com");
test::SetProfileInfo(&profile2, "Marion", "Mitchell", "Morrison",
"johnwayne@me.xyz", "Fox", "123 Zoo St", "unit 5",
@@ -4565,11 +4567,8 @@ TEST_F(PersonalDataManagerTest, MAYBE_SaveImportedProfile) {
// Verify that the merged profile's use count, use date and modification
// date were properly updated.
EXPECT_EQ(1U, saved_profiles.front()->use_count());
- EXPECT_GT(base::TimeDelta::FromMilliseconds(500),
- AutofillClock::Now() - saved_profiles.front()->use_date());
- EXPECT_GT(
- base::TimeDelta::FromMilliseconds(500),
- AutofillClock::Now() - saved_profiles.front()->modification_date());
+ EXPECT_EQ(kSomeLaterTime, saved_profiles.front()->use_date());
+ EXPECT_EQ(kSomeLaterTime, saved_profiles.front()->modification_date());
}
// Erase the profiles for the next test.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698