content_settings_helper_unittest.cc revision 06741cbc25cd4227a9fba40dfd0273bfcc1a587a
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.
4
5#include "chrome/common/content_settings_helper.h"
6
7#include "googleurl/src/gurl.h"
8#include "testing/gtest/include/gtest/gtest.h"
9
10TEST(ContentSettingsHelperTest, OriginToWString) {
11  // Urls with "http":
12  const GURL kUrl0("http://www.foo.com/bar");
13  const GURL kUrl1("http://foo.com/bar");
14
15  const GURL kUrl2("http://www.foo.com:81/bar");
16  const GURL kUrl3("http://foo.com:81/bar");
17
18  // Urls with "https":
19  const GURL kUrl4("https://www.foo.com/bar");
20  const GURL kUrl5("https://foo.com/bar");
21
22  const GURL kUrl6("https://www.foo.com:81/bar");
23  const GURL kUrl7("https://foo.com:81/bar");
24
25  // Now check the first group of urls with just "http":
26  EXPECT_EQ(L"www.foo.com", content_settings_helper::OriginToWString(kUrl0));
27  EXPECT_EQ(L"foo.com", content_settings_helper::OriginToWString(kUrl1));
28
29  EXPECT_EQ(L"www.foo.com:81", content_settings_helper::OriginToWString(kUrl2));
30  EXPECT_EQ(L"foo.com:81", content_settings_helper::OriginToWString(kUrl3));
31
32  // Now check the second group of urls with "https":
33  EXPECT_EQ(L"https://www.foo.com",
34            content_settings_helper::OriginToWString(kUrl4));
35  EXPECT_EQ(L"https://foo.com",
36            content_settings_helper::OriginToWString(kUrl5));
37
38  EXPECT_EQ(L"https://www.foo.com:81",
39            content_settings_helper::OriginToWString(kUrl6));
40  EXPECT_EQ(L"https://foo.com:81",
41            content_settings_helper::OriginToWString(kUrl7));
42}
43