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/extras/sqlite/sqlite_persistent_cookie_store.h" | 5 #include "net/extras/sqlite/sqlite_persistent_cookie_store.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 DestroyStore(); | 652 DestroyStore(); |
653 | 653 |
654 // Create a store that loads session cookie and test that the priority | 654 // Create a store that loads session cookie and test that the priority |
655 // attribute values are restored. | 655 // attribute values are restored. |
656 CanonicalCookieVector cookies; | 656 CanonicalCookieVector cookies; |
657 CreateAndLoad(false, true, &cookies); | 657 CreateAndLoad(false, true, &cookies); |
658 ASSERT_EQ(3U, cookies.size()); | 658 ASSERT_EQ(3U, cookies.size()); |
659 | 659 |
660 // Put the cookies into a map, by name, for comparison below. | 660 // Put the cookies into a map, by name, for comparison below. |
661 std::map<std::string, CanonicalCookie*> cookie_map; | 661 std::map<std::string, CanonicalCookie*> cookie_map; |
662 for (const auto& cookie : cookies) | 662 for (auto* cookie : cookies) |
663 cookie_map[cookie->Name()] = cookie; | 663 cookie_map[cookie->Name()] = cookie; |
664 | 664 |
665 // Validate that each cookie has the correct SameSite. | 665 // Validate that each cookie has the correct SameSite. |
666 ASSERT_EQ(1u, cookie_map.count(kNoneName)); | 666 ASSERT_EQ(1u, cookie_map.count(kNoneName)); |
667 EXPECT_EQ(CookieSameSite::NO_RESTRICTION, cookie_map[kNoneName]->SameSite()); | 667 EXPECT_EQ(CookieSameSite::NO_RESTRICTION, cookie_map[kNoneName]->SameSite()); |
668 | 668 |
669 ASSERT_EQ(1u, cookie_map.count(kLaxName)); | 669 ASSERT_EQ(1u, cookie_map.count(kLaxName)); |
670 EXPECT_EQ(CookieSameSite::LAX_MODE, cookie_map[kLaxName]->SameSite()); | 670 EXPECT_EQ(CookieSameSite::LAX_MODE, cookie_map[kLaxName]->SameSite()); |
671 | 671 |
672 ASSERT_EQ(1u, cookie_map.count(kStrictName)); | 672 ASSERT_EQ(1u, cookie_map.count(kStrictName)); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 EXPECT_TRUE(was_called_with_no_cookies); | 825 EXPECT_TRUE(was_called_with_no_cookies); |
826 | 826 |
827 // Same with trying to load a specific cookie. | 827 // Same with trying to load a specific cookie. |
828 was_called_with_no_cookies = false; | 828 was_called_with_no_cookies = false; |
829 store_->LoadCookiesForKey("foo.bar", base::Bind(WasCalledWithNoCookies, | 829 store_->LoadCookiesForKey("foo.bar", base::Bind(WasCalledWithNoCookies, |
830 &was_called_with_no_cookies)); | 830 &was_called_with_no_cookies)); |
831 EXPECT_TRUE(was_called_with_no_cookies); | 831 EXPECT_TRUE(was_called_with_no_cookies); |
832 } | 832 } |
833 | 833 |
834 } // namespace net | 834 } // namespace net |
OLD | NEW |