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

Side by Side Diff: components/offline_pages/content/suggested_articles_observer_unittest.cc

Issue 2820263002: [Offline Prefetch] Create a new JobScheduler task to wake up for net activity. (Closed)
Patch Set: tommycli@ comments. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/offline_pages/content/suggested_articles_observer.h" 5 #include "components/offline_pages/content/suggested_articles_observer.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/test/test_simple_task_runner.h" 8 #include "base/test/test_simple_task_runner.h"
9 #include "base/threading/thread_task_runner_handle.h" 9 #include "base/threading/thread_task_runner_handle.h"
10 #include "components/offline_pages/core/client_namespace_constants.h" 10 #include "components/offline_pages/core/client_namespace_constants.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 latest_prefetch_urls.clear(); 42 latest_prefetch_urls.clear();
43 remove_all_suggestions_count++; 43 remove_all_suggestions_count++;
44 } 44 }
45 45
46 void RemovePrefetchURLsByClientId(const ClientId& client_id) override { 46 void RemovePrefetchURLsByClientId(const ClientId& client_id) override {
47 DCHECK_EQ(client_id.name_space, kSuggestedArticlesNamespace); 47 DCHECK_EQ(client_id.name_space, kSuggestedArticlesNamespace);
48 remove_by_client_id_count++; 48 remove_by_client_id_count++;
49 last_removed_client_id = base::MakeUnique<ClientId>(client_id); 49 last_removed_client_id = base::MakeUnique<ClientId>(client_id);
50 } 50 }
51 51
52 void BeginBackgroundTask(
53 std::unique_ptr<ScopedBackgroundTask> task) override {}
54 void StopBackgroundTask(ScopedBackgroundTask* task) override {}
55
52 std::vector<PrefetchURL> latest_prefetch_urls; 56 std::vector<PrefetchURL> latest_prefetch_urls;
53 std::unique_ptr<ClientId> last_removed_client_id; 57 std::unique_ptr<ClientId> last_removed_client_id;
54 58
55 int new_suggestions_count = 0; 59 int new_suggestions_count = 0;
56 int remove_all_suggestions_count = 0; 60 int remove_all_suggestions_count = 0;
57 int remove_by_client_id_count = 0; 61 int remove_by_client_id_count = 0;
58 }; 62 };
59 63
60 class TestDelegate : public SuggestedArticlesObserver::Delegate { 64 class TestDelegate : public SuggestedArticlesObserver::Delegate {
61 public: 65 public:
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 189
186 observer()->OnSuggestionInvalidated( 190 observer()->OnSuggestionInvalidated(
187 ntp_snippets::ContentSuggestion::ID(category, test_url_1.spec())); 191 ntp_snippets::ContentSuggestion::ID(category, test_url_1.spec()));
188 192
189 EXPECT_EQ(1, test_prefetch_service()->remove_by_client_id_count); 193 EXPECT_EQ(1, test_prefetch_service()->remove_by_client_id_count);
190 EXPECT_EQ(ClientId(kSuggestedArticlesNamespace, test_url_1.spec()), 194 EXPECT_EQ(ClientId(kSuggestedArticlesNamespace, test_url_1.spec()),
191 *test_prefetch_service()->last_removed_client_id); 195 *test_prefetch_service()->last_removed_client_id);
192 } 196 }
193 197
194 } // namespace offline_pages 198 } // namespace offline_pages
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698