| 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" |
| 24 #include "testing/gmock/include/gmock/gmock.h" | 25 #include "testing/gmock/include/gmock/gmock.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 26 | 27 |
| 27 namespace net { | 28 namespace net { |
| 28 | 29 |
| 29 using base::Time; | 30 using base::Time; |
| 30 using base::TimeDelta; | 31 using base::TimeDelta; |
| 31 using base::Thread; | 32 using base::Thread; |
| 32 | 33 |
| 33 namespace { | 34 namespace { |
| (...skipping 1811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1845 | 1846 |
| 1846 TEST_F(CookieMonsterTest, TestDomainIsHostOnly) { | 1847 TEST_F(CookieMonsterTest, TestDomainIsHostOnly) { |
| 1847 const DomainIsHostOnlyCase tests[] = { | 1848 const DomainIsHostOnlyCase tests[] = { |
| 1848 { "", true }, | 1849 { "", true }, |
| 1849 { "www.google.com", true }, | 1850 { "www.google.com", true }, |
| 1850 { ".google.com", false } | 1851 { ".google.com", false } |
| 1851 }; | 1852 }; |
| 1852 | 1853 |
| 1853 for (size_t i = 0; i < arraysize(tests); ++i) { | 1854 for (size_t i = 0; i < arraysize(tests); ++i) { |
| 1854 EXPECT_EQ(tests[i].is_host_only, | 1855 EXPECT_EQ(tests[i].is_host_only, |
| 1855 CookieMonster::DomainIsHostOnly(tests[i].str)); | 1856 cookie_utils::DomainIsHostOnly(tests[i].str)); |
| 1856 } | 1857 } |
| 1857 } | 1858 } |
| 1858 | 1859 |
| 1859 TEST_F(CookieMonsterTest, TestCookieDeletion) { | 1860 TEST_F(CookieMonsterTest, TestCookieDeletion) { |
| 1860 scoped_refptr<MockPersistentCookieStore> store( | 1861 scoped_refptr<MockPersistentCookieStore> store( |
| 1861 new MockPersistentCookieStore); | 1862 new MockPersistentCookieStore); |
| 1862 scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL)); | 1863 scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL)); |
| 1863 | 1864 |
| 1864 // Create a session cookie. | 1865 // Create a session cookie. |
| 1865 EXPECT_TRUE(SetCookie(cm, url_google_, kValidCookieLine)); | 1866 EXPECT_TRUE(SetCookie(cm, url_google_, kValidCookieLine)); |
| (...skipping 1666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3532 base::Closure task = base::Bind( | 3533 base::Closure task = base::Bind( |
| 3533 &net::MultiThreadedCookieMonsterTest::DeleteCanonicalCookieTask, | 3534 &net::MultiThreadedCookieMonsterTest::DeleteCanonicalCookieTask, |
| 3534 base::Unretained(this), | 3535 base::Unretained(this), |
| 3535 cm, *it, &callback); | 3536 cm, *it, &callback); |
| 3536 RunOnOtherThread(task); | 3537 RunOnOtherThread(task); |
| 3537 EXPECT_TRUE(callback.did_run()); | 3538 EXPECT_TRUE(callback.did_run()); |
| 3538 EXPECT_TRUE(callback.result()); | 3539 EXPECT_TRUE(callback.result()); |
| 3539 } | 3540 } |
| 3540 | 3541 |
| 3541 } // namespace net | 3542 } // namespace net |
| OLD | NEW |