1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "ui/webui/web_ui_util.h" 6 7 #include "testing/gtest/include/gtest/gtest.h" 8 #include "url/gurl.h" 9 10 TEST(WebUIUtilTest, ParsePathAndScale) { 11 std::vector<ui::ScaleFactor> supported_scale_factors; 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 18 std::string path; 19 ui::ScaleFactor factor; 20 21 GURL url("http://some/random/username@email/and/more"); 22 webui::ParsePathAndScale(url, &path, &factor); 23 EXPECT_EQ("random/username@email/and/more", path); 24 EXPECT_EQ(ui::SCALE_FACTOR_100P, factor); 25 26 GURL url2("http://some/random/username/and/more"); 27 webui::ParsePathAndScale(url2, &path, &factor); 28 EXPECT_EQ("random/username/and/more", path); 29 EXPECT_EQ(ui::SCALE_FACTOR_100P, factor); 30 31 GURL url3("http://some/random/username/and/more@2ax"); 32 webui::ParsePathAndScale(url3, &path, &factor); 33 EXPECT_EQ("random/username/and/more@2ax", path); 34 EXPECT_EQ(ui::SCALE_FACTOR_100P, factor); 35 36 GURL url4("http://some/random/username/and/more@x"); 37 webui::ParsePathAndScale(url4, &path, &factor); 38 EXPECT_EQ("random/username/and/more@x", path); 39 EXPECT_EQ(ui::SCALE_FACTOR_100P, factor); 40 41 GURL url5("http://some/random/username@email/and/more@2x"); 42 webui::ParsePathAndScale(url5, &path, &factor); 43 EXPECT_EQ("random/username@email/and/more", path); 44 EXPECT_EQ(ui::SCALE_FACTOR_200P, factor); 45 46 GURL url6("http://some/random/username/and/more@1.4x"); 47 webui::ParsePathAndScale(url6, &path, &factor); 48 EXPECT_EQ("random/username/and/more", path); 49 EXPECT_EQ(ui::SCALE_FACTOR_140P, factor); 50 51 GURL url7("http://some/random/username/and/more@1.3x"); 52 webui::ParsePathAndScale(url7, &path, &factor); 53 EXPECT_EQ("random/username/and/more", path); 54 EXPECT_EQ(ui::SCALE_FACTOR_140P, factor); 55 } 56