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

Side by Side Diff: chrome/browser/ntp_snippets/download_suggestions_provider_unittest.cc

Issue 2683383002: [NTP:Downloads] Request offline pages even if model is not loaded. (Closed)
Patch Set: Created 3 years, 10 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 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 838 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 HasUrl("http://download.com/2")))); 849 HasUrl("http://download.com/2"))));
850 CreateLoadedProvider(/*show_assets=*/true, /*show_offline_pages=*/true, 850 CreateLoadedProvider(/*show_assets=*/true, /*show_offline_pages=*/true,
851 base::MakeUnique<base::DefaultClock>()); 851 base::MakeUnique<base::DefaultClock>());
852 } 852 }
853 853
854 TEST_F(DownloadSuggestionsProviderTest, 854 TEST_F(DownloadSuggestionsProviderTest,
855 ShouldFetchOfflinePageDownloadsOnStartup) { 855 ShouldFetchOfflinePageDownloadsOnStartup) {
856 IgnoreOnCategoryStatusChangedToAvailable(); 856 IgnoreOnCategoryStatusChangedToAvailable();
857 857
858 *(offline_pages_model()->mutable_items()) = CreateDummyOfflinePages({1, 2}); 858 *(offline_pages_model()->mutable_items()) = CreateDummyOfflinePages({1, 2});
859 offline_pages_model()->set_is_loaded(true);
Marc Treib 2017/02/10 09:08:11 I guess this just isn't required anymore; it would
vitaliii 2017/02/10 09:39:56 No, it wouldn't. Anyway is_loaded = true by defaul
Marc Treib 2017/02/10 10:05:02 Acknowledged.
860 EXPECT_CALL(*observer(), OnNewSuggestions(_, downloads_category(), 859 EXPECT_CALL(*observer(), OnNewSuggestions(_, downloads_category(),
861 UnorderedElementsAre( 860 UnorderedElementsAre(
862 HasUrl("http://dummy.com/1"), 861 HasUrl("http://dummy.com/1"),
863 HasUrl("http://dummy.com/2")))); 862 HasUrl("http://dummy.com/2"))));
864 CreateProvider(/*show_assets=*/false, /*show_offline_pages=*/true, 863 CreateProvider(/*show_assets=*/false, /*show_offline_pages=*/true,
865 base::MakeUnique<base::DefaultClock>()); 864 base::MakeUnique<base::DefaultClock>());
866 FireOfflinePageModelLoaded(); 865 FireOfflinePageModelLoaded();
867 } 866 }
868 867
869 TEST_F(DownloadSuggestionsProviderTest, 868 TEST_F(DownloadSuggestionsProviderTest,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
957 CreateLoadedProvider(/*show_assets=*/true, /*show_offline_pages=*/false, 956 CreateLoadedProvider(/*show_assets=*/true, /*show_offline_pages=*/false,
958 base::MakeUnique<base::DefaultClock>()); 957 base::MakeUnique<base::DefaultClock>());
959 } 958 }
960 959
961 TEST_F(DownloadSuggestionsProviderTest, 960 TEST_F(DownloadSuggestionsProviderTest,
962 ShouldLoadAndSubmitOfflinePagesEvenIfAssetDownloadsAreTurnedOff) { 961 ShouldLoadAndSubmitOfflinePagesEvenIfAssetDownloadsAreTurnedOff) {
963 IgnoreOnCategoryStatusChangedToAvailable(); 962 IgnoreOnCategoryStatusChangedToAvailable();
964 IgnoreOnSuggestionInvalidated(); 963 IgnoreOnSuggestionInvalidated();
965 964
966 *(offline_pages_model()->mutable_items()) = CreateDummyOfflinePages({1, 2}); 965 *(offline_pages_model()->mutable_items()) = CreateDummyOfflinePages({1, 2});
967 offline_pages_model()->set_is_loaded(true);
968 EXPECT_CALL(*observer(), OnNewSuggestions(_, downloads_category(), 966 EXPECT_CALL(*observer(), OnNewSuggestions(_, downloads_category(),
969 UnorderedElementsAre( 967 UnorderedElementsAre(
970 HasUrl("http://dummy.com/1"), 968 HasUrl("http://dummy.com/1"),
971 HasUrl("http://dummy.com/2")))); 969 HasUrl("http://dummy.com/2"))));
972 CreateProvider(/*show_assets=*/false, /*show_offline_pages=*/true, 970 CreateProvider(/*show_assets=*/false, /*show_offline_pages=*/true,
973 base::MakeUnique<base::DefaultClock>()); 971 base::MakeUnique<base::DefaultClock>());
974 } 972 }
975 973
976 TEST_F(DownloadSuggestionsProviderTest, ShouldStoreDismissedSuggestions) { 974 TEST_F(DownloadSuggestionsProviderTest, ShouldStoreDismissedSuggestions) {
977 IgnoreOnCategoryStatusChangedToAvailable(); 975 IgnoreOnCategoryStatusChangedToAvailable();
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1109 // it has been visited recently. 1107 // it has been visited recently.
1110 EXPECT_CALL( 1108 EXPECT_CALL(
1111 *observer(), 1109 *observer(),
1112 OnNewSuggestions(_, downloads_category(), 1110 OnNewSuggestions(_, downloads_category(),
1113 UnorderedElementsAre(HasUrl("http://dummy.com/0")))); 1111 UnorderedElementsAre(HasUrl("http://dummy.com/0"))));
1114 auto test_clock = base::MakeUnique<base::SimpleTestClock>(); 1112 auto test_clock = base::MakeUnique<base::SimpleTestClock>();
1115 test_clock->SetNow(now); 1113 test_clock->SetNow(now);
1116 CreateProvider(/*show_assets=*/false, /*show_offline_pages=*/true, 1114 CreateProvider(/*show_assets=*/false, /*show_offline_pages=*/true,
1117 std::move(test_clock)); 1115 std::move(test_clock));
1118 } 1116 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698