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 |