Commit cd7413fe authored by jkrcal's avatar jkrcal Committed by Commit bot

[LargeIconService] Add a unit-test for overriding request URL

This CL adds a test for a feature added in CL 2839653002, merged to M59.
The test has been implemented along with the original CL but is uploaded
separately to speed up the process (avoiding deps changes).

BUG=705572

Review-Url: https://codereview.chromium.org/2852383002
Cr-Commit-Position: refs/heads/master@{#469385}
parent 2961d5c4
......@@ -69,6 +69,7 @@ source_set("unit_tests") {
"//components/history/core/browser:browser",
"//components/history/core/test:test",
"//components/image_fetcher/core",
"//components/variations:test_support",
"//skia",
"//testing/gmock",
"//testing/gtest",
......
......@@ -6,6 +6,7 @@ include_rules = [
"+components/history/core/test",
"+components/image_fetcher/core",
"+components/keyed_service/core",
"+components/variations",
"+net/base",
"+skia",
"+third_party/skia",
......
......@@ -23,6 +23,7 @@
#include "components/favicon_base/favicon_types.h"
#include "components/image_fetcher/core/image_fetcher.h"
#include "components/image_fetcher/core/request_metadata.h"
#include "components/variations/variations_params_manager.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/skia/include/core/SkBitmap.h"
......@@ -164,6 +165,34 @@ TEST_F(LargeIconServiceTest, ShouldGetFromGoogleServer) {
"Favicons.LargeIconService.DownloadedSize", 64, /*expected_count=*/1);
}
TEST_F(LargeIconServiceTest, ShouldGetFromGoogleServerWithCustomUrl) {
variations::testing::VariationParamsManager variation_params(
"LargeIconServiceFetching",
{{"request_format", "https://t0.gstatic.com/faviconV2?size=%d&url=%s"}},
{"LargeIconServiceFetching"});
const GURL kExpectedServerUrl(
"https://t0.gstatic.com/faviconV2?size=42&url=http://www.example.com/");
EXPECT_CALL(mock_favicon_service_, UnableToDownloadFavicon(_)).Times(0);
base::MockCallback<base::Callback<void(bool success)>> callback;
EXPECT_CALL(*mock_image_fetcher_,
StartOrQueueNetworkRequest(_, kExpectedServerUrl, _))
.WillOnce(PostFetchReply(gfx::Image::CreateFrom1xBitmap(
CreateTestSkBitmap(64, 64, kTestColor))));
EXPECT_CALL(mock_favicon_service_,
SetLastResortFavicons(GURL(kDummyUrl), kExpectedServerUrl,
favicon_base::IconType::TOUCH_ICON, _, _))
.WillOnce(PostBoolReply(true));
large_icon_service_
.GetLargeIconOrFallbackStyleFromGoogleServerSkippingLocalCache(
GURL(kDummyUrl), /*min_source_size_in_pixel=*/42, callback.Get());
EXPECT_CALL(callback, Run(true));
base::RunLoop().RunUntilIdle();
}
TEST_F(LargeIconServiceTest, ShouldGetFromGoogleServerWithOriginalUrl) {
const GURL kExpectedServerUrl(
"https://t0.gstatic.com/faviconV2?client=chrome&drop_404_icon=true"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment