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 2293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2304 EXPECT_TRUE(IsCookieInList(cookie6_with_new_path, cookies_to_add)); | 2304 EXPECT_TRUE(IsCookieInList(cookie6_with_new_path, cookies_to_add)); |
2305 EXPECT_FALSE(IsCookieInList(cookie6_with_new_path, cookies_to_delete)); | 2305 EXPECT_FALSE(IsCookieInList(cookie6_with_new_path, cookies_to_delete)); |
2306 | 2306 |
2307 // |cookie7| is kept and |cookie7_with_new_path| is added as a new cookie. | 2307 // |cookie7| is kept and |cookie7_with_new_path| is added as a new cookie. |
2308 EXPECT_FALSE(IsCookieInList(cookie7, cookies_to_add)); | 2308 EXPECT_FALSE(IsCookieInList(cookie7, cookies_to_add)); |
2309 EXPECT_FALSE(IsCookieInList(cookie7, cookies_to_delete)); | 2309 EXPECT_FALSE(IsCookieInList(cookie7, cookies_to_delete)); |
2310 EXPECT_TRUE(IsCookieInList(cookie7_with_new_path, cookies_to_add)); | 2310 EXPECT_TRUE(IsCookieInList(cookie7_with_new_path, cookies_to_add)); |
2311 EXPECT_FALSE(IsCookieInList(cookie7_with_new_path, cookies_to_delete)); | 2311 EXPECT_FALSE(IsCookieInList(cookie7_with_new_path, cookies_to_delete)); |
2312 } | 2312 } |
2313 | 2313 |
| 2314 // Check that DeleteAll does flush (as a sanity check that flush_count() |
| 2315 // works). |
| 2316 TEST_F(CookieMonsterTest, DeleteAll) { |
| 2317 scoped_refptr<FlushablePersistentStore> store(new FlushablePersistentStore()); |
| 2318 scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL)); |
| 2319 cm->SetPersistSessionCookies(true); |
| 2320 |
| 2321 EXPECT_TRUE(SetCookie(cm.get(), url_google_, "X=Y; path=/")); |
| 2322 |
| 2323 ASSERT_EQ(0, store->flush_count()); |
| 2324 EXPECT_EQ(1, DeleteAll(cm.get())); |
| 2325 EXPECT_EQ(1, store->flush_count()); |
| 2326 } |
| 2327 |
2314 TEST_F(CookieMonsterTest, HistogramCheck) { | 2328 TEST_F(CookieMonsterTest, HistogramCheck) { |
2315 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); | 2329 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); |
2316 // Should match call in InitializeHistograms, but doesn't really matter | 2330 // Should match call in InitializeHistograms, but doesn't really matter |
2317 // since the histogram should have been initialized by the CM construction | 2331 // since the histogram should have been initialized by the CM construction |
2318 // above. | 2332 // above. |
2319 base::HistogramBase* expired_histogram = base::Histogram::FactoryGet( | 2333 base::HistogramBase* expired_histogram = base::Histogram::FactoryGet( |
2320 "Cookie.ExpirationDurationMinutes", 1, 10 * 365 * 24 * 60, 50, | 2334 "Cookie.ExpirationDurationMinutes", 1, 10 * 365 * 24 * 60, 50, |
2321 base::Histogram::kUmaTargetedHistogramFlag); | 2335 base::Histogram::kUmaTargetedHistogramFlag); |
2322 | 2336 |
2323 scoped_ptr<base::HistogramSamples> samples1( | 2337 scoped_ptr<base::HistogramSamples> samples1( |
(...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2948 monster()->AddCallbackForCookie( | 2962 monster()->AddCallbackForCookie( |
2949 test_url_, "abc", | 2963 test_url_, "abc", |
2950 base::Bind(&RecordCookieChanges, &cookies1, nullptr))); | 2964 base::Bind(&RecordCookieChanges, &cookies1, nullptr))); |
2951 SetCookie(monster(), test_url_, "abc=def"); | 2965 SetCookie(monster(), test_url_, "abc=def"); |
2952 base::MessageLoop::current()->RunUntilIdle(); | 2966 base::MessageLoop::current()->RunUntilIdle(); |
2953 EXPECT_EQ(1U, cookies0.size()); | 2967 EXPECT_EQ(1U, cookies0.size()); |
2954 EXPECT_EQ(1U, cookies0.size()); | 2968 EXPECT_EQ(1U, cookies0.size()); |
2955 } | 2969 } |
2956 | 2970 |
2957 } // namespace net | 2971 } // namespace net |
OLD | NEW |