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

Unified Diff: components/offline_pages/content/suggested_articles_observer_unittest.cc

Issue 2879013002: Create skeleton for the Prefetching store and initial pipeline step. (Closed)
Patch Set: Dispatcher instance is now injected into Service. Minor changes. 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
Index: components/offline_pages/content/suggested_articles_observer_unittest.cc
diff --git a/components/offline_pages/content/suggested_articles_observer_unittest.cc b/components/offline_pages/content/suggested_articles_observer_unittest.cc
index 6fae70d85ce8c4c5ddd046dbfd82ffb3c4b1b359..0ab41ac109cfbfdb23c40ab3b395d5116358d33e 100644
--- a/components/offline_pages/content/suggested_articles_observer_unittest.cc
+++ b/components/offline_pages/content/suggested_articles_observer_unittest.cc
@@ -32,31 +32,39 @@ 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::string& name_space,
+ const std::vector<PrefetchURL>& prefetch_urls) override {
+ latest_name_space = name_space;
+ 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);
+ void RemovePrefetchURLsByClientId(const std::string& name_space,
+ const std::string& client_id) override {
+ DCHECK_EQ(kSuggestedArticlesNamespace, name_space);
remove_by_client_id_count++;
- last_removed_client_id = base::MakeUnique<ClientId>(client_id);
+ last_removed_name_space = name_space;
+ last_removed_client_id = client_id;
}
void BeginBackgroundTask(
std::unique_ptr<ScopedBackgroundTask> task) override {}
void StopBackgroundTask(ScopedBackgroundTask* task) override {}
+ std::string latest_name_space;
std::vector<PrefetchURL> latest_prefetch_urls;
- std::unique_ptr<ClientId> last_removed_client_id;
+ std::string last_removed_name_space;
+ std::string last_removed_client_id;
int new_suggestions_count = 0;
int remove_all_suggestions_count = 0;
@@ -68,6 +76,10 @@ class TestingPrefetchService : public PrefetchService {
TestingPrefetchService() = default;
PrefetchDispatcher* GetDispatcher() override { return &dispatcher; };
+ PrefetchStore* GetStore() override {
+ CHECK(false);
+ return nullptr;
+ };
TestingPrefetchDispatcher dispatcher;
};
@@ -168,9 +180,8 @@ TEST_F(OfflinePageSuggestedArticlesObserverTest,
EXPECT_EQ(1U, test_prefetch_dispatcher()->latest_prefetch_urls.size());
EXPECT_EQ(test_url_1,
test_prefetch_dispatcher()->latest_prefetch_urls[0].url);
- EXPECT_EQ(
- kSuggestedArticlesNamespace,
- test_prefetch_dispatcher()->latest_prefetch_urls[0].client_id.name_space);
+ EXPECT_EQ(kSuggestedArticlesNamespace,
+ test_prefetch_dispatcher()->latest_name_space);
}
TEST_F(OfflinePageSuggestedArticlesObserverTest, RemovesAllOnBadStatus) {
@@ -208,8 +219,10 @@ 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);
+ EXPECT_EQ(kSuggestedArticlesNamespace,
+ test_prefetch_dispatcher()->last_removed_name_space);
}
} // namespace offline_pages

Powered by Google App Engine
This is Rietveld 408576698