OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/common/content_settings_helper.h" | 5 #include "chrome/common/content_settings_helper.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 #include "url/gurl.h" | 9 #include "url/gurl.h" |
10 | 10 |
11 TEST(ContentSettingsHelperTest, OriginToString16) { | 11 TEST(ContentSettingsHelperTest, OriginToString16) { |
12 // Urls with "http": | 12 // Urls with "http": |
13 const GURL kUrl0("http://www.foo.com/bar"); | 13 const GURL kUrl0("http://www.foo.com/bar"); |
14 const GURL kUrl1("http://foo.com/bar"); | 14 const GURL kUrl1("http://foo.com/bar"); |
15 | 15 |
16 const GURL kUrl2("http://www.foo.com:81/bar"); | 16 const GURL kUrl2("http://www.foo.com:81/bar"); |
17 const GURL kUrl3("http://foo.com:81/bar"); | 17 const GURL kUrl3("http://foo.com:81/bar"); |
18 | 18 |
19 // Urls with "https": | 19 // Urls with "https": |
20 const GURL kUrl4("https://www.foo.com/bar"); | 20 const GURL kUrl4("https://www.foo.com/bar"); |
21 const GURL kUrl5("https://foo.com/bar"); | 21 const GURL kUrl5("https://foo.com/bar"); |
22 | 22 |
23 const GURL kUrl6("https://www.foo.com:81/bar"); | 23 const GURL kUrl6("https://www.foo.com:81/bar"); |
24 const GURL kUrl7("https://foo.com:81/bar"); | 24 const GURL kUrl7("https://foo.com:81/bar"); |
25 | 25 |
26 // Now check the first group of urls with just "http": | 26 // Now check the first group of urls with just "http": |
27 EXPECT_EQ(ASCIIToUTF16("www.foo.com"), | 27 EXPECT_EQ(base::ASCIIToUTF16("www.foo.com"), |
28 content_settings_helper::OriginToString16(kUrl0)); | 28 content_settings_helper::OriginToString16(kUrl0)); |
29 EXPECT_EQ(ASCIIToUTF16("foo.com"), | 29 EXPECT_EQ(base::ASCIIToUTF16("foo.com"), |
30 content_settings_helper::OriginToString16(kUrl1)); | 30 content_settings_helper::OriginToString16(kUrl1)); |
31 | 31 |
32 EXPECT_EQ(ASCIIToUTF16("www.foo.com:81"), | 32 EXPECT_EQ(base::ASCIIToUTF16("www.foo.com:81"), |
33 content_settings_helper::OriginToString16(kUrl2)); | 33 content_settings_helper::OriginToString16(kUrl2)); |
34 EXPECT_EQ(ASCIIToUTF16("foo.com:81"), | 34 EXPECT_EQ(base::ASCIIToUTF16("foo.com:81"), |
35 content_settings_helper::OriginToString16(kUrl3)); | 35 content_settings_helper::OriginToString16(kUrl3)); |
36 | 36 |
37 // Now check the second group of urls with "https": | 37 // Now check the second group of urls with "https": |
38 EXPECT_EQ(ASCIIToUTF16("https://www.foo.com"), | 38 EXPECT_EQ(base::ASCIIToUTF16("https://www.foo.com"), |
39 content_settings_helper::OriginToString16(kUrl4)); | 39 content_settings_helper::OriginToString16(kUrl4)); |
40 EXPECT_EQ(ASCIIToUTF16("https://foo.com"), | 40 EXPECT_EQ(base::ASCIIToUTF16("https://foo.com"), |
41 content_settings_helper::OriginToString16(kUrl5)); | 41 content_settings_helper::OriginToString16(kUrl5)); |
42 | 42 |
43 EXPECT_EQ(ASCIIToUTF16("https://www.foo.com:81"), | 43 EXPECT_EQ(base::ASCIIToUTF16("https://www.foo.com:81"), |
44 content_settings_helper::OriginToString16(kUrl6)); | 44 content_settings_helper::OriginToString16(kUrl6)); |
45 EXPECT_EQ(ASCIIToUTF16("https://foo.com:81"), | 45 EXPECT_EQ(base::ASCIIToUTF16("https://foo.com:81"), |
46 content_settings_helper::OriginToString16(kUrl7)); | 46 content_settings_helper::OriginToString16(kUrl7)); |
47 } | 47 } |
OLD | NEW |