De-flakify MetricsServiceTest.RegisterSyntheticTrial.
The test relied on TimeTicks::Now() changing between
several lines of code. This is flaky, since on a
sufficiently fast machine, that may not end up the
case.
This CL fixes that cause of flakyness (and re-enables
the test) by making sure TimeTicks::Now() changes.
According to the docs for TimeTicks::Now(), its
resolution is ~1-15ms, so this shouldn't cause a
huge delay in the test.
Also changes the SyntheticTrialGroup constructor
to not take the start_time parameter since it gets
clobbered by the API anyway.
BUG=320433
Review URL: https://codereview.chromium.org/178383002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@253410 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/metrics/metrics_service.cc b/chrome/browser/metrics/metrics_service.cc
index a3c0b83..4865ffd0 100644
--- a/chrome/browser/metrics/metrics_service.cc
+++ b/chrome/browser/metrics/metrics_service.cc
@@ -356,10 +356,7 @@
} // namespace
-SyntheticTrialGroup::SyntheticTrialGroup(uint32 trial,
- uint32 group,
- base::TimeTicks start)
- : start_time(start) {
+SyntheticTrialGroup::SyntheticTrialGroup(uint32 trial, uint32 group) {
id.name = trial;
id.group = group;
}
@@ -1821,14 +1818,14 @@
if (synthetic_trial_groups_[i].id.name == trial.id.name) {
if (synthetic_trial_groups_[i].id.group != trial.id.group) {
synthetic_trial_groups_[i].id.group = trial.id.group;
- synthetic_trial_groups_[i].start_time = trial.start_time;
+ synthetic_trial_groups_[i].start_time = base::TimeTicks::Now();
}
return;
}
}
- SyntheticTrialGroup trial_group(
- trial.id.name, trial.id.group, base::TimeTicks::Now());
+ SyntheticTrialGroup trial_group = trial;
+ trial_group.start_time = base::TimeTicks::Now();
synthetic_trial_groups_.push_back(trial_group);
}