canonical_cookie_unittest.cc revision 5821806d5e7f356e8fa4b058a389a808ea183019
1// Copyright (c) 2012 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 "net/cookies/canonical_cookie.h"
6
7#include "googleurl/src/gurl.h"
8#include "testing/gtest/include/gtest/gtest.h"
9
10namespace net {
11
12TEST(CanonicalCookieTest, GetCookieSourceFromURL) {
13  EXPECT_EQ("http://example.com/",
14            CanonicalCookie::GetCookieSourceFromURL(
15                GURL("http://example.com")));
16  EXPECT_EQ("http://example.com/",
17            CanonicalCookie::GetCookieSourceFromURL(
18                GURL("http://example.com/")));
19  EXPECT_EQ("http://example.com/",
20            CanonicalCookie::GetCookieSourceFromURL(
21                GURL("http://example.com/test")));
22  EXPECT_EQ("file:///tmp/test.html",
23            CanonicalCookie::GetCookieSourceFromURL(
24                GURL("file:///tmp/test.html")));
25  EXPECT_EQ("http://example.com/",
26            CanonicalCookie::GetCookieSourceFromURL(
27                GURL("http://example.com:1234/")));
28  EXPECT_EQ("http://example.com/",
29            CanonicalCookie::GetCookieSourceFromURL(
30                GURL("https://example.com/")));
31  EXPECT_EQ("http://example.com/",
32            CanonicalCookie::GetCookieSourceFromURL(
33                GURL("http://user:pwd@example.com/")));
34  EXPECT_EQ("http://example.com/",
35            CanonicalCookie::GetCookieSourceFromURL(
36                GURL("http://example.com/test?foo")));
37  EXPECT_EQ("http://example.com/",
38            CanonicalCookie::GetCookieSourceFromURL(
39                GURL("http://example.com/test#foo")));
40}
41
42}  // namespace net
43