| OLD | NEW |
| 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 "chrome/browser/android/offline_pages/suggested_articles_observer.h" | 5 #include "chrome/browser/android/offline_pages/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 "chrome/test/base/testing_profile.h" | 10 #include "chrome/test/base/testing_profile.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 latest_prefetch_urls.clear(); | 43 latest_prefetch_urls.clear(); |
| 44 remove_all_suggestions_count++; | 44 remove_all_suggestions_count++; |
| 45 } | 45 } |
| 46 | 46 |
| 47 void RemovePrefetchURLsByClientId(const ClientId& client_id) override { | 47 void RemovePrefetchURLsByClientId(const ClientId& client_id) override { |
| 48 DCHECK_EQ(client_id.name_space, kSuggestedArticlesNamespace); | 48 DCHECK_EQ(client_id.name_space, kSuggestedArticlesNamespace); |
| 49 remove_by_client_id_count++; | 49 remove_by_client_id_count++; |
| 50 last_removed_client_id = base::MakeUnique<ClientId>(client_id); | 50 last_removed_client_id = base::MakeUnique<ClientId>(client_id); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void BeginBackgroundTask( |
| 54 std::unique_ptr<ScopedBackgroundTask> task) override {} |
| 55 void StopBackgroundTask(ScopedBackgroundTask* task) override {} |
| 56 |
| 53 std::vector<PrefetchURL> latest_prefetch_urls; | 57 std::vector<PrefetchURL> latest_prefetch_urls; |
| 54 std::unique_ptr<ClientId> last_removed_client_id; | 58 std::unique_ptr<ClientId> last_removed_client_id; |
| 55 | 59 |
| 56 int new_suggestions_count = 0; | 60 int new_suggestions_count = 0; |
| 57 int remove_all_suggestions_count = 0; | 61 int remove_all_suggestions_count = 0; |
| 58 int remove_by_client_id_count = 0; | 62 int remove_by_client_id_count = 0; |
| 59 }; | 63 }; |
| 60 | 64 |
| 61 class TestDelegate : public SuggestedArticlesObserver::Delegate { | 65 class TestDelegate : public SuggestedArticlesObserver::Delegate { |
| 62 public: | 66 public: |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 191 |
| 188 observer()->OnSuggestionInvalidated( | 192 observer()->OnSuggestionInvalidated( |
| 189 ntp_snippets::ContentSuggestion::ID(category, test_url_1.spec())); | 193 ntp_snippets::ContentSuggestion::ID(category, test_url_1.spec())); |
| 190 | 194 |
| 191 EXPECT_EQ(1, test_prefetch_service()->remove_by_client_id_count); | 195 EXPECT_EQ(1, test_prefetch_service()->remove_by_client_id_count); |
| 192 EXPECT_EQ(ClientId(kSuggestedArticlesNamespace, test_url_1.spec()), | 196 EXPECT_EQ(ClientId(kSuggestedArticlesNamespace, test_url_1.spec()), |
| 193 *test_prefetch_service()->last_removed_client_id); | 197 *test_prefetch_service()->last_removed_client_id); |
| 194 } | 198 } |
| 195 | 199 |
| 196 } // namespace offline_pages | 200 } // namespace offline_pages |
| OLD | NEW |