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 "ui/base/webui/web_ui_util.h" | 5 #include "ui/base/webui/web_ui_util.h" |
6 | 6 |
7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "url/gurl.h" | 8 #include "url/gurl.h" |
9 | 9 |
10 TEST(WebUIUtilTest, ParsePathAndScale) { | 10 TEST(WebUIUtilTest, ParsePathAndScale) { |
11 std::vector<ui::ScaleFactor> supported_scale_factors; | 11 std::string path; |
12 supported_scale_factors.push_back(ui::SCALE_FACTOR_100P); | |
13 supported_scale_factors.push_back(ui::SCALE_FACTOR_140P); | |
14 supported_scale_factors.push_back(ui::SCALE_FACTOR_200P); | |
15 ui::test::ScopedSetSupportedScaleFactors scoped_supported( | |
16 supported_scale_factors); | |
17 | 12 |
18 std::string path; | 13 float factor = 0; |
19 ui::ScaleFactor factor; | |
20 | |
21 GURL url("http://some/random/username@email/and/more"); | 14 GURL url("http://some/random/username@email/and/more"); |
22 webui::ParsePathAndScale(url, &path, &factor); | 15 webui::ParsePathAndScale(url, &path, &factor); |
23 EXPECT_EQ("random/username@email/and/more", path); | 16 EXPECT_EQ("random/username@email/and/more", path); |
24 EXPECT_EQ(ui::SCALE_FACTOR_100P, factor); | 17 EXPECT_EQ(1.0f, factor); |
25 | 18 |
| 19 factor = 0; |
26 GURL url2("http://some/random/username/and/more"); | 20 GURL url2("http://some/random/username/and/more"); |
27 webui::ParsePathAndScale(url2, &path, &factor); | 21 webui::ParsePathAndScale(url2, &path, &factor); |
28 EXPECT_EQ("random/username/and/more", path); | 22 EXPECT_EQ("random/username/and/more", path); |
29 EXPECT_EQ(ui::SCALE_FACTOR_100P, factor); | 23 EXPECT_EQ(1.0f, factor); |
30 | 24 |
| 25 factor = 0; |
31 GURL url3("http://some/random/username/and/more@2ax"); | 26 GURL url3("http://some/random/username/and/more@2ax"); |
32 webui::ParsePathAndScale(url3, &path, &factor); | 27 webui::ParsePathAndScale(url3, &path, &factor); |
33 EXPECT_EQ("random/username/and/more@2ax", path); | 28 EXPECT_EQ("random/username/and/more@2ax", path); |
34 EXPECT_EQ(ui::SCALE_FACTOR_100P, factor); | 29 EXPECT_EQ(1.0f, factor); |
35 | 30 |
| 31 factor = 0; |
36 GURL url4("http://some/random/username/and/more@x"); | 32 GURL url4("http://some/random/username/and/more@x"); |
37 webui::ParsePathAndScale(url4, &path, &factor); | 33 webui::ParsePathAndScale(url4, &path, &factor); |
38 EXPECT_EQ("random/username/and/more@x", path); | 34 EXPECT_EQ("random/username/and/more@x", path); |
39 EXPECT_EQ(ui::SCALE_FACTOR_100P, factor); | 35 EXPECT_EQ(1.0f, factor); |
40 | 36 |
| 37 factor = 0; |
41 GURL url5("http://some/random/username@email/and/more@2x"); | 38 GURL url5("http://some/random/username@email/and/more@2x"); |
42 webui::ParsePathAndScale(url5, &path, &factor); | 39 webui::ParsePathAndScale(url5, &path, &factor); |
43 EXPECT_EQ("random/username@email/and/more", path); | 40 EXPECT_EQ("random/username@email/and/more", path); |
44 EXPECT_EQ(ui::SCALE_FACTOR_200P, factor); | 41 EXPECT_EQ(2.0f, factor); |
45 | 42 |
| 43 factor = 0; |
46 GURL url6("http://some/random/username/and/more@1.4x"); | 44 GURL url6("http://some/random/username/and/more@1.4x"); |
47 webui::ParsePathAndScale(url6, &path, &factor); | 45 webui::ParsePathAndScale(url6, &path, &factor); |
48 EXPECT_EQ("random/username/and/more", path); | 46 EXPECT_EQ("random/username/and/more", path); |
49 EXPECT_EQ(ui::SCALE_FACTOR_140P, factor); | 47 EXPECT_EQ(1.4f, factor); |
50 | 48 |
| 49 factor = 0; |
51 GURL url7("http://some/random/username/and/more@1.3x"); | 50 GURL url7("http://some/random/username/and/more@1.3x"); |
52 webui::ParsePathAndScale(url7, &path, &factor); | 51 webui::ParsePathAndScale(url7, &path, &factor); |
53 EXPECT_EQ("random/username/and/more", path); | 52 EXPECT_EQ("random/username/and/more", path); |
54 EXPECT_EQ(ui::SCALE_FACTOR_140P, factor); | 53 EXPECT_EQ(1.3f, factor); |
55 } | 54 } |
OLD | NEW |