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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 2220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2231 EXPECT_EQ("http://example.com/", | 2231 EXPECT_EQ("http://example.com/", |
2232 CookieMonster::CanonicalCookie::GetCookieSourceFromURL( | 2232 CookieMonster::CanonicalCookie::GetCookieSourceFromURL( |
2233 GURL("http://example.com/test#foo"))); | 2233 GURL("http://example.com/test#foo"))); |
2234 } | 2234 } |
2235 | 2235 |
2236 TEST(CookieMonsterTest, HistogramCheck) { | 2236 TEST(CookieMonsterTest, HistogramCheck) { |
2237 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); | 2237 scoped_refptr<CookieMonster> cm(new CookieMonster(NULL, NULL)); |
2238 // Should match call in InitializeHistograms, but doesn't really matter | 2238 // Should match call in InitializeHistograms, but doesn't really matter |
2239 // since the histogram should have been initialized by the CM construction | 2239 // since the histogram should have been initialized by the CM construction |
2240 // above. | 2240 // above. |
2241 scoped_refptr<base::Histogram> expired_histogram = | 2241 base::Histogram* expired_histogram = |
2242 base::Histogram::FactoryGet( | 2242 base::Histogram::FactoryGet( |
2243 "Cookie.ExpirationDurationMinutes", 1, 10 * 365 * 24 * 60, 50, | 2243 "Cookie.ExpirationDurationMinutes", 1, 10 * 365 * 24 * 60, 50, |
2244 base::Histogram::kUmaTargetedHistogramFlag); | 2244 base::Histogram::kUmaTargetedHistogramFlag); |
2245 | 2245 |
2246 base::Histogram::SampleSet histogram_set_1; | 2246 base::Histogram::SampleSet histogram_set_1; |
2247 expired_histogram->SnapshotSample(&histogram_set_1); | 2247 expired_histogram->SnapshotSample(&histogram_set_1); |
2248 ASSERT_TRUE(cm->SetCookieWithDetails( | 2248 ASSERT_TRUE(cm->SetCookieWithDetails( |
2249 GURL("http://fake.a.url"), "a", "b", "a.url", "/", | 2249 GURL("http://fake.a.url"), "a", "b", "a.url", "/", |
2250 base::Time::Now() + base::TimeDelta::FromMinutes(59), | 2250 base::Time::Now() + base::TimeDelta::FromMinutes(59), |
2251 false, false)); | 2251 false, false)); |
2252 | 2252 |
2253 base::Histogram::SampleSet histogram_set_2; | 2253 base::Histogram::SampleSet histogram_set_2; |
2254 expired_histogram->SnapshotSample(&histogram_set_2); | 2254 expired_histogram->SnapshotSample(&histogram_set_2); |
2255 EXPECT_EQ(histogram_set_1.TotalCount() + 1, | 2255 EXPECT_EQ(histogram_set_1.TotalCount() + 1, |
2256 histogram_set_2.TotalCount()); | 2256 histogram_set_2.TotalCount()); |
2257 | 2257 |
2258 // kValidCookieLine creates a session cookie. | 2258 // kValidCookieLine creates a session cookie. |
2259 GURL url_google(kUrlGoogle); | 2259 GURL url_google(kUrlGoogle); |
2260 ASSERT_TRUE(cm->SetCookie(url_google, kValidCookieLine)); | 2260 ASSERT_TRUE(cm->SetCookie(url_google, kValidCookieLine)); |
2261 expired_histogram->SnapshotSample(&histogram_set_1); | 2261 expired_histogram->SnapshotSample(&histogram_set_1); |
2262 EXPECT_EQ(histogram_set_2.TotalCount(), | 2262 EXPECT_EQ(histogram_set_2.TotalCount(), |
2263 histogram_set_1.TotalCount()); | 2263 histogram_set_1.TotalCount()); |
2264 } | 2264 } |
2265 | 2265 |
2266 } // namespace | 2266 } // namespace |
OLD | NEW |