| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ntp_snippets/download_suggestions_provider.h" | 5 #include "chrome/browser/ntp_snippets/download_suggestions_provider.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 UnorderedElementsAre(HasUrl("http://download.com/1"), | 820 UnorderedElementsAre(HasUrl("http://download.com/1"), |
| 821 HasUrl("http://download.com/2")))); | 821 HasUrl("http://download.com/2")))); |
| 822 CreateLoadedProvider(/*show_assets=*/true, /*show_offline_pages=*/true); | 822 CreateLoadedProvider(/*show_assets=*/true, /*show_offline_pages=*/true); |
| 823 } | 823 } |
| 824 | 824 |
| 825 TEST_F(DownloadSuggestionsProviderTest, | 825 TEST_F(DownloadSuggestionsProviderTest, |
| 826 ShouldFetchOfflinePageDownloadsOnStartup) { | 826 ShouldFetchOfflinePageDownloadsOnStartup) { |
| 827 IgnoreOnCategoryStatusChangedToAvailable(); | 827 IgnoreOnCategoryStatusChangedToAvailable(); |
| 828 | 828 |
| 829 *(offline_pages_model()->mutable_items()) = CreateDummyOfflinePages({1, 2}); | 829 *(offline_pages_model()->mutable_items()) = CreateDummyOfflinePages({1, 2}); |
| 830 offline_pages_model()->set_is_loaded(true); | |
| 831 EXPECT_CALL(*observer(), OnNewSuggestions(_, downloads_category(), | 830 EXPECT_CALL(*observer(), OnNewSuggestions(_, downloads_category(), |
| 832 UnorderedElementsAre( | 831 UnorderedElementsAre( |
| 833 HasUrl("http://dummy.com/1"), | 832 HasUrl("http://dummy.com/1"), |
| 834 HasUrl("http://dummy.com/2")))); | 833 HasUrl("http://dummy.com/2")))); |
| 835 CreateProvider(/*show_assets=*/false, /*show_offline_pages=*/true); | 834 CreateProvider(/*show_assets=*/false, /*show_offline_pages=*/true); |
| 836 FireOfflinePageModelLoaded(); | 835 FireOfflinePageModelLoaded(); |
| 837 } | 836 } |
| 838 | 837 |
| 839 TEST_F(DownloadSuggestionsProviderTest, | 838 TEST_F(DownloadSuggestionsProviderTest, |
| 840 ShouldFetchAssetDownloadsOnHistoryQueryComplete) { | 839 ShouldFetchAssetDownloadsOnHistoryQueryComplete) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 HasUrl("http://download.com/2")))); | 921 HasUrl("http://download.com/2")))); |
| 923 CreateLoadedProvider(/*show_assets=*/true, /*show_offline_pages=*/false); | 922 CreateLoadedProvider(/*show_assets=*/true, /*show_offline_pages=*/false); |
| 924 } | 923 } |
| 925 | 924 |
| 926 TEST_F(DownloadSuggestionsProviderTest, | 925 TEST_F(DownloadSuggestionsProviderTest, |
| 927 ShouldLoadAndSubmitOfflinePagesEvenIfAssetDownloadsAreTurnedOff) { | 926 ShouldLoadAndSubmitOfflinePagesEvenIfAssetDownloadsAreTurnedOff) { |
| 928 IgnoreOnCategoryStatusChangedToAvailable(); | 927 IgnoreOnCategoryStatusChangedToAvailable(); |
| 929 IgnoreOnSuggestionInvalidated(); | 928 IgnoreOnSuggestionInvalidated(); |
| 930 | 929 |
| 931 *(offline_pages_model()->mutable_items()) = CreateDummyOfflinePages({1, 2}); | 930 *(offline_pages_model()->mutable_items()) = CreateDummyOfflinePages({1, 2}); |
| 932 offline_pages_model()->set_is_loaded(true); | |
| 933 EXPECT_CALL(*observer(), OnNewSuggestions(_, downloads_category(), | 931 EXPECT_CALL(*observer(), OnNewSuggestions(_, downloads_category(), |
| 934 UnorderedElementsAre( | 932 UnorderedElementsAre( |
| 935 HasUrl("http://dummy.com/1"), | 933 HasUrl("http://dummy.com/1"), |
| 936 HasUrl("http://dummy.com/2")))); | 934 HasUrl("http://dummy.com/2")))); |
| 937 CreateProvider(/*show_assets=*/false, /*show_offline_pages=*/true); | 935 CreateProvider(/*show_assets=*/false, /*show_offline_pages=*/true); |
| 938 } | 936 } |
| 939 | 937 |
| 940 TEST_F(DownloadSuggestionsProviderTest, ShouldStoreDismissedSuggestions) { | 938 TEST_F(DownloadSuggestionsProviderTest, ShouldStoreDismissedSuggestions) { |
| 941 IgnoreOnCategoryStatusChangedToAvailable(); | 939 IgnoreOnCategoryStatusChangedToAvailable(); |
| 942 IgnoreOnSuggestionInvalidated(); | 940 IgnoreOnSuggestionInvalidated(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 | 987 |
| 990 EXPECT_CALL(*observer(), OnNewSuggestions(_, _, _)); | 988 EXPECT_CALL(*observer(), OnNewSuggestions(_, _, _)); |
| 991 | 989 |
| 992 downloads_manager()->mutable_items()->clear(); | 990 downloads_manager()->mutable_items()->clear(); |
| 993 FireHistoryQueryComplete(); | 991 FireHistoryQueryComplete(); |
| 994 | 992 |
| 995 *(downloads_manager()->mutable_items()) = CreateDummyAssetDownloads({1}); | 993 *(downloads_manager()->mutable_items()) = CreateDummyAssetDownloads({1}); |
| 996 // Once the manager has been loaded, the ids should be pruned. | 994 // Once the manager has been loaded, the ids should be pruned. |
| 997 EXPECT_THAT(GetDismissedSuggestions(), IsEmpty()); | 995 EXPECT_THAT(GetDismissedSuggestions(), IsEmpty()); |
| 998 } | 996 } |
| OLD | NEW |