Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: net/cookies/cookie_monster_unittest.cc

Issue 11568033: Small fixes to allow unit tests to compile with gcc 4.7.x (tested with gcc 4.7.2) (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/cookies/cookie_monster_perftest.cc ('k') | net/spdy/spdy_http_stream_spdy3_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 "net/cookies/cookie_store_unittest.h" 5 #include "net/cookies/cookie_store_unittest.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1718 CreateMonsterForGC(CookieMonster::kMaxCookies * 2)); 1718 CreateMonsterForGC(CookieMonster::kMaxCookies * 2));
1719 EXPECT_EQ(CookieMonster::kMaxCookies * 2, GetAllCookies(cm).size()); 1719 EXPECT_EQ(CookieMonster::kMaxCookies * 2, GetAllCookies(cm).size());
1720 SetCookie(cm, GURL("http://newdomain.com"), "b=2"); 1720 SetCookie(cm, GURL("http://newdomain.com"), "b=2");
1721 EXPECT_EQ(CookieMonster::kMaxCookies * 2 + 1, GetAllCookies(cm).size()); 1721 EXPECT_EQ(CookieMonster::kMaxCookies * 2 + 1, GetAllCookies(cm).size());
1722 } 1722 }
1723 1723
1724 // Now we explore a series of relationships between cookie last access 1724 // Now we explore a series of relationships between cookie last access
1725 // time and size of store to make sure we only get rid of cookies when 1725 // time and size of store to make sure we only get rid of cookies when
1726 // we really should. 1726 // we really should.
1727 const struct TestCase { 1727 const struct TestCase {
1728 int num_cookies; 1728 size_t num_cookies;
1729 int num_old_cookies; 1729 size_t num_old_cookies;
1730 int expected_initial_cookies; 1730 size_t expected_initial_cookies;
1731 // Indexed by ExpiryAndKeyScheme 1731 // Indexed by ExpiryAndKeyScheme
1732 int expected_cookies_after_set; 1732 size_t expected_cookies_after_set;
1733 } test_cases[] = { 1733 } test_cases[] = {
1734 { 1734 {
1735 // A whole lot of recent cookies; gc shouldn't happen. 1735 // A whole lot of recent cookies; gc shouldn't happen.
1736 CookieMonster::kMaxCookies * 2, 1736 CookieMonster::kMaxCookies * 2,
1737 0, 1737 0,
1738 CookieMonster::kMaxCookies * 2, 1738 CookieMonster::kMaxCookies * 2,
1739 CookieMonster::kMaxCookies * 2 + 1 1739 CookieMonster::kMaxCookies * 2 + 1
1740 }, { 1740 }, {
1741 // Some old cookies, but still overflowing max. 1741 // Some old cookies, but still overflowing max.
1742 CookieMonster::kMaxCookies * 2, 1742 CookieMonster::kMaxCookies * 2,
(...skipping 15 matching lines...) Expand all
1758 CookieMonster::kMaxCookies - CookieMonster::kPurgeCookies 1758 CookieMonster::kMaxCookies - CookieMonster::kPurgeCookies
1759 } 1759 }
1760 }; 1760 };
1761 1761
1762 for (int ci = 0; ci < static_cast<int>(ARRAYSIZE_UNSAFE(test_cases)); ++ci) { 1762 for (int ci = 0; ci < static_cast<int>(ARRAYSIZE_UNSAFE(test_cases)); ++ci) {
1763 const TestCase *test_case = &test_cases[ci]; 1763 const TestCase *test_case = &test_cases[ci];
1764 scoped_refptr<CookieMonster> cm( 1764 scoped_refptr<CookieMonster> cm(
1765 CreateMonsterFromStoreForGC( 1765 CreateMonsterFromStoreForGC(
1766 test_case->num_cookies, test_case->num_old_cookies, 1766 test_case->num_cookies, test_case->num_old_cookies,
1767 CookieMonster::kSafeFromGlobalPurgeDays * 2)); 1767 CookieMonster::kSafeFromGlobalPurgeDays * 2));
1768 EXPECT_EQ(test_case->expected_initial_cookies, 1768 EXPECT_EQ(test_case->expected_initial_cookies, GetAllCookies(cm).size())
1769 static_cast<int>(GetAllCookies(cm).size()))
1770 << "For test case " << ci; 1769 << "For test case " << ci;
1771 // Will trigger GC 1770 // Will trigger GC
1772 SetCookie(cm, GURL("http://newdomain.com"), "b=2"); 1771 SetCookie(cm, GURL("http://newdomain.com"), "b=2");
1773 EXPECT_EQ(test_case->expected_cookies_after_set, 1772 EXPECT_EQ(test_case->expected_cookies_after_set, GetAllCookies(cm).size())
1774 static_cast<int>((GetAllCookies(cm).size())))
1775 << "For test case " << ci; 1773 << "For test case " << ci;
1776 } 1774 }
1777 } 1775 }
1778 1776
1779 // This test checks that keep expired cookies flag is working. 1777 // This test checks that keep expired cookies flag is working.
1780 TEST_F(CookieMonsterTest, KeepExpiredCookies) { 1778 TEST_F(CookieMonsterTest, KeepExpiredCookies) {
1781 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); 1779 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL));
1782 cm->SetKeepExpiredCookies(); 1780 cm->SetKeepExpiredCookies();
1783 CookieOptions options; 1781 CookieOptions options;
1784 1782
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
2259 EXPECT_EQ(CookieStoreCommand::ADD, store->commands()[4].type); 2257 EXPECT_EQ(CookieStoreCommand::ADD, store->commands()[4].type);
2260 2258
2261 // Create some non-persistent cookies and check that they don't go to the 2259 // Create some non-persistent cookies and check that they don't go to the
2262 // persistent storage. 2260 // persistent storage.
2263 EXPECT_TRUE(SetCookie(cm, url_google_, "B=Bar")); 2261 EXPECT_TRUE(SetCookie(cm, url_google_, "B=Bar"));
2264 this->MatchCookieLines("A=Foo; B=Bar", GetCookies(cm, url_google_)); 2262 this->MatchCookieLines("A=Foo; B=Bar", GetCookies(cm, url_google_));
2265 EXPECT_EQ(5u, store->commands().size()); 2263 EXPECT_EQ(5u, store->commands().size());
2266 } 2264 }
2267 2265
2268 } // namespace net 2266 } // namespace net
OLDNEW
« no previous file with comments | « net/cookies/cookie_monster_perftest.cc ('k') | net/spdy/spdy_http_stream_spdy3_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698