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 // This file contains test infrastructure for multiple files | 5 // This file contains test infrastructure for multiple files |
6 // (current cookie_monster_unittest.cc and cookie_monster_perftest.cc) | 6 // (current cookie_monster_unittest.cc and cookie_monster_perftest.cc) |
7 // that need to test out CookieMonster interactions with the backing store. | 7 // that need to test out CookieMonster interactions with the backing store. |
8 // It should only be included by test code. | 8 // It should only be included by test code. |
9 | 9 |
10 #ifndef NET_COOKIES_COOKIE_MONSTER_STORE_TEST_H_ | 10 #ifndef NET_COOKIES_COOKIE_MONSTER_STORE_TEST_H_ |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 MockPersistentCookieStore(); | 75 MockPersistentCookieStore(); |
76 | 76 |
77 void SetLoadExpectation( | 77 void SetLoadExpectation( |
78 bool return_value, | 78 bool return_value, |
79 const std::vector<CanonicalCookie*>& result); | 79 const std::vector<CanonicalCookie*>& result); |
80 | 80 |
81 const CommandList& commands() const { | 81 const CommandList& commands() const { |
82 return commands_; | 82 return commands_; |
83 } | 83 } |
84 | 84 |
85 virtual void Load(const LoadedCallback& loaded_callback) OVERRIDE; | 85 virtual void Load(const LoadedCallback& loaded_callback) override; |
86 | 86 |
87 virtual void LoadCookiesForKey(const std::string& key, | 87 virtual void LoadCookiesForKey(const std::string& key, |
88 const LoadedCallback& loaded_callback) OVERRIDE; | 88 const LoadedCallback& loaded_callback) override; |
89 | 89 |
90 virtual void AddCookie(const CanonicalCookie& cookie) OVERRIDE; | 90 virtual void AddCookie(const CanonicalCookie& cookie) override; |
91 | 91 |
92 virtual void UpdateCookieAccessTime( | 92 virtual void UpdateCookieAccessTime( |
93 const CanonicalCookie& cookie) OVERRIDE; | 93 const CanonicalCookie& cookie) override; |
94 | 94 |
95 virtual void DeleteCookie( | 95 virtual void DeleteCookie( |
96 const CanonicalCookie& cookie) OVERRIDE; | 96 const CanonicalCookie& cookie) override; |
97 | 97 |
98 virtual void Flush(const base::Closure& callback) OVERRIDE; | 98 virtual void Flush(const base::Closure& callback) override; |
99 | 99 |
100 virtual void SetForceKeepSessionState() OVERRIDE; | 100 virtual void SetForceKeepSessionState() override; |
101 | 101 |
102 protected: | 102 protected: |
103 virtual ~MockPersistentCookieStore(); | 103 virtual ~MockPersistentCookieStore(); |
104 | 104 |
105 private: | 105 private: |
106 CommandList commands_; | 106 CommandList commands_; |
107 | 107 |
108 // Deferred result to use when Load() is called. | 108 // Deferred result to use when Load() is called. |
109 bool load_return_value_; | 109 bool load_return_value_; |
110 std::vector<CanonicalCookie*> load_result_; | 110 std::vector<CanonicalCookie*> load_result_; |
(...skipping 12 matching lines...) Expand all Loading... |
123 | 123 |
124 MockCookieMonsterDelegate(); | 124 MockCookieMonsterDelegate(); |
125 | 125 |
126 const std::vector<CookieNotification>& changes() const { return changes_; } | 126 const std::vector<CookieNotification>& changes() const { return changes_; } |
127 | 127 |
128 void reset() { changes_.clear(); } | 128 void reset() { changes_.clear(); } |
129 | 129 |
130 virtual void OnCookieChanged( | 130 virtual void OnCookieChanged( |
131 const CanonicalCookie& cookie, | 131 const CanonicalCookie& cookie, |
132 bool removed, | 132 bool removed, |
133 CookieMonsterDelegate::ChangeCause cause) OVERRIDE; | 133 CookieMonsterDelegate::ChangeCause cause) override; |
134 | 134 |
135 virtual void OnLoaded() OVERRIDE; | 135 virtual void OnLoaded() override; |
136 | 136 |
137 private: | 137 private: |
138 virtual ~MockCookieMonsterDelegate(); | 138 virtual ~MockCookieMonsterDelegate(); |
139 | 139 |
140 std::vector<CookieNotification> changes_; | 140 std::vector<CookieNotification> changes_; |
141 | 141 |
142 DISALLOW_COPY_AND_ASSIGN(MockCookieMonsterDelegate); | 142 DISALLOW_COPY_AND_ASSIGN(MockCookieMonsterDelegate); |
143 }; | 143 }; |
144 | 144 |
145 // Helper to build a single CanonicalCookie. | 145 // Helper to build a single CanonicalCookie. |
146 CanonicalCookie BuildCanonicalCookie(const std::string& key, | 146 CanonicalCookie BuildCanonicalCookie(const std::string& key, |
147 const std::string& cookie_line, | 147 const std::string& cookie_line, |
148 const base::Time& creation_time); | 148 const base::Time& creation_time); |
149 | 149 |
150 // Helper to build a list of CanonicalCookie*s. | 150 // Helper to build a list of CanonicalCookie*s. |
151 void AddCookieToList( | 151 void AddCookieToList( |
152 const std::string& key, | 152 const std::string& key, |
153 const std::string& cookie_line, | 153 const std::string& cookie_line, |
154 const base::Time& creation_time, | 154 const base::Time& creation_time, |
155 std::vector<CanonicalCookie*>* out_list); | 155 std::vector<CanonicalCookie*>* out_list); |
156 | 156 |
157 // Just act like a backing database. Keep cookie information from | 157 // Just act like a backing database. Keep cookie information from |
158 // Add/Update/Delete and regurgitate it when Load is called. | 158 // Add/Update/Delete and regurgitate it when Load is called. |
159 class MockSimplePersistentCookieStore | 159 class MockSimplePersistentCookieStore |
160 : public CookieMonster::PersistentCookieStore { | 160 : public CookieMonster::PersistentCookieStore { |
161 public: | 161 public: |
162 MockSimplePersistentCookieStore(); | 162 MockSimplePersistentCookieStore(); |
163 | 163 |
164 virtual void Load(const LoadedCallback& loaded_callback) OVERRIDE; | 164 virtual void Load(const LoadedCallback& loaded_callback) override; |
165 | 165 |
166 virtual void LoadCookiesForKey(const std::string& key, | 166 virtual void LoadCookiesForKey(const std::string& key, |
167 const LoadedCallback& loaded_callback) OVERRIDE; | 167 const LoadedCallback& loaded_callback) override; |
168 | 168 |
169 virtual void AddCookie(const CanonicalCookie& cookie) OVERRIDE; | 169 virtual void AddCookie(const CanonicalCookie& cookie) override; |
170 | 170 |
171 virtual void UpdateCookieAccessTime(const CanonicalCookie& cookie) OVERRIDE; | 171 virtual void UpdateCookieAccessTime(const CanonicalCookie& cookie) override; |
172 | 172 |
173 virtual void DeleteCookie(const CanonicalCookie& cookie) OVERRIDE; | 173 virtual void DeleteCookie(const CanonicalCookie& cookie) override; |
174 | 174 |
175 virtual void Flush(const base::Closure& callback) OVERRIDE; | 175 virtual void Flush(const base::Closure& callback) override; |
176 | 176 |
177 virtual void SetForceKeepSessionState() OVERRIDE; | 177 virtual void SetForceKeepSessionState() override; |
178 | 178 |
179 protected: | 179 protected: |
180 virtual ~MockSimplePersistentCookieStore(); | 180 virtual ~MockSimplePersistentCookieStore(); |
181 | 181 |
182 private: | 182 private: |
183 typedef std::map<int64, CanonicalCookie> CanonicalCookieMap; | 183 typedef std::map<int64, CanonicalCookie> CanonicalCookieMap; |
184 | 184 |
185 CanonicalCookieMap cookies_; | 185 CanonicalCookieMap cookies_; |
186 | 186 |
187 // Indicates if the store has been fully loaded to avoid return duplicate | 187 // Indicates if the store has been fully loaded to avoid return duplicate |
(...skipping 10 matching lines...) Expand all Loading... |
198 // longer than |gc_perf_micros| to complete, and how many cookie were | 198 // longer than |gc_perf_micros| to complete, and how many cookie were |
199 // left in the store afterwards. | 199 // left in the store afterwards. |
200 CookieMonster* CreateMonsterFromStoreForGC( | 200 CookieMonster* CreateMonsterFromStoreForGC( |
201 int num_cookies, | 201 int num_cookies, |
202 int num_old_cookies, | 202 int num_old_cookies, |
203 int days_old); | 203 int days_old); |
204 | 204 |
205 } // namespace net | 205 } // namespace net |
206 | 206 |
207 #endif // NET_COOKIES_COOKIE_MONSTER_STORE_TEST_H_ | 207 #endif // NET_COOKIES_COOKIE_MONSTER_STORE_TEST_H_ |
OLD | NEW |