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

Side by Side Diff: content/browser/webui/url_data_manager_backend_unittest.cc

Issue 2262653003: Make URLRequest::Read to return net errors or bytes read instead of a bool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 3 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 | « no previous file | net/base/layered_network_delegate.h » ('j') | net/base/layered_network_delegate.h » ('J')
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 "content/browser/webui/url_data_manager_backend.h" 5 #include "content/browser/webui/url_data_manager_backend.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
11 #include "content/public/test/mock_resource_context.h" 11 #include "content/public/test/mock_resource_context.h"
12 #include "content/public/test/test_browser_thread_bundle.h" 12 #include "content/public/test/test_browser_thread_bundle.h"
13 #include "net/http/http_response_headers.h" 13 #include "net/http/http_response_headers.h"
14 #include "net/http/http_response_info.h" 14 #include "net/http/http_response_info.h"
15 #include "net/url_request/url_request_context.h" 15 #include "net/url_request/url_request_context.h"
16 #include "net/url_request/url_request_job.h" 16 #include "net/url_request/url_request_job.h"
17 #include "net/url_request/url_request_job_factory_impl.h" 17 #include "net/url_request/url_request_job_factory_impl.h"
18 #include "net/url_request/url_request_test_util.h" 18 #include "net/url_request/url_request_test_util.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 namespace content { 21 namespace content {
22 22
23 class CancelAfterFirstReadURLRequestDelegate : public net::TestDelegate { 23 class CancelAfterFirstReadURLRequestDelegate : public net::TestDelegate {
24 public: 24 public:
25 CancelAfterFirstReadURLRequestDelegate() {} 25 CancelAfterFirstReadURLRequestDelegate() {}
26 26
27 ~CancelAfterFirstReadURLRequestDelegate() override {} 27 ~CancelAfterFirstReadURLRequestDelegate() override {}
28 28
29 void OnResponseStarted(net::URLRequest* request) override { 29 void OnResponseStarted(net::URLRequest* request, int net_error) override {
30 // net::TestDelegate will start the first read. 30 // net::TestDelegate will start the first read.
31 TestDelegate::OnResponseStarted(request); 31 TestDelegate::OnResponseStarted(request, net_error);
32 request->Cancel(); 32 request->Cancel();
33 } 33 }
34 34
35 void OnReadCompleted(net::URLRequest* request, int bytes_read) override { 35 void OnReadCompleted(net::URLRequest* request, int bytes_read) override {
36 // Read should have been cancelled. 36 // Read should have been cancelled.
37 EXPECT_EQ(-1, bytes_read); 37 EXPECT_EQ(net::ERR_ABORTED, bytes_read);
38 } 38 }
39 39
40 private: 40 private:
41 DISALLOW_COPY_AND_ASSIGN(CancelAfterFirstReadURLRequestDelegate); 41 DISALLOW_COPY_AND_ASSIGN(CancelAfterFirstReadURLRequestDelegate);
42 }; 42 };
43 43
44 class UrlDataManagerBackendTest : public testing::Test { 44 class UrlDataManagerBackendTest : public testing::Test {
45 public: 45 public:
46 UrlDataManagerBackendTest() 46 UrlDataManagerBackendTest()
47 : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) { 47 : thread_bundle_(TestBrowserThreadBundle::IO_MAINLOOP) {
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 std::unique_ptr<net::URLRequest> error_request = 130 std::unique_ptr<net::URLRequest> error_request =
131 url_request_context_.CreateRequest( 131 url_request_context_.CreateRequest(
132 GURL("chrome://network-error/-123456789"), net::HIGHEST, &delegate_); 132 GURL("chrome://network-error/-123456789"), net::HIGHEST, &delegate_);
133 error_request->Start(); 133 error_request->Start();
134 base::RunLoop().Run(); 134 base::RunLoop().Run();
135 EXPECT_EQ(net::URLRequestStatus::FAILED, error_request->status().status()); 135 EXPECT_EQ(net::URLRequestStatus::FAILED, error_request->status().status());
136 EXPECT_EQ(net::ERR_INVALID_URL, error_request->status().error()); 136 EXPECT_EQ(net::ERR_INVALID_URL, error_request->status().error());
137 } 137 }
138 138
139 } // namespace content 139 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | net/base/layered_network_delegate.h » ('j') | net/base/layered_network_delegate.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698