Upstream version 11.40.277.0
[platform/framework/web/crosswalk.git] / src / ui / base / webui / web_ui_util_unittest.cc
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
3 // found in the LICENSE file.
4
5 #include "ui/base/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::string path;
12
13   float factor = 0;
14   GURL url("http://some/random/username@email/and/more");
15   webui::ParsePathAndScale(url, &path, &factor);
16   EXPECT_EQ("random/username@email/and/more", path);
17   EXPECT_EQ(1.0f, factor);
18
19   factor = 0;
20   GURL url2("http://some/random/username/and/more");
21   webui::ParsePathAndScale(url2, &path, &factor);
22   EXPECT_EQ("random/username/and/more", path);
23   EXPECT_EQ(1.0f, factor);
24
25   factor = 0;
26   GURL url3("http://some/random/username/and/more@2ax");
27   webui::ParsePathAndScale(url3, &path, &factor);
28   EXPECT_EQ("random/username/and/more@2ax", path);
29   EXPECT_EQ(1.0f, factor);
30
31   factor = 0;
32   GURL url4("http://some/random/username/and/more@x");
33   webui::ParsePathAndScale(url4, &path, &factor);
34   EXPECT_EQ("random/username/and/more@x", path);
35   EXPECT_EQ(1.0f, factor);
36
37   factor = 0;
38   GURL url5("http://some/random/username@email/and/more@2x");
39   webui::ParsePathAndScale(url5, &path, &factor);
40   EXPECT_EQ("random/username@email/and/more", path);
41   EXPECT_EQ(2.0f, factor);
42
43   factor = 0;
44   GURL url6("http://some/random/username/and/more@1.4x");
45   webui::ParsePathAndScale(url6, &path, &factor);
46   EXPECT_EQ("random/username/and/more", path);
47   EXPECT_EQ(1.4f, factor);
48
49   factor = 0;
50   GURL url7("http://some/random/username/and/more@1.3x");
51   webui::ParsePathAndScale(url7, &path, &factor);
52   EXPECT_EQ("random/username/and/more", path);
53   EXPECT_EQ(1.3f, factor);
54 }