OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "components/favicon_base/favicon_url_parser.h" | 5 #include "components/favicon_base/favicon_url_parser.h" |
6 | 6 |
| 7 #include <memory> |
| 8 |
7 #include "base/macros.h" | 9 #include "base/macros.h" |
8 #include "base/memory/scoped_ptr.h" | |
9 #include "components/favicon_base/favicon_types.h" | 10 #include "components/favicon_base/favicon_types.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "ui/base/layout.h" | 12 #include "ui/base/layout.h" |
12 | 13 |
13 class FaviconUrlParserTest : public testing::Test { | 14 class FaviconUrlParserTest : public testing::Test { |
14 public: | 15 public: |
15 FaviconUrlParserTest() { | 16 FaviconUrlParserTest() { |
16 // Set the supported scale factors because the supported scale factors | 17 // Set the supported scale factors because the supported scale factors |
17 // affect the result of ParsePathAndScale(). | 18 // affect the result of ParsePathAndScale(). |
18 std::vector<ui::ScaleFactor> supported_scale_factors; | 19 std::vector<ui::ScaleFactor> supported_scale_factors; |
19 supported_scale_factors.push_back(ui::SCALE_FACTOR_100P); | 20 supported_scale_factors.push_back(ui::SCALE_FACTOR_100P); |
20 supported_scale_factors.push_back(ui::SCALE_FACTOR_140P); | 21 supported_scale_factors.push_back(ui::SCALE_FACTOR_140P); |
21 scoped_set_supported_scale_factors_.reset( | 22 scoped_set_supported_scale_factors_.reset( |
22 new ui::test::ScopedSetSupportedScaleFactors(supported_scale_factors)); | 23 new ui::test::ScopedSetSupportedScaleFactors(supported_scale_factors)); |
23 } | 24 } |
24 | 25 |
25 ~FaviconUrlParserTest() override {} | 26 ~FaviconUrlParserTest() override {} |
26 | 27 |
27 private: | 28 private: |
28 typedef scoped_ptr<ui::test::ScopedSetSupportedScaleFactors> | 29 typedef std::unique_ptr<ui::test::ScopedSetSupportedScaleFactors> |
29 ScopedSetSupportedScaleFactors; | 30 ScopedSetSupportedScaleFactors; |
30 ScopedSetSupportedScaleFactors scoped_set_supported_scale_factors_; | 31 ScopedSetSupportedScaleFactors scoped_set_supported_scale_factors_; |
31 | 32 |
32 DISALLOW_COPY_AND_ASSIGN(FaviconUrlParserTest); | 33 DISALLOW_COPY_AND_ASSIGN(FaviconUrlParserTest); |
33 }; | 34 }; |
34 | 35 |
35 // Test parsing path with no extra parameters. | 36 // Test parsing path with no extra parameters. |
36 TEST_F(FaviconUrlParserTest, ParsingNoExtraParams) { | 37 TEST_F(FaviconUrlParserTest, ParsingNoExtraParams) { |
37 const std::string url("https://www.google.ca/imghp?hl=en&tab=wi"); | 38 const std::string url("https://www.google.ca/imghp?hl=en&tab=wi"); |
38 int icon_types = favicon_base::TOUCH_PRECOMPOSED_ICON; | 39 int icon_types = favicon_base::TOUCH_PRECOMPOSED_ICON; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 EXPECT_EQ(32, parsed.size_in_dip); | 158 EXPECT_EQ(32, parsed.size_in_dip); |
158 EXPECT_EQ(1.4f, parsed.device_scale_factor); | 159 EXPECT_EQ(1.4f, parsed.device_scale_factor); |
159 | 160 |
160 const std::string path14 = | 161 const std::string path14 = |
161 "largest/iconurl/http://www.google.com/favicon.ico"; | 162 "largest/iconurl/http://www.google.com/favicon.ico"; |
162 EXPECT_TRUE(chrome::ParseFaviconPath(path14, icon_types, &parsed)); | 163 EXPECT_TRUE(chrome::ParseFaviconPath(path14, icon_types, &parsed)); |
163 EXPECT_TRUE(parsed.is_icon_url); | 164 EXPECT_TRUE(parsed.is_icon_url); |
164 EXPECT_EQ("http://www.google.com/favicon.ico", parsed.url); | 165 EXPECT_EQ("http://www.google.com/favicon.ico", parsed.url); |
165 EXPECT_EQ(0, parsed.size_in_dip); | 166 EXPECT_EQ(0, parsed.size_in_dip); |
166 } | 167 } |
OLD | NEW |