Chromium Code Reviews| 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..7f8f310ef5876a0c04f2b74651490f40c58a5303 100644 |
| --- a/components/suggestions/suggestions_service_unittest.cc |
| +++ b/components/suggestions/suggestions_service_unittest.cc |
| @@ -46,6 +46,9 @@ const char kFakeBlacklistUrlParam[] = "baz"; |
| const char kTestTitle[] = "a title"; |
| const char kTestUrl[] = "http://go.com"; |
| const char kBlacklistUrl[] = "http://blacklist.com"; |
| +const int64 kTestExpiry = |
| + (base::Time::NowFromSystemTime() - base::Time::UnixEpoch()) |
| + .ToInternalValue() + suggestions::kDefaultExpiryUsec; |
| scoped_ptr<net::FakeURLFetcher> CreateURLFetcher( |
| const GURL& url, net::URLFetcherDelegate* delegate, |
| @@ -94,6 +97,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 +517,13 @@ 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(); |
| + suggestions_service->SetDefaultExpiryTimestamp(&suggestions, kTestExpiry); |
| + EXPECT_NE(suggestions.suggestions(0).expiry_ts(), kTestExpiry); |
|
manzagop (departed)
2014/08/05 15:30:26
An equality test is a stronger statement. I'd keep
gayane -on leave until 09-2017
2014/08/06 14:40:55
Done.
|
| + EXPECT_EQ(suggestions.suggestions(1).expiry_ts(), kTestExpiry); |
| +} |
| } // namespace suggestions |