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

Unified Diff: components/offline_pages/core/prefetch/suggested_articles_observer_unittest.cc

Issue 2879013002: Create skeleton for the Prefetching store and initial pipeline step. (Closed)
Patch Set: Made construction params a cost&. Created 3 years, 7 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/offline_pages/core/prefetch/suggested_articles_observer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/offline_pages/core/prefetch/suggested_articles_observer_unittest.cc
diff --git a/components/offline_pages/core/prefetch/suggested_articles_observer_unittest.cc b/components/offline_pages/core/prefetch/suggested_articles_observer_unittest.cc
index f813d52929853115fd4d99c72bfc079c97529d94..6ed4c1b5805e65729eef922fe7b7c5112a45a41d 100644
--- a/components/offline_pages/core/prefetch/suggested_articles_observer_unittest.cc
+++ b/components/offline_pages/core/prefetch/suggested_articles_observer_unittest.cc
@@ -32,23 +32,25 @@ class TestingPrefetchDispatcher : public PrefetchDispatcher {
public:
TestingPrefetchDispatcher() = default;
+ void SetService(PrefetchService* service) override{};
+
void AddCandidatePrefetchURLs(
- const std::vector<PrefetchURL>& suggested_urls) override {
- latest_prefetch_urls = suggested_urls;
+ const std::vector<PrefetchURL>& prefetch_urls) override {
+ latest_prefetch_urls = prefetch_urls;
new_suggestions_count++;
}
void RemoveAllUnprocessedPrefetchURLs(
const std::string& name_space) override {
- DCHECK_EQ(name_space, kSuggestedArticlesNamespace);
+ DCHECK_EQ(kSuggestedArticlesNamespace, name_space);
latest_prefetch_urls.clear();
remove_all_suggestions_count++;
}
void RemovePrefetchURLsByClientId(const ClientId& client_id) override {
- DCHECK_EQ(client_id.name_space, kSuggestedArticlesNamespace);
+ DCHECK_EQ(kSuggestedArticlesNamespace, client_id.name_space);
remove_by_client_id_count++;
- last_removed_client_id = base::MakeUnique<ClientId>(client_id);
+ last_removed_client_id = client_id;
}
void BeginBackgroundTask(
@@ -56,7 +58,7 @@ class TestingPrefetchDispatcher : public PrefetchDispatcher {
void StopBackgroundTask(ScopedBackgroundTask* task) override {}
std::vector<PrefetchURL> latest_prefetch_urls;
- std::unique_ptr<ClientId> last_removed_client_id;
+ ClientId last_removed_client_id;
int new_suggestions_count = 0;
int remove_all_suggestions_count = 0;
@@ -67,17 +69,19 @@ class TestingPrefetchService : public PrefetchService {
public:
TestingPrefetchService() = default;
- void ObserveContentSuggestionsService(
- ntp_snippets::ContentSuggestionsService* content_suggestions_service)
- override {}
- PrefetchDispatcher* GetDispatcher() override { return &dispatcher; };
OfflineMetricsCollector* GetOfflineMetricsCollector() override {
return nullptr;
}
+ PrefetchDispatcher* GetPrefetchDispatcher() override { return &dispatcher; }
PrefetchGCMHandler* GetPrefetchGCMHandler() override { return nullptr; }
+ PrefetchStore* GetPrefetchStore() override { return nullptr; }
+ void ObserveContentSuggestionsService(
+ ntp_snippets::ContentSuggestionsService* content_suggestions_service)
+ override {}
TestingPrefetchDispatcher dispatcher;
};
+
} // namespace
class OfflinePageSuggestedArticlesObserverTest : public testing::Test {
@@ -159,8 +163,11 @@ TEST_F(OfflinePageSuggestedArticlesObserverTest, RemovesClientIdOnInvalidated) {
ntp_snippets::ContentSuggestion::ID(category, test_url_1.spec()));
EXPECT_EQ(1, test_prefetch_dispatcher()->remove_by_client_id_count);
- EXPECT_EQ(ClientId(kSuggestedArticlesNamespace, test_url_1.spec()),
- *test_prefetch_dispatcher()->last_removed_client_id);
+ EXPECT_EQ(test_url_1.spec(),
+ test_prefetch_dispatcher()->last_removed_client_id.id);
+ EXPECT_EQ(
+ kSuggestedArticlesNamespace,
+ test_prefetch_dispatcher()->latest_prefetch_urls[0].client_id.name_space);
}
} // namespace offline_pages
« no previous file with comments | « components/offline_pages/core/prefetch/suggested_articles_observer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698