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/http/http_vary_data_unittest.cc

Issue 15829004: Update net/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: license twerk Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « net/http/http_transaction_unittest.cc ('k') | net/http/mock_http_cache.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "net/http/http_request_info.h" 7 #include "net/http/http_request_info.h"
8 #include "net/http/http_response_headers.h" 8 #include "net/http/http_response_headers.h"
9 #include "net/http/http_vary_data.h" 9 #include "net/http/http_vary_data.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 27 matching lines...) Expand all
38 "HTTP/1.1 200 OK\nVary: cookie, *, bar\n\n", 38 "HTTP/1.1 200 OK\nVary: cookie, *, bar\n\n",
39 "HTTP/1.1 200 OK\nVary: cookie\nFoo: 1\nVary: *\n\n", 39 "HTTP/1.1 200 OK\nVary: cookie\nFoo: 1\nVary: *\n\n",
40 }; 40 };
41 41
42 for (size_t i = 0; i < arraysize(kTestResponses); ++i) { 42 for (size_t i = 0; i < arraysize(kTestResponses); ++i) {
43 TestTransaction t; 43 TestTransaction t;
44 t.Init(std::string(), kTestResponses[i]); 44 t.Init(std::string(), kTestResponses[i]);
45 45
46 net::HttpVaryData v; 46 net::HttpVaryData v;
47 EXPECT_FALSE(v.is_valid()); 47 EXPECT_FALSE(v.is_valid());
48 EXPECT_FALSE(v.Init(t.request, *t.response)); 48 EXPECT_FALSE(v.Init(t.request, *t.response.get()));
49 EXPECT_FALSE(v.is_valid()); 49 EXPECT_FALSE(v.is_valid());
50 } 50 }
51 } 51 }
52 52
53 TEST(HttpVaryDataTest, MultipleInit) { 53 TEST(HttpVaryDataTest, MultipleInit) {
54 net::HttpVaryData v; 54 net::HttpVaryData v;
55 55
56 // Init to something valid. 56 // Init to something valid.
57 TestTransaction t1; 57 TestTransaction t1;
58 t1.Init("Foo: 1\r\nbar: 23", "HTTP/1.1 200 OK\nVary: foo, bar\n\n"); 58 t1.Init("Foo: 1\r\nbar: 23", "HTTP/1.1 200 OK\nVary: foo, bar\n\n");
59 EXPECT_TRUE(v.Init(t1.request, *t1.response)); 59 EXPECT_TRUE(v.Init(t1.request, *t1.response.get()));
60 EXPECT_TRUE(v.is_valid()); 60 EXPECT_TRUE(v.is_valid());
61 61
62 // Now overwrite by initializing to something invalid. 62 // Now overwrite by initializing to something invalid.
63 TestTransaction t2; 63 TestTransaction t2;
64 t2.Init("Foo: 1\r\nbar: 23", "HTTP/1.1 200 OK\nVary: *\n\n"); 64 t2.Init("Foo: 1\r\nbar: 23", "HTTP/1.1 200 OK\nVary: *\n\n");
65 EXPECT_FALSE(v.Init(t2.request, *t2.response)); 65 EXPECT_FALSE(v.Init(t2.request, *t2.response.get()));
66 EXPECT_FALSE(v.is_valid()); 66 EXPECT_FALSE(v.is_valid());
67 } 67 }
68 68
69 TEST(HttpVaryDataTest, DoesVary) { 69 TEST(HttpVaryDataTest, DoesVary) {
70 TestTransaction a; 70 TestTransaction a;
71 a.Init("Foo: 1", "HTTP/1.1 200 OK\nVary: foo\n\n"); 71 a.Init("Foo: 1", "HTTP/1.1 200 OK\nVary: foo\n\n");
72 72
73 TestTransaction b; 73 TestTransaction b;
74 b.Init("Foo: 2", "HTTP/1.1 200 OK\nVary: foo\n\n"); 74 b.Init("Foo: 2", "HTTP/1.1 200 OK\nVary: foo\n\n");
75 75
76 net::HttpVaryData v; 76 net::HttpVaryData v;
77 EXPECT_TRUE(v.Init(a.request, *a.response)); 77 EXPECT_TRUE(v.Init(a.request, *a.response.get()));
78 78
79 EXPECT_FALSE(v.MatchesRequest(b.request, *b.response)); 79 EXPECT_FALSE(v.MatchesRequest(b.request, *b.response.get()));
80 } 80 }
81 81
82 TEST(HttpVaryDataTest, DoesVary2) { 82 TEST(HttpVaryDataTest, DoesVary2) {
83 TestTransaction a; 83 TestTransaction a;
84 a.Init("Foo: 1\r\nbar: 23", "HTTP/1.1 200 OK\nVary: foo, bar\n\n"); 84 a.Init("Foo: 1\r\nbar: 23", "HTTP/1.1 200 OK\nVary: foo, bar\n\n");
85 85
86 TestTransaction b; 86 TestTransaction b;
87 b.Init("Foo: 12\r\nbar: 3", "HTTP/1.1 200 OK\nVary: foo, bar\n\n"); 87 b.Init("Foo: 12\r\nbar: 3", "HTTP/1.1 200 OK\nVary: foo, bar\n\n");
88 88
89 net::HttpVaryData v; 89 net::HttpVaryData v;
90 EXPECT_TRUE(v.Init(a.request, *a.response)); 90 EXPECT_TRUE(v.Init(a.request, *a.response.get()));
91 91
92 EXPECT_FALSE(v.MatchesRequest(b.request, *b.response)); 92 EXPECT_FALSE(v.MatchesRequest(b.request, *b.response.get()));
93 } 93 }
94 94
95 TEST(HttpVaryDataTest, DoesntVary) { 95 TEST(HttpVaryDataTest, DoesntVary) {
96 TestTransaction a; 96 TestTransaction a;
97 a.Init("Foo: 1", "HTTP/1.1 200 OK\nVary: foo\n\n"); 97 a.Init("Foo: 1", "HTTP/1.1 200 OK\nVary: foo\n\n");
98 98
99 TestTransaction b; 99 TestTransaction b;
100 b.Init("Foo: 1", "HTTP/1.1 200 OK\nVary: foo\n\n"); 100 b.Init("Foo: 1", "HTTP/1.1 200 OK\nVary: foo\n\n");
101 101
102 net::HttpVaryData v; 102 net::HttpVaryData v;
103 EXPECT_TRUE(v.Init(a.request, *a.response)); 103 EXPECT_TRUE(v.Init(a.request, *a.response.get()));
104 104
105 EXPECT_TRUE(v.MatchesRequest(b.request, *b.response)); 105 EXPECT_TRUE(v.MatchesRequest(b.request, *b.response.get()));
106 } 106 }
107 107
108 TEST(HttpVaryDataTest, DoesntVary2) { 108 TEST(HttpVaryDataTest, DoesntVary2) {
109 TestTransaction a; 109 TestTransaction a;
110 a.Init("Foo: 1\r\nbAr: 2", "HTTP/1.1 200 OK\nVary: foo, bar\n\n"); 110 a.Init("Foo: 1\r\nbAr: 2", "HTTP/1.1 200 OK\nVary: foo, bar\n\n");
111 111
112 TestTransaction b; 112 TestTransaction b;
113 b.Init("Foo: 1\r\nbaR: 2", "HTTP/1.1 200 OK\nVary: foo\nVary: bar\n\n"); 113 b.Init("Foo: 1\r\nbaR: 2", "HTTP/1.1 200 OK\nVary: foo\nVary: bar\n\n");
114 114
115 net::HttpVaryData v; 115 net::HttpVaryData v;
116 EXPECT_TRUE(v.Init(a.request, *a.response)); 116 EXPECT_TRUE(v.Init(a.request, *a.response.get()));
117 117
118 EXPECT_TRUE(v.MatchesRequest(b.request, *b.response)); 118 EXPECT_TRUE(v.MatchesRequest(b.request, *b.response.get()));
119 } 119 }
120 120
121 TEST(HttpVaryDataTest, ImplicitCookieForRedirect) { 121 TEST(HttpVaryDataTest, ImplicitCookieForRedirect) {
122 TestTransaction a; 122 TestTransaction a;
123 a.Init("Cookie: 1", "HTTP/1.1 301 Moved\nLocation: x\n\n"); 123 a.Init("Cookie: 1", "HTTP/1.1 301 Moved\nLocation: x\n\n");
124 124
125 TestTransaction b; 125 TestTransaction b;
126 b.Init("Cookie: 2", "HTTP/1.1 301 Moved\nLocation: x\n\n"); 126 b.Init("Cookie: 2", "HTTP/1.1 301 Moved\nLocation: x\n\n");
127 127
128 net::HttpVaryData v; 128 net::HttpVaryData v;
129 EXPECT_TRUE(v.Init(a.request, *a.response)); 129 EXPECT_TRUE(v.Init(a.request, *a.response.get()));
130 130
131 EXPECT_FALSE(v.MatchesRequest(b.request, *b.response)); 131 EXPECT_FALSE(v.MatchesRequest(b.request, *b.response.get()));
132 } 132 }
133 133
134 TEST(HttpVaryDataTest, ImplicitCookieForRedirect2) { 134 TEST(HttpVaryDataTest, ImplicitCookieForRedirect2) {
135 // This should be no different than the test above 135 // This should be no different than the test above
136 136
137 TestTransaction a; 137 TestTransaction a;
138 a.Init("Cookie: 1", "HTTP/1.1 301 Moved\nLocation: x\nVary: coOkie\n\n"); 138 a.Init("Cookie: 1", "HTTP/1.1 301 Moved\nLocation: x\nVary: coOkie\n\n");
139 139
140 TestTransaction b; 140 TestTransaction b;
141 b.Init("Cookie: 2", "HTTP/1.1 301 Moved\nLocation: x\nVary: cooKie\n\n"); 141 b.Init("Cookie: 2", "HTTP/1.1 301 Moved\nLocation: x\nVary: cooKie\n\n");
142 142
143 net::HttpVaryData v; 143 net::HttpVaryData v;
144 EXPECT_TRUE(v.Init(a.request, *a.response)); 144 EXPECT_TRUE(v.Init(a.request, *a.response.get()));
145 145
146 EXPECT_FALSE(v.MatchesRequest(b.request, *b.response)); 146 EXPECT_FALSE(v.MatchesRequest(b.request, *b.response.get()));
147 } 147 }
OLDNEW
« no previous file with comments | « net/http/http_transaction_unittest.cc ('k') | net/http/mock_http_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698