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

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: unittest fixes 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
« no previous file with comments | « components/suggestions/suggestions_service.cc ('k') | components/suggestions/suggestions_store.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5f06c7c19b60a50370f9795d09b77a5745dd14a0 100644
--- a/components/suggestions/suggestions_service_unittest.cc
+++ b/components/suggestions/suggestions_service_unittest.cc
@@ -46,6 +46,8 @@ const char kFakeBlacklistUrlParam[] = "baz";
const char kTestTitle[] = "a title";
const char kTestUrl[] = "http://go.com";
const char kBlacklistUrl[] = "http://blacklist.com";
+const int64 kTestDefaultExpiry = 1402200000000000;
+const int64 kTestSetExpiry = 1404792000000000;
scoped_ptr<net::FakeURLFetcher> CreateURLFetcher(
const GURL& url, net::URLFetcherDelegate* delegate,
@@ -91,9 +93,25 @@ scoped_ptr<SuggestionsProfile> CreateSuggestionsProfile() {
ChromeSuggestion* suggestion = profile->add_suggestions();
suggestion->set_title(kTestTitle);
suggestion->set_url(kTestUrl);
+ suggestion->set_expiry_ts(kTestSetExpiry);
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*));
@@ -202,14 +220,12 @@ class SuggestionsServiceTest : public testing::Test {
EXPECT_TRUE(suggestions_service != NULL);
scoped_ptr<SuggestionsProfile> suggestions_profile(
CreateSuggestionsProfile());
-
// Set up net::FakeURLFetcherFactory.
std::string expected_url =
(std::string(kFakeSuggestionsURL) + "?") + kFakeSuggestionsCommonParams;
factory_.SetFakeResponse(GURL(expected_url),
suggestions_profile->SerializeAsString(),
net::HTTP_OK, net::URLRequestStatus::SUCCESS);
-
// Set up expectations on the SuggestionsStore. The number depends on
// whether the second request is issued (it won't be issued if the second
// fetch occurs before the first request has completed).
@@ -497,4 +513,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(kTestSetExpiry, suggestions.suggestions(0).expiry_ts());
+ EXPECT_EQ(kTestDefaultExpiry, suggestions.suggestions(1).expiry_ts());
+}
} // namespace suggestions
« no previous file with comments | « components/suggestions/suggestions_service.cc ('k') | components/suggestions/suggestions_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698