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

Side by Side Diff: chrome/browser/local_discovery/privet_url_fetcher_unittest.cc

Issue 215573003: Send an empty Privet token with /privet/info always (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | « chrome/browser/local_discovery/privet_url_fetcher.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "chrome/browser/local_discovery/privet_url_fetcher.h" 5 #include "chrome/browser/local_discovery/privet_url_fetcher.h"
6 #include "net/url_request/test_url_fetcher_factory.h" 6 #include "net/url_request/test_url_fetcher_factory.h"
7 #include "net/url_request/url_request_test_util.h" 7 #include "net/url_request/url_request_test_util.h"
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 202
203 std::string header_token; 203 std::string header_token;
204 ASSERT_TRUE(headers.GetHeader("X-Privet-Token", &header_token)); 204 ASSERT_TRUE(headers.GetHeader("X-Privet-Token", &header_token));
205 EXPECT_EQ(kSamplePrivetToken, header_token); 205 EXPECT_EQ(kSamplePrivetToken, header_token);
206 } 206 }
207 207
208 TEST_F(PrivetURLFetcherTest, Header2) { 208 TEST_F(PrivetURLFetcherTest, Header2) {
209 PrivetURLFetcher::SetTokenForHost(GURL(kSamplePrivetURL).GetOrigin().spec(), 209 PrivetURLFetcher::SetTokenForHost(GURL(kSamplePrivetURL).GetOrigin().spec(),
210 ""); 210 "");
211 211
212 privet_urlfetcher_->AllowEmptyPrivetToken(); 212 privet_urlfetcher_->SendEmptyPrivetToken();
213 privet_urlfetcher_->Start(); 213 privet_urlfetcher_->Start();
214 214
215 net::TestURLFetcher* fetcher = fetcher_factory_.GetFetcherByID(0); 215 net::TestURLFetcher* fetcher = fetcher_factory_.GetFetcherByID(0);
216 ASSERT_TRUE(fetcher != NULL);
217 net::HttpRequestHeaders headers;
218 fetcher->GetExtraRequestHeaders(&headers);
219
220 std::string header_token;
221 ASSERT_TRUE(headers.GetHeader("X-Privet-Token", &header_token));
222 EXPECT_EQ(kEmptyPrivetToken, header_token);
223 }
224
225 TEST_F(PrivetURLFetcherTest, AlwaysSendEmpty) {
226 PrivetURLFetcher::SetTokenForHost(GURL(kSamplePrivetURL).GetOrigin().spec(),
227 "SampleToken");
228
229 privet_urlfetcher_->SendEmptyPrivetToken();
230 privet_urlfetcher_->Start();
231
232 net::TestURLFetcher* fetcher = fetcher_factory_.GetFetcherByID(0);
216 ASSERT_TRUE(fetcher != NULL); 233 ASSERT_TRUE(fetcher != NULL);
217 net::HttpRequestHeaders headers; 234 net::HttpRequestHeaders headers;
218 fetcher->GetExtraRequestHeaders(&headers); 235 fetcher->GetExtraRequestHeaders(&headers);
219 236
220 std::string header_token; 237 std::string header_token;
221 ASSERT_TRUE(headers.GetHeader("X-Privet-Token", &header_token)); 238 ASSERT_TRUE(headers.GetHeader("X-Privet-Token", &header_token));
222 EXPECT_EQ(kEmptyPrivetToken, header_token); 239 EXPECT_EQ(kEmptyPrivetToken, header_token);
223 } 240 }
224 241
225 TEST_F(PrivetURLFetcherTest, FetchHasError) { 242 TEST_F(PrivetURLFetcherTest, FetchHasError) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 net::OK)); 292 net::OK));
276 fetcher->set_response_code(200); 293 fetcher->set_response_code(200);
277 294
278 EXPECT_CALL(delegate_, OnFileInternal()); 295 EXPECT_CALL(delegate_, OnFileInternal());
279 fetcher->delegate()->OnURLFetchComplete(fetcher); 296 fetcher->delegate()->OnURLFetchComplete(fetcher);
280 } 297 }
281 298
282 } // namespace 299 } // namespace
283 300
284 } // namespace local_discovery 301 } // namespace local_discovery
OLDNEW
« no previous file with comments | « chrome/browser/local_discovery/privet_url_fetcher.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698