diff options
author | gayane <gayane@chromium.org> | 2014-12-11 09:12:14 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-12-11 17:12:49 +0000 |
commit | 546a2a8a39527d17244818089976f28036ffb0a3 (patch) | |
tree | a09d678b4d122b36c8e64293da9db9c148d8cea1 /components/suggestions | |
parent | 930a3ec03a7f35dcbf6c7e08c255233611a91f92 (diff) | |
download | chromium_src-546a2a8a39527d17244818089976f28036ffb0a3.zip chromium_src-546a2a8a39527d17244818089976f28036ffb0a3.tar.gz chromium_src-546a2a8a39527d17244818089976f28036ffb0a3.tar.bz2 |
suggestions_store_unittest is not using rand() anymore
suggestions_store_unittest is modified not to use rand() as it can be not deterministic even with a constant seed.
BUG=440255
Review URL: https://codereview.chromium.org/789373002
Cr-Commit-Position: refs/heads/master@{#307919}
Diffstat (limited to 'components/suggestions')
-rw-r--r-- | components/suggestions/suggestions_store_unittest.cc | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/components/suggestions/suggestions_store_unittest.cc b/components/suggestions/suggestions_store_unittest.cc index c50152f..ad5aa2a 100644 --- a/components/suggestions/suggestions_store_unittest.cc +++ b/components/suggestions/suggestions_store_unittest.cc @@ -17,7 +17,6 @@ namespace { const char kTestTitle[] = "Foo site"; const char kTestUrl[] = "http://foo.com/"; -const int kTimeGapUsec = 100000; void AddSuggestion(SuggestionsProfile* suggestions, const char *title, const char *url, int64 expiry_ts) { @@ -39,15 +38,15 @@ SuggestionsProfile CreateTestSuggestionsProfileWithExpiry(int expired_count, int valid_count) { int64 now_usec = (base::Time::NowFromSystemTime() - base::Time::UnixEpoch()) .ToInternalValue(); - srand(7); // Constant seed for rand() function. - int64 offset_limit_usec = 30 * base::Time::kMicrosecondsPerDay; - int64 offset_usec = rand() % offset_limit_usec + kTimeGapUsec; + int64 offset_usec = 5 * base::Time::kMicrosecondsPerMinute; SuggestionsProfile suggestions; - for (int i = 0; i < valid_count; i++) - AddSuggestion(&suggestions, kTestTitle, kTestUrl, now_usec + offset_usec); - for (int i = 0; i < expired_count; i++) - AddSuggestion(&suggestions, kTestTitle, kTestUrl, now_usec - offset_usec); + for (int i = 1; i <= valid_count; i++) + AddSuggestion(&suggestions, kTestTitle, kTestUrl, + now_usec + offset_usec * i); + for (int i = 1; i <= expired_count; i++) + AddSuggestion(&suggestions, kTestTitle, kTestUrl, + now_usec - offset_usec * i); return suggestions; } |