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" |
(...skipping 1689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1700 EXPECT_TRUE(SetCookieWithOptions(cm_1.get(), url_google_foo_, | 1700 EXPECT_TRUE(SetCookieWithOptions(cm_1.get(), url_google_foo_, |
1701 "A1=B; path=/foo;", | 1701 "A1=B; path=/foo;", |
1702 options)); | 1702 options)); |
1703 EXPECT_TRUE(SetCookieWithOptions(cm_1.get(), url_google_bar_, | 1703 EXPECT_TRUE(SetCookieWithOptions(cm_1.get(), url_google_bar_, |
1704 "A2=D; path=/bar;", | 1704 "A2=D; path=/bar;", |
1705 options)); | 1705 options)); |
1706 EXPECT_TRUE(SetCookieWithOptions(cm_1.get(), url_google_, | 1706 EXPECT_TRUE(SetCookieWithOptions(cm_1.get(), url_google_, |
1707 "A3=F;", | 1707 "A3=F;", |
1708 options)); | 1708 options)); |
1709 | 1709 |
1710 CookieList cookies_1 = GetAllCookies(cm_1); | |
1711 scoped_refptr<CookieMonster> cm_2(new CookieMonster(NULL, NULL)); | 1710 scoped_refptr<CookieMonster> cm_2(new CookieMonster(NULL, NULL)); |
1712 ASSERT_TRUE(cm_2->InitializeFrom(cookies_1)); | 1711 ASSERT_TRUE(cm_2->InitializeFrom(cm_1.get())); |
1713 CookieList cookies_2 = GetAllCookies(cm_2); | 1712 CookieList cookies = cm_2->GetAllCookies(); |
1714 | 1713 |
1715 size_t expected_size = 3; | 1714 size_t expected_size = 3; |
1716 EXPECT_EQ(expected_size, cookies_2.size()); | 1715 EXPECT_EQ(expected_size, cookies.size()); |
1717 | 1716 |
1718 CookieList::iterator it = cookies_2.begin(); | 1717 CookieList::iterator it = cookies.begin(); |
1719 | 1718 |
1720 ASSERT_TRUE(it != cookies_2.end()); | 1719 ASSERT_TRUE(it != cookies.end()); |
1721 EXPECT_EQ("A1", it->Name()); | 1720 EXPECT_EQ("A1", it->Name()); |
1722 EXPECT_EQ("/foo", it->Path()); | 1721 EXPECT_EQ("/foo", it->Path()); |
1723 | 1722 |
1724 ASSERT_TRUE(++it != cookies_2.end()); | 1723 ASSERT_TRUE(++it != cookies.end()); |
1725 EXPECT_EQ("A2", it->Name()); | 1724 EXPECT_EQ("A2", it->Name()); |
1726 EXPECT_EQ("/bar", it->Path()); | 1725 EXPECT_EQ("/bar", it->Path()); |
1727 | 1726 |
1728 ASSERT_TRUE(++it != cookies_2.end()); | 1727 ASSERT_TRUE(++it != cookies.end()); |
1729 EXPECT_EQ("A3", it->Name()); | 1728 EXPECT_EQ("A3", it->Name()); |
1730 EXPECT_EQ("/", it->Path()); | 1729 EXPECT_EQ("/", it->Path()); |
1731 } | 1730 } |
1732 | 1731 |
1733 | 1732 |
1734 // Test that overwriting persistent cookies deletes the old one from the | 1733 // Test that overwriting persistent cookies deletes the old one from the |
1735 // backing store. | 1734 // backing store. |
1736 TEST_F(CookieMonsterTest, OverwritePersistentCookie) { | 1735 TEST_F(CookieMonsterTest, OverwritePersistentCookie) { |
1737 GURL url_google("http://www.google.com/"); | 1736 GURL url_google("http://www.google.com/"); |
1738 GURL url_chromium("http://chromium.org"); | 1737 GURL url_chromium("http://chromium.org"); |
(...skipping 1278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3017 base::Closure task = base::Bind( | 3016 base::Closure task = base::Bind( |
3018 &net::MultiThreadedCookieMonsterTest::DeleteCanonicalCookieTask, | 3017 &net::MultiThreadedCookieMonsterTest::DeleteCanonicalCookieTask, |
3019 base::Unretained(this), | 3018 base::Unretained(this), |
3020 cm, *it, &callback); | 3019 cm, *it, &callback); |
3021 RunOnOtherThread(task); | 3020 RunOnOtherThread(task); |
3022 EXPECT_TRUE(callback.did_run()); | 3021 EXPECT_TRUE(callback.did_run()); |
3023 EXPECT_TRUE(callback.result()); | 3022 EXPECT_TRUE(callback.result()); |
3024 } | 3023 } |
3025 | 3024 |
3026 } // namespace net | 3025 } // namespace net |
OLD | NEW |