OLD | NEW |
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 <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 1940 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1951 {GURL("https://google.com"), "c", "3", "", "/another/path/to/cookie", | 1951 {GURL("https://google.com"), "c", "3", "", "/another/path/to/cookie", |
1952 base::Time::Now() + base::TimeDelta::FromSeconds(100), | 1952 base::Time::Now() + base::TimeDelta::FromSeconds(100), |
1953 true, false, COOKIE_PRIORITY_DEFAULT} | 1953 true, false, COOKIE_PRIORITY_DEFAULT} |
1954 }; | 1954 }; |
1955 const int INPUT_DELETE = 1; | 1955 const int INPUT_DELETE = 1; |
1956 | 1956 |
1957 // Create new cookies and flush them to the store. | 1957 // Create new cookies and flush them to the store. |
1958 { | 1958 { |
1959 scoped_refptr<CookieMonster> cmout(new CookieMonster(store.get(), NULL)); | 1959 scoped_refptr<CookieMonster> cmout(new CookieMonster(store.get(), NULL)); |
1960 for (const CookiesInputInfo* p = input_info; | 1960 for (const CookiesInputInfo* p = input_info; |
1961 p < &input_info[ARRAYSIZE_UNSAFE(input_info)]; | 1961 p < &input_info[arraysize(input_info)]; |
1962 p++) { | 1962 p++) { |
1963 EXPECT_TRUE(SetCookieWithDetails(cmout.get(), | 1963 EXPECT_TRUE(SetCookieWithDetails(cmout.get(), |
1964 p->url, | 1964 p->url, |
1965 p->name, | 1965 p->name, |
1966 p->value, | 1966 p->value, |
1967 p->domain, | 1967 p->domain, |
1968 p->path, | 1968 p->path, |
1969 p->expiration_time, | 1969 p->expiration_time, |
1970 p->secure, | 1970 p->secure, |
1971 p->http_only, | 1971 p->http_only, |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2105 }, { | 2105 }, { |
2106 // Old cookies enough to bring below our purge line (which we | 2106 // Old cookies enough to bring below our purge line (which we |
2107 // shouldn't do). | 2107 // shouldn't do). |
2108 CookieMonster::kMaxCookies * 2, | 2108 CookieMonster::kMaxCookies * 2, |
2109 CookieMonster::kMaxCookies * 3 / 2, | 2109 CookieMonster::kMaxCookies * 3 / 2, |
2110 CookieMonster::kMaxCookies * 2, | 2110 CookieMonster::kMaxCookies * 2, |
2111 CookieMonster::kMaxCookies - CookieMonster::kPurgeCookies | 2111 CookieMonster::kMaxCookies - CookieMonster::kPurgeCookies |
2112 } | 2112 } |
2113 }; | 2113 }; |
2114 | 2114 |
2115 for (int ci = 0; ci < static_cast<int>(ARRAYSIZE_UNSAFE(test_cases)); ++ci) { | 2115 for (int ci = 0; ci < static_cast<int>(arraysize(test_cases)); ++ci) { |
2116 const TestCase *test_case = &test_cases[ci]; | 2116 const TestCase *test_case = &test_cases[ci]; |
2117 scoped_refptr<CookieMonster> cm( | 2117 scoped_refptr<CookieMonster> cm( |
2118 CreateMonsterFromStoreForGC( | 2118 CreateMonsterFromStoreForGC( |
2119 test_case->num_cookies, test_case->num_old_cookies, | 2119 test_case->num_cookies, test_case->num_old_cookies, |
2120 CookieMonster::kSafeFromGlobalPurgeDays * 2)); | 2120 CookieMonster::kSafeFromGlobalPurgeDays * 2)); |
2121 EXPECT_EQ(test_case->expected_initial_cookies, | 2121 EXPECT_EQ(test_case->expected_initial_cookies, |
2122 GetAllCookies(cm.get()).size()) << "For test case " << ci; | 2122 GetAllCookies(cm.get()).size()) << "For test case " << ci; |
2123 // Will trigger GC | 2123 // Will trigger GC |
2124 SetCookie(cm.get(), GURL("http://newdomain.com"), "b=2"); | 2124 SetCookie(cm.get(), GURL("http://newdomain.com"), "b=2"); |
2125 EXPECT_EQ(test_case->expected_cookies_after_set, | 2125 EXPECT_EQ(test_case->expected_cookies_after_set, |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2732 | 2732 |
2733 // Inject our initial cookies into the mock PersistentCookieStore. | 2733 // Inject our initial cookies into the mock PersistentCookieStore. |
2734 store->SetLoadExpectation(true, initial_cookies); | 2734 store->SetLoadExpectation(true, initial_cookies); |
2735 | 2735 |
2736 scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL)); | 2736 scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL)); |
2737 | 2737 |
2738 EXPECT_EQ("foo=bar; hello=world", GetCookies(cm.get(), url)); | 2738 EXPECT_EQ("foo=bar; hello=world", GetCookies(cm.get(), url)); |
2739 } | 2739 } |
2740 | 2740 |
2741 } // namespace net | 2741 } // namespace net |
OLD | NEW |