OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <time.h> | 5 #include <time.h> |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
15 #include "base/metrics/histogram.h" | 15 #include "base/metrics/histogram.h" |
16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
17 #include "base/stringprintf.h" | 17 #include "base/stringprintf.h" |
18 #include "base/threading/platform_thread.h" | 18 #include "base/threading/platform_thread.h" |
19 #include "base/threading/thread.h" | 19 #include "base/threading/thread.h" |
20 #include "base/time.h" | 20 #include "base/time.h" |
21 #include "googleurl/src/gurl.h" | 21 #include "googleurl/src/gurl.h" |
22 #include "net/base/cookie_monster.h" | 22 #include "net/base/cookie_monster.h" |
23 #include "net/base/cookie_monster_store_test.h" // For CookieStore mock | 23 #include "net/base/cookie_monster_store_test.h" // For CookieStore mock |
24 #include "net/base/cookie_utils.h" | |
25 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
26 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
27 | 26 |
28 namespace net { | 27 namespace net { |
29 | 28 |
30 using base::Time; | 29 using base::Time; |
31 using base::TimeDelta; | 30 using base::TimeDelta; |
32 using base::Thread; | 31 using base::Thread; |
33 | 32 |
34 namespace { | 33 namespace { |
(...skipping 1811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1846 | 1845 |
1847 TEST_F(CookieMonsterTest, TestDomainIsHostOnly) { | 1846 TEST_F(CookieMonsterTest, TestDomainIsHostOnly) { |
1848 const DomainIsHostOnlyCase tests[] = { | 1847 const DomainIsHostOnlyCase tests[] = { |
1849 { "", true }, | 1848 { "", true }, |
1850 { "www.google.com", true }, | 1849 { "www.google.com", true }, |
1851 { ".google.com", false } | 1850 { ".google.com", false } |
1852 }; | 1851 }; |
1853 | 1852 |
1854 for (size_t i = 0; i < arraysize(tests); ++i) { | 1853 for (size_t i = 0; i < arraysize(tests); ++i) { |
1855 EXPECT_EQ(tests[i].is_host_only, | 1854 EXPECT_EQ(tests[i].is_host_only, |
1856 cookie_utils::DomainIsHostOnly(tests[i].str)); | 1855 CookieMonster::DomainIsHostOnly(tests[i].str)); |
1857 } | 1856 } |
1858 } | 1857 } |
1859 | 1858 |
1860 TEST_F(CookieMonsterTest, TestCookieDeletion) { | 1859 TEST_F(CookieMonsterTest, TestCookieDeletion) { |
1861 scoped_refptr<MockPersistentCookieStore> store( | 1860 scoped_refptr<MockPersistentCookieStore> store( |
1862 new MockPersistentCookieStore); | 1861 new MockPersistentCookieStore); |
1863 scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL)); | 1862 scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL)); |
1864 | 1863 |
1865 // Create a session cookie. | 1864 // Create a session cookie. |
1866 EXPECT_TRUE(SetCookie(cm, url_google_, kValidCookieLine)); | 1865 EXPECT_TRUE(SetCookie(cm, url_google_, kValidCookieLine)); |
(...skipping 1697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3564 | 3563 |
3565 // Get cookies after the cookie has expired. | 3564 // Get cookies after the cookie has expired. |
3566 cookies.clear(); | 3565 cookies.clear(); |
3567 cm->FindCookiesForKey(cm->GetKey(url_google_.host()), url_google_, | 3566 cm->FindCookiesForKey(cm->GetKey(url_google_.host()), url_google_, |
3568 CookieOptions(), current + TimeDelta::FromSeconds(20), | 3567 CookieOptions(), current + TimeDelta::FromSeconds(20), |
3569 false, &cookies); | 3568 false, &cookies); |
3570 EXPECT_EQ(0U, cookies.size()); | 3569 EXPECT_EQ(0U, cookies.size()); |
3571 } | 3570 } |
3572 | 3571 |
3573 } // namespace net | 3572 } // namespace net |
OLD | NEW |