[NTP] Correctly reset background attribution links
If the attribution link is not https or is empty the action_url
in theme info should be reset. Otherwise its possible for an old
action url to be displayed for a new custom background image.
Bug: 868164
Change-Id: I00ca396b665c169410c33730f16c3054ec761c26
Reviewed-on: https://chromium-review.googlesource.com/1152516
Commit-Queue: Mathieu Perreault <[email protected]>
Reviewed-by: Mathieu Perreault <[email protected]>
Cr-Commit-Position: refs/heads/master@{#578956}
diff --git a/chrome/browser/search/instant_service_unittest.cc b/chrome/browser/search/instant_service_unittest.cc
index 89e8d24..87cb417 100644
--- a/chrome/browser/search/instant_service_unittest.cc
+++ b/chrome/browser/search/instant_service_unittest.cc
@@ -124,3 +124,38 @@
EXPECT_EQ(false, file_exists);
}
+
+TEST_F(InstantServiceTest, CustomBackgroundAttributionActionUrlReset) {
+ const GURL kUrl("https://www.foo.com");
+ const std::string kAttributionLine1 = "foo";
+ const std::string kAttributionLine2 = "bar";
+ const GURL kHttpsActionUrl("https://www.bar.com");
+ const GURL kHttpActionUrl("http://www.bar.com");
+
+ SetUserSelectedDefaultSearchProvider("{google:baseURL}");
+ instant_service_->SetCustomBackgroundURLWithAttributions(
+ kUrl, kAttributionLine1, kAttributionLine2, kHttpsActionUrl);
+
+ ThemeBackgroundInfo* theme_info = instant_service_->GetThemeInfoForTesting();
+ EXPECT_EQ(kHttpsActionUrl,
+ theme_info->custom_background_attribution_action_url);
+
+ instant_service_->SetCustomBackgroundURLWithAttributions(
+ kUrl, kAttributionLine1, kAttributionLine2, kHttpActionUrl);
+
+ theme_info = instant_service_->GetThemeInfoForTesting();
+ EXPECT_EQ(GURL(), theme_info->custom_background_attribution_action_url);
+
+ instant_service_->SetCustomBackgroundURLWithAttributions(
+ kUrl, kAttributionLine1, kAttributionLine2, kHttpsActionUrl);
+
+ theme_info = instant_service_->GetThemeInfoForTesting();
+ EXPECT_EQ(kHttpsActionUrl,
+ theme_info->custom_background_attribution_action_url);
+
+ instant_service_->SetCustomBackgroundURLWithAttributions(
+ kUrl, kAttributionLine1, kAttributionLine2, GURL());
+
+ theme_info = instant_service_->GetThemeInfoForTesting();
+ EXPECT_EQ(GURL(), theme_info->custom_background_attribution_action_url);
+}