| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/callback.h" | 6 #include "base/callback.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 ASSERT_STREQ("Y", cookies[0]->Value().c_str()); | 179 ASSERT_STREQ("Y", cookies[0]->Value().c_str()); |
| 180 STLDeleteContainerPointers(cookies.begin(), cookies.end()); | 180 STLDeleteContainerPointers(cookies.begin(), cookies.end()); |
| 181 cookies.clear(); | 181 cookies.clear(); |
| 182 } | 182 } |
| 183 | 183 |
| 184 // Test if data is stored as expected in the SQLite database. | 184 // Test if data is stored as expected in the SQLite database. |
| 185 TEST_F(SQLitePersistentCookieStoreTest, TestPersistance) { | 185 TEST_F(SQLitePersistentCookieStoreTest, TestPersistance) { |
| 186 InitializeStore(false); | 186 InitializeStore(false); |
| 187 AddCookie("A", "B", "http://foo.bar", "/", base::Time::Now()); | 187 AddCookie("A", "B", "http://foo.bar", "/", base::Time::Now()); |
| 188 // Replace the store effectively destroying the current one and forcing it | 188 // Replace the store effectively destroying the current one and forcing it |
| 189 // to write it's data to disk. Then we can see if after loading it again it | 189 // to write its data to disk. Then we can see if after loading it again it |
| 190 // is still there. | 190 // is still there. |
| 191 DestroyStore(); | 191 DestroyStore(); |
| 192 // Reload and test for persistence | 192 // Reload and test for persistence |
| 193 std::vector<net::CookieMonster::CanonicalCookie*> cookies; | 193 std::vector<net::CookieMonster::CanonicalCookie*> cookies; |
| 194 CreateAndLoad(false, &cookies); | 194 CreateAndLoad(false, &cookies); |
| 195 ASSERT_EQ(1U, cookies.size()); | 195 ASSERT_EQ(1U, cookies.size()); |
| 196 ASSERT_STREQ("http://foo.bar", cookies[0]->Domain().c_str()); | 196 ASSERT_STREQ("http://foo.bar", cookies[0]->Domain().c_str()); |
| 197 ASSERT_STREQ("A", cookies[0]->Name().c_str()); | 197 ASSERT_STREQ("A", cookies[0]->Name().c_str()); |
| 198 ASSERT_STREQ("B", cookies[0]->Value().c_str()); | 198 ASSERT_STREQ("B", cookies[0]->Value().c_str()); |
| 199 | 199 |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 | 445 |
| 446 EXPECT_FALSE(cookie_map["session-noexpires"]->DoesExpire()); | 446 EXPECT_FALSE(cookie_map["session-noexpires"]->DoesExpire()); |
| 447 EXPECT_FALSE(cookie_map["session-noexpires"]->IsPersistent()); | 447 EXPECT_FALSE(cookie_map["session-noexpires"]->IsPersistent()); |
| 448 | 448 |
| 449 EXPECT_TRUE(cookie_map["persistent"]->DoesExpire()); | 449 EXPECT_TRUE(cookie_map["persistent"]->DoesExpire()); |
| 450 EXPECT_TRUE(cookie_map["persistent"]->IsPersistent()); | 450 EXPECT_TRUE(cookie_map["persistent"]->IsPersistent()); |
| 451 | 451 |
| 452 STLDeleteContainerPointers(cookies.begin(), cookies.end()); | 452 STLDeleteContainerPointers(cookies.begin(), cookies.end()); |
| 453 cookies.clear(); | 453 cookies.clear(); |
| 454 } | 454 } |
| OLD | NEW |