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

Unified Diff: components/suggestions/suggestions_service_unittest.cc

Issue 423133003: [Suggestions Service] Add support for expiring the SuggestionsStore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more fixes Created 6 years, 4 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
Index: components/suggestions/suggestions_service_unittest.cc
diff --git a/components/suggestions/suggestions_service_unittest.cc b/components/suggestions/suggestions_service_unittest.cc
index 0d082ea4f83f7fa256bc922a4b4dd8ee96bce1c4..4b52fd8530920a52bf5690e1f437bfc94dbf5be9 100644
--- a/components/suggestions/suggestions_service_unittest.cc
+++ b/components/suggestions/suggestions_service_unittest.cc
@@ -94,6 +94,23 @@ scoped_ptr<SuggestionsProfile> CreateSuggestionsProfile() {
return profile.Pass();
}
+// Creates one suggestion with expiry timestamp and one without.
+SuggestionsProfile CreateSuggestionsProfileWithExpiryTimestamps() {
+ int64 now = (base::Time::NowFromSystemTime() - base::Time::UnixEpoch())
+ .ToInternalValue();
+ SuggestionsProfile profile;
+ ChromeSuggestion* suggestion = profile.add_suggestions();
+ suggestion->set_title(kTestTitle);
+ suggestion->set_url(kTestUrl);
+ suggestion->set_expiry_ts(now);
+
+ suggestion = profile.add_suggestions();
+ suggestion->set_title(kTestTitle);
+ suggestion->set_url(kTestUrl);
+
+ return profile;
+}
+
class MockSuggestionsStore : public suggestions::SuggestionsStore {
public:
MOCK_METHOD1(LoadSuggestions, bool(SuggestionsProfile*));
@@ -497,4 +514,19 @@ TEST_F(SuggestionsServiceTest, UpdateBlacklistDelay) {
EXPECT_EQ(initial_delay, suggestions_service->blacklist_delay());
}
+TEST_F(SuggestionsServiceTest, CheckDefaultTimeStamps) {
+
manzagop (departed) 2014/08/04 19:50:26 extra line
gayane -on leave until 09-2017 2014/08/05 14:39:15 Done.
+ scoped_ptr<SuggestionsService> suggestions_service(
+ CreateSuggestionsServiceWithMocks());
+ SuggestionsProfile suggestions =
+ CreateSuggestionsProfileWithExpiryTimestamps();
+ int64 now_usec = (base::Time::NowFromSystemTime() - base::Time::UnixEpoch())
+ .ToInternalValue();
+ int64 default_timestamp_usec = now_usec + kDefaultExpiryUsec;
+ suggestions_service->SetDefaultExpiryTimestamps(&suggestions,
+ default_timestamp_usec);
+
+ EXPECT_NE(suggestions.suggestions(0).expiry_ts(), default_timestamp_usec);
manzagop (departed) 2014/08/04 19:50:25 Perhaps you could ensure it's a specific value by
gayane -on leave until 09-2017 2014/08/05 14:39:15 Done.
+ EXPECT_EQ(suggestions.suggestions(1).expiry_ts(), default_timestamp_usec);
+}
} // namespace suggestions

Powered by Google App Engine
This is Rietveld 408576698