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

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: Coding style fixes and refactoring 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..d01cf56ce131d33240fff4ad52fdc2d6b3441522 100644
--- a/components/suggestions/suggestions_service_unittest.cc
+++ b/components/suggestions/suggestions_service_unittest.cc
@@ -94,6 +94,24 @@ scoped_ptr<SuggestionsProfile> CreateSuggestionsProfile() {
return profile.Pass();
}
+// Create one suggestion with expiry timestamp and one without
Mathieu 2014/08/04 14:39:10 *Creates Also period at the end of the comment.
gayane -on leave until 09-2017 2014/08/04 16:34:58 Done.
+SuggestionsProfile CreateSuggestionsProfileWithExpiryTimestamps() {
+ int64 now = (base::Time::NowFromSystemTime() - base::Time::UnixEpoch())
Mathieu 2014/08/04 14:39:10 Have you tried ToJavaTime? I think it could be com
gayane -on leave until 09-2017 2014/08/04 16:34:58 then I would need to do base::Time::NowFromSystemT
+ .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 +515,20 @@ TEST_F(SuggestionsServiceTest, UpdateBlacklistDelay) {
EXPECT_EQ(initial_delay, suggestions_service->blacklist_delay());
}
+TEST_F(SuggestionsServiceTest, CheckDefaultTimeStamps) {
+
+ scoped_ptr<SuggestionsService> suggestions_service(
+ CreateSuggestionsServiceWithMocks());
+ SuggestionsProfile suggestions =
+ CreateSuggestionsProfileWithExpiryTimestamps();
Mathieu 2014/08/04 14:39:10 Indentation is off. Indent 4 from the start of the
gayane -on leave until 09-2017 2014/08/04 16:34:58 Done.
+ int64 now_usec = (base::Time::NowFromSystemTime() - base::Time::UnixEpoch())
+ .ToInternalValue();
+ int64 default_timestamp_usec = now_usec +
+ SuggestionsService::default_expiry_usec;
Mathieu 2014/08/04 14:39:10 do you need the "SuggestionsService::"?
gayane -on leave until 09-2017 2014/08/04 16:34:58 Done.
+ suggestions_service->SetDefaultExpiryTimestamps(&suggestions,
+ default_timestamp_usec);
+
+ EXPECT_NE(suggestions.suggestions(0).expiry_ts(), default_timestamp_usec);
+ EXPECT_EQ(suggestions.suggestions(1).expiry_ts(), default_timestamp_usec);
+}
} // namespace suggestions

Powered by Google App Engine
This is Rietveld 408576698