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

Unified Diff: components/ntp_snippets/physical_web_pages/physical_web_page_suggestions_provider_unittest.cc

Issue 2669533002: [NTP::PhysicalWeb] In OnLost invalidate by |resolved_url|. (Closed)
Patch Set: treib@ comments. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/ntp_snippets/physical_web_pages/physical_web_page_suggestions_provider.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ntp_snippets/physical_web_pages/physical_web_page_suggestions_provider_unittest.cc
diff --git a/components/ntp_snippets/physical_web_pages/physical_web_page_suggestions_provider_unittest.cc b/components/ntp_snippets/physical_web_pages/physical_web_page_suggestions_provider_unittest.cc
index 5c91ddc36639d30d0de1a81394c9d11dc5288c5e..696cebb50a27f2781b85ddf3aa7cf508f25ea1db 100644
--- a/components/ntp_snippets/physical_web_pages/physical_web_page_suggestions_provider_unittest.cc
+++ b/components/ntp_snippets/physical_web_pages/physical_web_page_suggestions_provider_unittest.cc
@@ -298,17 +298,6 @@ TEST_F(PhysicalWebPageSuggestionsProviderTest, ShouldDismiss) {
}
TEST_F(PhysicalWebPageSuggestionsProviderTest,
- ShouldInvalidateSuggestionOnUrlLost) {
- IgnoreOnCategoryStatusChangedToAvailable();
- IgnoreOnNewSuggestions();
- physical_web_data_source()->SetMetadataList(CreateDummyPhysicalWebPages({1}));
- CreateProvider();
-
- EXPECT_CALL(*observer(), OnSuggestionInvalidated(_, GetDummySuggestionId(1)));
- FireUrlLost("https://resolved_url.com/1");
-}
-
-TEST_F(PhysicalWebPageSuggestionsProviderTest,
ShouldNotShowDismissedSuggestions) {
IgnoreOnCategoryStatusChangedToAvailable();
IgnoreOnSuggestionInvalidated();
@@ -405,4 +394,75 @@ TEST_F(PhysicalWebPageSuggestionsProviderTest,
ElementsAre(HasUrl("https://resolved_url.com/1")));
}
+TEST_F(PhysicalWebPageSuggestionsProviderTest,
+ ShouldInvalidateSuggestionWhenItsOnlyBeaconIsLost) {
+ IgnoreOnCategoryStatusChangedToAvailable();
+ physical_web_data_source()->SetMetadataList(
+ CreateDummyPhysicalWebPages({1, 2}));
+
+ EXPECT_CALL(*observer(), OnNewSuggestions(_, provided_category(), _));
+ CreateProvider();
+
+ EXPECT_CALL(*observer(), OnSuggestionInvalidated(_, GetDummySuggestionId(1)));
+ FireUrlLost("https://scanned_url.com/1");
+}
+
+TEST_F(PhysicalWebPageSuggestionsProviderTest,
+ ShouldNotInvalidateSuggestionWhenBeaconWithDifferentScannedURLRemains) {
+ IgnoreOnCategoryStatusChangedToAvailable();
+ // Make 2 beacons point to the same URL, while having different |scanned_url|.
+ std::unique_ptr<physical_web::MetadataList> pages =
+ CreateDummyPhysicalWebPages({1, 2});
+ (*pages)[1].resolved_url = (*pages)[0].resolved_url;
+ physical_web_data_source()->SetMetadataList(std::move(pages));
+
+ EXPECT_CALL(*observer(), OnNewSuggestions(_, provided_category(), _));
+ CreateProvider();
+
+ // The first beacons is lost, but the second one still points to the same
+ // |resolved_url|, so the suggestion must not be invalidated.
+ EXPECT_CALL(*observer(), OnSuggestionInvalidated(_, _)).Times(0);
+ FireUrlLost("https://scanned_url.com/1");
+}
+
+TEST_F(PhysicalWebPageSuggestionsProviderTest,
+ ShouldNotInvalidateSuggestionWhenBeaconWithSameScannedURLRemains) {
+ IgnoreOnCategoryStatusChangedToAvailable();
+ // Make 2 beacons point to the same URL, while having the same |scanned_url|.
+ std::unique_ptr<physical_web::MetadataList> pages =
+ CreateDummyPhysicalWebPages({1, 2});
+ (*pages)[1].scanned_url = (*pages)[0].scanned_url;
+ (*pages)[1].resolved_url = (*pages)[0].resolved_url;
+ physical_web_data_source()->SetMetadataList(std::move(pages));
+
+ EXPECT_CALL(*observer(), OnNewSuggestions(_, provided_category(), _));
+ CreateProvider();
+
+ // The first beacons is lost, but the second one still points to the same
+ // |resolved_url|, so the suggestion must not be invalidated.
+ EXPECT_CALL(*observer(), OnSuggestionInvalidated(_, _)).Times(0);
+ FireUrlLost("https://scanned_url.com/1");
+}
+
+TEST_F(PhysicalWebPageSuggestionsProviderTest,
+ ShouldInvalidateSuggestionWhenAllBeaconsLost) {
+ IgnoreOnCategoryStatusChangedToAvailable();
+ // Make 3 beacons point to the same URL. Two of them have the same
+ // |scanned_url|.
+ std::unique_ptr<physical_web::MetadataList> pages =
+ CreateDummyPhysicalWebPages({1, 2, 3});
+ (*pages)[1].scanned_url = (*pages)[0].scanned_url;
+ (*pages)[1].resolved_url = (*pages)[0].resolved_url;
+ (*pages)[2].resolved_url = (*pages)[0].resolved_url;
+ physical_web_data_source()->SetMetadataList(std::move(pages));
+
+ EXPECT_CALL(*observer(), OnNewSuggestions(_, provided_category(), _));
+ CreateProvider();
+
+ FireUrlLost("https://scanned_url.com/1");
+ FireUrlLost("https://scanned_url.com/1");
+ EXPECT_CALL(*observer(), OnSuggestionInvalidated(_, GetDummySuggestionId(1)));
+ FireUrlLost("https://scanned_url.com/3");
+}
+
} // namespace ntp_snippets
« no previous file with comments | « components/ntp_snippets/physical_web_pages/physical_web_page_suggestions_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698