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

Side by Side Diff: net/base/layered_network_delegate_unittest.cc

Issue 2786583002: chromeos: Check both original and absolute paths for file: scheme (Closed)
Patch Set: remove dcheck Created 3 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
« no previous file with comments | « net/base/layered_network_delegate.cc ('k') | net/base/network_delegate.h » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/base/layered_network_delegate.h" 5 #include "net/base/layered_network_delegate.h"
6 6
7 #include <map> 7 #include <map>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 } 121 }
122 122
123 bool OnCanSetCookie(const URLRequest& request, 123 bool OnCanSetCookie(const URLRequest& request,
124 const std::string& cookie_line, 124 const std::string& cookie_line,
125 CookieOptions* options) override { 125 CookieOptions* options) override {
126 IncrementAndCompareCounter("on_can_set_cookie_count"); 126 IncrementAndCompareCounter("on_can_set_cookie_count");
127 return false; 127 return false;
128 } 128 }
129 129
130 bool OnCanAccessFile(const URLRequest& request, 130 bool OnCanAccessFile(const URLRequest& request,
131 const base::FilePath& path) const override { 131 const base::FilePath& original_path,
132 const base::FilePath& absolute_path) const override {
132 IncrementAndCompareCounter("on_can_access_file_count"); 133 IncrementAndCompareCounter("on_can_access_file_count");
133 return false; 134 return false;
134 } 135 }
135 136
136 bool OnCanEnablePrivacyMode( 137 bool OnCanEnablePrivacyMode(
137 const GURL& url, 138 const GURL& url,
138 const GURL& first_party_for_cookies) const override { 139 const GURL& first_party_for_cookies) const override {
139 IncrementAndCompareCounter("on_can_enable_privacy_mode_count"); 140 IncrementAndCompareCounter("on_can_enable_privacy_mode_count");
140 return false; 141 return false;
141 } 142 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 OnResponseStarted(request.get(), net::OK); 199 OnResponseStarted(request.get(), net::OK);
199 OnNetworkBytesReceived(request.get(), 42); 200 OnNetworkBytesReceived(request.get(), 42);
200 OnCompleted(request.get(), false, net::OK); 201 OnCompleted(request.get(), false, net::OK);
201 OnURLRequestDestroyed(request.get()); 202 OnURLRequestDestroyed(request.get());
202 OnPACScriptError(0, base::string16()); 203 OnPACScriptError(0, base::string16());
203 EXPECT_EQ( 204 EXPECT_EQ(
204 NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION, 205 NetworkDelegate::AUTH_REQUIRED_RESPONSE_NO_ACTION,
205 OnAuthRequired(request.get(), *auth_challenge, AuthCallback(), NULL)); 206 OnAuthRequired(request.get(), *auth_challenge, AuthCallback(), NULL));
206 EXPECT_FALSE(OnCanGetCookies(*request, CookieList())); 207 EXPECT_FALSE(OnCanGetCookies(*request, CookieList()));
207 EXPECT_FALSE(OnCanSetCookie(*request, std::string(), NULL)); 208 EXPECT_FALSE(OnCanSetCookie(*request, std::string(), NULL));
208 EXPECT_FALSE(OnCanAccessFile(*request, base::FilePath())); 209 EXPECT_FALSE(OnCanAccessFile(*request, base::FilePath(), base::FilePath()));
209 EXPECT_FALSE(OnCanEnablePrivacyMode(GURL(), GURL())); 210 EXPECT_FALSE(OnCanEnablePrivacyMode(GURL(), GURL()));
210 EXPECT_FALSE(OnCancelURLRequestWithPolicyViolatingReferrerHeader( 211 EXPECT_FALSE(OnCancelURLRequestWithPolicyViolatingReferrerHeader(
211 *request, GURL(), GURL())); 212 *request, GURL(), GURL()));
212 } 213 }
213 214
214 protected: 215 protected:
215 void OnBeforeURLRequestInternal(URLRequest* request, 216 void OnBeforeURLRequestInternal(URLRequest* request,
216 const CompletionCallback& callback, 217 const CompletionCallback& callback,
217 GURL* new_url) override { 218 GURL* new_url) override {
218 ++(*counters_)["on_before_url_request_count"]; 219 ++(*counters_)["on_before_url_request_count"];
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 EXPECT_EQ(1, (*counters_)["on_can_get_cookies_count"]); 304 EXPECT_EQ(1, (*counters_)["on_can_get_cookies_count"]);
304 } 305 }
305 306
306 void OnCanSetCookieInternal(const URLRequest& request, 307 void OnCanSetCookieInternal(const URLRequest& request,
307 const std::string& cookie_line, 308 const std::string& cookie_line,
308 CookieOptions* options) override { 309 CookieOptions* options) override {
309 ++(*counters_)["on_can_set_cookie_count"]; 310 ++(*counters_)["on_can_set_cookie_count"];
310 EXPECT_EQ(1, (*counters_)["on_can_set_cookie_count"]); 311 EXPECT_EQ(1, (*counters_)["on_can_set_cookie_count"]);
311 } 312 }
312 313
313 void OnCanAccessFileInternal(const URLRequest& request, 314 void OnCanAccessFileInternal(
314 const base::FilePath& path) const override { 315 const URLRequest& request,
316 const base::FilePath& original_path,
317 const base::FilePath& absolute_path) const override {
315 ++(*counters_)["on_can_access_file_count"]; 318 ++(*counters_)["on_can_access_file_count"];
316 EXPECT_EQ(1, (*counters_)["on_can_access_file_count"]); 319 EXPECT_EQ(1, (*counters_)["on_can_access_file_count"]);
317 } 320 }
318 321
319 void OnCanEnablePrivacyModeInternal( 322 void OnCanEnablePrivacyModeInternal(
320 const GURL& url, 323 const GURL& url,
321 const GURL& first_party_for_cookies) const override { 324 const GURL& first_party_for_cookies) const override {
322 ++(*counters_)["on_can_enable_privacy_mode_count"]; 325 ++(*counters_)["on_can_enable_privacy_mode_count"];
323 EXPECT_EQ(1, (*counters_)["on_can_enable_privacy_mode_count"]); 326 EXPECT_EQ(1, (*counters_)["on_can_enable_privacy_mode_count"]);
324 } 327 }
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 CountersMap layered_network_delegate_counters; 386 CountersMap layered_network_delegate_counters;
384 TestNetworkDelegateImpl* test_network_delegate_; 387 TestNetworkDelegateImpl* test_network_delegate_;
385 std::unique_ptr<TestLayeredNetworkDelegate> layered_network_delegate_; 388 std::unique_ptr<TestLayeredNetworkDelegate> layered_network_delegate_;
386 }; 389 };
387 390
388 TEST_F(LayeredNetworkDelegateTest, VerifyLayeredNetworkDelegateInternal) { 391 TEST_F(LayeredNetworkDelegateTest, VerifyLayeredNetworkDelegateInternal) {
389 layered_network_delegate_->CallAndVerify(); 392 layered_network_delegate_->CallAndVerify();
390 } 393 }
391 394
392 } // namespace net 395 } // namespace net
OLDNEW
« no previous file with comments | « net/base/layered_network_delegate.cc ('k') | net/base/network_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698