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
3 // found in the LICENSE file.
5 #include "chrome/common/content_settings_helper.h"
7 #include "base/strings/utf_string_conversions.h"
8 #include "testing/gtest/include/gtest/gtest.h"
11 TEST(ContentSettingsHelperTest
, OriginToString16
) {
13 const GURL
kUrl0("http://www.foo.com/bar");
14 const GURL
kUrl1("http://foo.com/bar");
16 const GURL
kUrl2("http://www.foo.com:81/bar");
17 const GURL
kUrl3("http://foo.com:81/bar");
20 const GURL
kUrl4("https://www.foo.com/bar");
21 const GURL
kUrl5("https://foo.com/bar");
23 const GURL
kUrl6("https://www.foo.com:81/bar");
24 const GURL
kUrl7("https://foo.com:81/bar");
26 // Now check the first group of urls with just "http":
27 EXPECT_EQ(base::ASCIIToUTF16("www.foo.com"),
28 content_settings_helper::OriginToString16(kUrl0
));
29 EXPECT_EQ(base::ASCIIToUTF16("foo.com"),
30 content_settings_helper::OriginToString16(kUrl1
));
32 EXPECT_EQ(base::ASCIIToUTF16("www.foo.com:81"),
33 content_settings_helper::OriginToString16(kUrl2
));
34 EXPECT_EQ(base::ASCIIToUTF16("foo.com:81"),
35 content_settings_helper::OriginToString16(kUrl3
));
37 // Now check the second group of urls with "https":
38 EXPECT_EQ(base::ASCIIToUTF16("https://www.foo.com"),
39 content_settings_helper::OriginToString16(kUrl4
));
40 EXPECT_EQ(base::ASCIIToUTF16("https://foo.com"),
41 content_settings_helper::OriginToString16(kUrl5
));
43 EXPECT_EQ(base::ASCIIToUTF16("https://www.foo.com:81"),
44 content_settings_helper::OriginToString16(kUrl6
));
45 EXPECT_EQ(base::ASCIIToUTF16("https://foo.com:81"),
46 content_settings_helper::OriginToString16(kUrl7
));