Home | History | Annotate | Download | only in common
      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 "base/utf_string_conversions.h"
      8 #include "googleurl/src/gurl.h"
      9 #include "testing/gtest/include/gtest/gtest.h"
     10 
     11 TEST(ContentSettingsHelperTest, OriginToString16) {
     12   // Urls with "http":
     13   const GURL kUrl0("http://www.foo.com/bar");
     14   const GURL kUrl1("http://foo.com/bar");
     15 
     16   const GURL kUrl2("http://www.foo.com:81/bar");
     17   const GURL kUrl3("http://foo.com:81/bar");
     18 
     19   // Urls with "https":
     20   const GURL kUrl4("https://www.foo.com/bar");
     21   const GURL kUrl5("https://foo.com/bar");
     22 
     23   const GURL kUrl6("https://www.foo.com:81/bar");
     24   const GURL kUrl7("https://foo.com:81/bar");
     25 
     26   // Now check the first group of urls with just "http":
     27   EXPECT_EQ(ASCIIToUTF16("www.foo.com"),
     28             content_settings_helper::OriginToString16(kUrl0));
     29   EXPECT_EQ(ASCIIToUTF16("foo.com"),
     30             content_settings_helper::OriginToString16(kUrl1));
     31 
     32   EXPECT_EQ(ASCIIToUTF16("www.foo.com:81"),
     33             content_settings_helper::OriginToString16(kUrl2));
     34   EXPECT_EQ(ASCIIToUTF16("foo.com:81"),
     35             content_settings_helper::OriginToString16(kUrl3));
     36 
     37   // Now check the second group of urls with "https":
     38   EXPECT_EQ(ASCIIToUTF16("https://www.foo.com"),
     39             content_settings_helper::OriginToString16(kUrl4));
     40   EXPECT_EQ(ASCIIToUTF16("https://foo.com"),
     41             content_settings_helper::OriginToString16(kUrl5));
     42 
     43   EXPECT_EQ(ASCIIToUTF16("https://www.foo.com:81"),
     44             content_settings_helper::OriginToString16(kUrl6));
     45   EXPECT_EQ(ASCIIToUTF16("https://foo.com:81"),
     46             content_settings_helper::OriginToString16(kUrl7));
     47 }
     48