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..81f1a3d13b025459be3ab2f53ad4e977a95fba86 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 |
+SuggestionsProfile CreateSuggestionsProfile_MultipleSuggestions() { |
manzagop (departed)
2014/07/31 15:31:50
CreateSuggestionsProfileWithSomeExpiryTimestamps?
gayane -on leave until 09-2017
2014/08/04 13:46:30
Done.
|
+ int64 now = (base::Time::NowFromSystemTime() |
+ -base::Time::UnixEpoch()).ToInternalValue(); |
manzagop (departed)
2014/07/31 15:31:50
indent. See other comments for the details.
gayane -on leave until 09-2017
2014/08/04 13:46:30
Done.
|
+ |
+ 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 = |
+ CreateSuggestionsProfile_MultipleSuggestions(); |
+ suggestions_service->AddDefaultExpiryTimestamps(&suggestions); |
+ |
+ int64 now = (base::Time::NowFromSystemTime() |
+ -base::Time::UnixEpoch()).ToInternalValue(); |
+ |
+ EXPECT_LT(suggestions.suggestions(0).expiry_ts(), now); |
manzagop (departed)
2014/07/31 15:31:50
You could simplify testing by having AddDefaultExp
gayane -on leave until 09-2017
2014/08/04 13:46:30
----
1. added a const private field in suggestions
|
+ EXPECT_GT(suggestions.suggestions(1).expiry_ts(), now); |
+} |
+ |
} // namespace suggestions |