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..41a5b04df8607297db59cb3daa6286e4893689c7 100644 |
--- a/components/suggestions/suggestions_service_unittest.cc |
+++ b/components/suggestions/suggestions_service_unittest.cc |
@@ -46,6 +46,12 @@ const char kFakeBlacklistUrlParam[] = "baz"; |
const char kTestTitle[] = "a title"; |
const char kTestUrl[] = "http://go.com"; |
const char kBlacklistUrl[] = "http://blacklist.com"; |
+const int64 kTestDefaultExpiry = |
+ (base::Time::NowFromSystemTime() - base::Time::UnixEpoch()) |
manzagop (departed)
2014/08/06 19:11:18
Does calling those functions bring added value com
gayane -on leave until 09-2017
2014/08/06 21:12:20
Done.
|
+ .ToInternalValue() + suggestions::kDefaultExpiryUsec; |
+const int64 kTestSetExpiry = |
+ (base::Time::NowFromSystemTime() - base::Time::UnixEpoch()) |
+ .ToInternalValue(); |
scoped_ptr<net::FakeURLFetcher> CreateURLFetcher( |
const GURL& url, net::URLFetcherDelegate* delegate, |
@@ -94,6 +100,21 @@ scoped_ptr<SuggestionsProfile> CreateSuggestionsProfile() { |
return profile.Pass(); |
} |
+// Creates one suggestion with expiry timestamp and one without. |
+SuggestionsProfile CreateSuggestionsProfileWithExpiryTimestamps() { |
+ SuggestionsProfile profile; |
+ ChromeSuggestion* suggestion = profile.add_suggestions(); |
+ suggestion->set_title(kTestTitle); |
+ suggestion->set_url(kTestUrl); |
+ suggestion->set_expiry_ts(kTestSetExpiry); |
+ |
+ 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 +518,14 @@ 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, |
+ kTestDefaultExpiry); |
+ EXPECT_EQ(suggestions.suggestions(0).expiry_ts(), kTestSetExpiry); |
+ EXPECT_EQ(suggestions.suggestions(1).expiry_ts(), kTestDefaultExpiry); |
+} |
} // namespace suggestions |