Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: net/cookies/cookie_store_unittest.cc

Issue 1893083002: Change scoped_ptr to std::unique_ptr in //net. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptr-net-all: iwyu Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/cookies/cookie_store_unittest.h ('k') | net/extras/sqlite/sqlite_channel_id_store.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 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/cookies/cookie_store.h"
6
7 #include <memory>
5 #include <vector> 8 #include <vector>
6 9
7 #include "base/time/time.h" 10 #include "base/time/time.h"
8 #include "net/cookies/cookie_store.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "net/cookies/canonical_cookie.h" 11 #include "net/cookies/canonical_cookie.h"
11 #include "net/cookies/cookie_options.h" 12 #include "net/cookies/cookie_options.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 #include "url/gurl.h" 14 #include "url/gurl.h"
14 15
15 namespace net { 16 namespace net {
16 17
17 namespace { 18 namespace {
18 19
19 // Helper for testing BuildCookieLine 20 // Helper for testing BuildCookieLine
20 void MatchCookieLineToVector( 21 void MatchCookieLineToVector(
21 const std::string& line, 22 const std::string& line,
22 const std::vector<scoped_ptr<CanonicalCookie>>& cookies) { 23 const std::vector<std::unique_ptr<CanonicalCookie>>& cookies) {
23 // Test the std::vector<CanonicalCookie> variant 24 // Test the std::vector<CanonicalCookie> variant
24 // ('CookieMonster::CookieList'): 25 // ('CookieMonster::CookieList'):
25 std::vector<CanonicalCookie> list; 26 std::vector<CanonicalCookie> list;
26 for (const auto& cookie : cookies) 27 for (const auto& cookie : cookies)
27 list.push_back(*cookie); 28 list.push_back(*cookie);
28 EXPECT_EQ(line, CookieStore::BuildCookieLine(list)); 29 EXPECT_EQ(line, CookieStore::BuildCookieLine(list));
29 30
30 // Test the std::vector<CanonicalCookie*> variant 31 // Test the std::vector<CanonicalCookie*> variant
31 // ('CookieMonster::CanonicalCookieVector' (yes, this is absurd)): 32 // ('CookieMonster::CanonicalCookieVector' (yes, this is absurd)):
32 std::vector<CanonicalCookie*> ptr_list; 33 std::vector<CanonicalCookie*> ptr_list;
33 for (const auto& cookie : cookies) 34 for (const auto& cookie : cookies)
34 ptr_list.push_back(cookie.get()); 35 ptr_list.push_back(cookie.get());
35 EXPECT_EQ(line, CookieStore::BuildCookieLine(ptr_list)); 36 EXPECT_EQ(line, CookieStore::BuildCookieLine(ptr_list));
36 } 37 }
37 38
38 } // namespace 39 } // namespace
39 40
40 TEST(CookieStoreBaseTest, BuildCookieLine) { 41 TEST(CookieStoreBaseTest, BuildCookieLine) {
41 std::vector<scoped_ptr<CanonicalCookie>> cookies; 42 std::vector<std::unique_ptr<CanonicalCookie>> cookies;
42 GURL url("https://example.com/"); 43 GURL url("https://example.com/");
43 CookieOptions options; 44 CookieOptions options;
44 base::Time now = base::Time::Now(); 45 base::Time now = base::Time::Now();
45 MatchCookieLineToVector("", cookies); 46 MatchCookieLineToVector("", cookies);
46 47
47 cookies.push_back(CanonicalCookie::Create(url, "A=B", now, options)); 48 cookies.push_back(CanonicalCookie::Create(url, "A=B", now, options));
48 MatchCookieLineToVector("A=B", cookies); 49 MatchCookieLineToVector("A=B", cookies);
49 // Nameless cookies are sent back without a prefixed '='. 50 // Nameless cookies are sent back without a prefixed '='.
50 cookies.push_back(CanonicalCookie::Create(url, "C", now, options)); 51 cookies.push_back(CanonicalCookie::Create(url, "C", now, options));
51 MatchCookieLineToVector("A=B; C", cookies); 52 MatchCookieLineToVector("A=B; C", cookies);
52 // Cookies separated by ';'. 53 // Cookies separated by ';'.
53 cookies.push_back(CanonicalCookie::Create(url, "D=E", now, options)); 54 cookies.push_back(CanonicalCookie::Create(url, "D=E", now, options));
54 MatchCookieLineToVector("A=B; C; D=E", cookies); 55 MatchCookieLineToVector("A=B; C; D=E", cookies);
55 // BuildCookieLine doesn't reorder the list, it relies on the caller to do so. 56 // BuildCookieLine doesn't reorder the list, it relies on the caller to do so.
56 cookies.push_back(CanonicalCookie::Create( 57 cookies.push_back(CanonicalCookie::Create(
57 url, "F=G", now - base::TimeDelta::FromSeconds(1), options)); 58 url, "F=G", now - base::TimeDelta::FromSeconds(1), options));
58 MatchCookieLineToVector("A=B; C; D=E; F=G", cookies); 59 MatchCookieLineToVector("A=B; C; D=E; F=G", cookies);
59 // BuildCookieLine doesn't deduplicate. 60 // BuildCookieLine doesn't deduplicate.
60 cookies.push_back(CanonicalCookie::Create( 61 cookies.push_back(CanonicalCookie::Create(
61 url, "D=E", now - base::TimeDelta::FromSeconds(2), options)); 62 url, "D=E", now - base::TimeDelta::FromSeconds(2), options));
62 MatchCookieLineToVector("A=B; C; D=E; F=G; D=E", cookies); 63 MatchCookieLineToVector("A=B; C; D=E; F=G; D=E", cookies);
63 } 64 }
64 65
65 } // namespace net 66 } // namespace net
OLDNEW
« no previous file with comments | « net/cookies/cookie_store_unittest.h ('k') | net/extras/sqlite/sqlite_channel_id_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698