| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 class EvictedDomainCookieCounterTest : public testing::Test { | 31 class EvictedDomainCookieCounterTest : public testing::Test { |
| 32 protected: | 32 protected: |
| 33 class MockDelegate : public EvictedDomainCookieCounter::Delegate { | 33 class MockDelegate : public EvictedDomainCookieCounter::Delegate { |
| 34 public: | 34 public: |
| 35 explicit MockDelegate(EvictedDomainCookieCounterTest* tester); | 35 explicit MockDelegate(EvictedDomainCookieCounterTest* tester); |
| 36 | 36 |
| 37 // EvictedDomainCookieCounter::Delegate implementation. | 37 // EvictedDomainCookieCounter::Delegate implementation. |
| 38 virtual void Report( | 38 virtual void Report( |
| 39 const EvictedDomainCookieCounter::EvictedCookie& evicted_cookie, | 39 const EvictedDomainCookieCounter::EvictedCookie& evicted_cookie, |
| 40 const Time& reinstatement_time) OVERRIDE; | 40 const Time& reinstatement_time) override; |
| 41 virtual Time CurrentTime() const OVERRIDE; | 41 virtual Time CurrentTime() const override; |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 EvictedDomainCookieCounterTest* tester_; | 44 EvictedDomainCookieCounterTest* tester_; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 EvictedDomainCookieCounterTest(); | 47 EvictedDomainCookieCounterTest(); |
| 48 virtual ~EvictedDomainCookieCounterTest(); | 48 virtual ~EvictedDomainCookieCounterTest(); |
| 49 | 49 |
| 50 // testing::Test implementation. | 50 // testing::Test implementation. |
| 51 virtual void SetUp() OVERRIDE; | 51 virtual void SetUp() override; |
| 52 virtual void TearDown() OVERRIDE; | 52 virtual void TearDown() override; |
| 53 | 53 |
| 54 // Initialization that allows parameters to be specified. | 54 // Initialization that allows parameters to be specified. |
| 55 void InitCounter(size_t max_size, size_t purge_count); | 55 void InitCounter(size_t max_size, size_t purge_count); |
| 56 | 56 |
| 57 // Wrapper to allocate new cookie and store it in |cookies_|. | 57 // Wrapper to allocate new cookie and store it in |cookies_|. |
| 58 // If |max_age| == 0, then the cookie does not expire. | 58 // If |max_age| == 0, then the cookie does not expire. |
| 59 void CreateNewCookie( | 59 void CreateNewCookie( |
| 60 const char* url, const std::string& cookie_line, int64 max_age); | 60 const char* url, const std::string& cookie_line, int64 max_age); |
| 61 | 61 |
| 62 // Clears |cookies_| and creates common cookies for multiple tests. | 62 // Clears |cookies_| and creates common cookies for multiple tests. |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 // dummy CookieMonster::Delegate to increment an integer. | 182 // dummy CookieMonster::Delegate to increment an integer. |
| 183 TEST_F(EvictedDomainCookieCounterTest, TestChain) { | 183 TEST_F(EvictedDomainCookieCounterTest, TestChain) { |
| 184 int result = 0; | 184 int result = 0; |
| 185 | 185 |
| 186 class ChangedDelegateDummy : public net::CookieMonster::Delegate { | 186 class ChangedDelegateDummy : public net::CookieMonster::Delegate { |
| 187 public: | 187 public: |
| 188 explicit ChangedDelegateDummy(int* result) : result_(result) {} | 188 explicit ChangedDelegateDummy(int* result) : result_(result) {} |
| 189 | 189 |
| 190 virtual void OnCookieChanged(const net::CanonicalCookie& cookie, | 190 virtual void OnCookieChanged(const net::CanonicalCookie& cookie, |
| 191 bool removed, | 191 bool removed, |
| 192 ChangeCause cause) OVERRIDE { | 192 ChangeCause cause) override { |
| 193 ++(*result_); | 193 ++(*result_); |
| 194 } | 194 } |
| 195 | 195 |
| 196 virtual void OnLoaded() OVERRIDE {} | 196 virtual void OnLoaded() override {} |
| 197 | 197 |
| 198 private: | 198 private: |
| 199 virtual ~ChangedDelegateDummy() {} | 199 virtual ~ChangedDelegateDummy() {} |
| 200 | 200 |
| 201 int* result_; | 201 int* result_; |
| 202 }; | 202 }; |
| 203 | 203 |
| 204 scoped_ptr<MockDelegate> cookie_counter_delegate(new MockDelegate(this)); | 204 scoped_ptr<MockDelegate> cookie_counter_delegate(new MockDelegate(this)); |
| 205 cookie_counter_ = new EvictedDomainCookieCounter( | 205 cookie_counter_ = new EvictedDomainCookieCounter( |
| 206 new ChangedDelegateDummy(&result), | 206 new ChangedDelegateDummy(&result), |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 for (int i = 0; i < 6; ++i) | 382 for (int i = 0; i < 6; ++i) |
| 383 Add(cookies_[i]); | 383 Add(cookies_[i]); |
| 384 EXPECT_EQ(0u, cookie_counter_->GetStorageSize()); | 384 EXPECT_EQ(0u, cookie_counter_->GetStorageSize()); |
| 385 // Reinstatement delays: [1499,1497,(1494),(1490),(1485),300]. | 385 // Reinstatement delays: [1499,1497,(1494),(1490),(1485),300]. |
| 386 EXPECT_EQ("1499,1497;300", google_stat_ + ";" + other_stat_); | 386 EXPECT_EQ("1499,1497;300", google_stat_ + ";" + other_stat_); |
| 387 } | 387 } |
| 388 | 388 |
| 389 } // namespace | 389 } // namespace |
| 390 | 390 |
| 391 } // namespace chrome_browser_net | 391 } // namespace chrome_browser_net |
| OLD | NEW |