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

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

Issue 2513393002: [NTP] Cleanup: offline pages related tests. (Closed)
Patch Set: Created 4 years, 1 month 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/observer_list.h" 10 #include "base/observer_list.h"
(...skipping 748 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 CreateProvider(/*show_assets=*/true, /*show_offline_pages=*/true); 759 CreateProvider(/*show_assets=*/true, /*show_offline_pages=*/true);
760 760
761 provider()->DismissSuggestion( 761 provider()->DismissSuggestion(
762 GetDummySuggestionId(1, /*is_offline_page=*/true)); 762 GetDummySuggestionId(1, /*is_offline_page=*/true));
763 provider()->DismissSuggestion( 763 provider()->DismissSuggestion(
764 GetDummySuggestionId(2, /*is_offline_page=*/true)); 764 GetDummySuggestionId(2, /*is_offline_page=*/true));
765 provider()->DismissSuggestion( 765 provider()->DismissSuggestion(
766 GetDummySuggestionId(3, /*is_offline_page=*/true)); 766 GetDummySuggestionId(3, /*is_offline_page=*/true));
767 EXPECT_THAT(GetDismissedSuggestions(), SizeIs(3)); 767 EXPECT_THAT(GetDismissedSuggestions(), SizeIs(3));
768 768
769 // Prune on getting all offline pages. Note that the first suggestion is not 769 // Prune on getting all offline pages. Note that the first suggestion is
770 // removed from |offline_pages_model| storage, because otherwise 770 // added back to the |offline_pages_model| storage, because otherwise
771 // |GetDismissedSuggestions| cannot return it. 771 // |GetDismissedSuggestions| cannot return it.
772 EXPECT_CALL(*observer(), 772 EXPECT_CALL(*observer(),
773 OnNewSuggestions(_, downloads_category(), IsEmpty())); 773 OnNewSuggestions(_, downloads_category(), IsEmpty()));
774 774
775 // TODO(vitaliii): Add the first suggestion back, so that
776 // GetDismissedSuggestions can return it.
777 *(offline_pages_model()->mutable_items()) = 775 *(offline_pages_model()->mutable_items()) =
778 CreateDummyOfflinePages({2, 3}); 776 CreateDummyOfflinePages({2, 3});
779 FireOfflinePageModelChanged(); 777 FireOfflinePageModelChanged();
778
779 *(offline_pages_model()->mutable_items()) =
Marc Treib 2016/11/21 12:27:53 Should the "is added back" comment be here?
vitaliii 2016/11/21 14:56:46 Done.
780 CreateDummyOfflinePages({1, 2, 3});
780 EXPECT_THAT(GetDismissedSuggestions(), SizeIs(2)); 781 EXPECT_THAT(GetDismissedSuggestions(), SizeIs(2));
781 782
782 // Prune when offline page is deleted. 783 // Prune when offline page is deleted.
783 FireOfflinePageDeleted(offline_pages_model()->items()[1]); 784 FireOfflinePageDeleted(offline_pages_model()->items()[1]);
784 EXPECT_THAT(GetDismissedSuggestions(), SizeIs(1)); 785 EXPECT_THAT(GetDismissedSuggestions(), SizeIs(1));
785 } 786 }
786 787
787 TEST_F(DownloadSuggestionsProviderTest, ShouldPruneAssetDownloadsDismissedIDs) { 788 TEST_F(DownloadSuggestionsProviderTest, ShouldPruneAssetDownloadsDismissedIDs) {
788 IgnoreOnCategoryStatusChangedToAvailable(); 789 IgnoreOnCategoryStatusChangedToAvailable();
789 IgnoreOnSuggestionInvalidated(); 790 IgnoreOnSuggestionInvalidated();
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
916 IgnoreOnSuggestionInvalidated(); 917 IgnoreOnSuggestionInvalidated();
917 918
918 *(downloads_manager()->mutable_items()) = CreateDummyAssetDownloads({1, 2}); 919 *(downloads_manager()->mutable_items()) = CreateDummyAssetDownloads({1, 2});
919 EXPECT_CALL( 920 EXPECT_CALL(
920 *observer(), 921 *observer(),
921 OnNewSuggestions(_, downloads_category(), 922 OnNewSuggestions(_, downloads_category(),
922 UnorderedElementsAre(HasUrl("http://download.com/1"), 923 UnorderedElementsAre(HasUrl("http://download.com/1"),
923 HasUrl("http://download.com/2")))); 924 HasUrl("http://download.com/2"))));
924 CreateProvider(/*show_assets=*/true, /*show_offline_pages=*/false); 925 CreateProvider(/*show_assets=*/true, /*show_offline_pages=*/false);
925 } 926 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698