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

Side by Side Diff: net/url_request/url_request_simple_job_unittest.cc

Issue 2903213003: Do not use ScopedTaskEnvironment::RunUntilIdle() in URLRequestSimpleJobTest. (Closed)
Patch Set: 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 | « no previous file | 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 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/url_request/url_request_simple_job.h" 5 #include "net/url_request/url_request_simple_job.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/sequenced_task_runner.h" 14 #include "base/sequenced_task_runner.h"
15 #include "base/strings/string_piece.h" 15 #include "base/strings/string_piece.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "base/test/scoped_task_environment.h"
18 #include "net/base/request_priority.h" 17 #include "net/base/request_priority.h"
19 #include "net/test/gtest_util.h" 18 #include "net/test/gtest_util.h"
20 #include "net/test/net_test_suite.h"
21 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" 19 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h"
22 #include "net/url_request/url_request_job.h" 20 #include "net/url_request/url_request_job.h"
23 #include "net/url_request/url_request_job_factory.h" 21 #include "net/url_request/url_request_job_factory.h"
24 #include "net/url_request/url_request_job_factory_impl.h" 22 #include "net/url_request/url_request_job_factory_impl.h"
25 #include "net/url_request/url_request_test_util.h" 23 #include "net/url_request/url_request_test_util.h"
26 #include "testing/gmock/include/gmock/gmock.h" 24 #include "testing/gmock/include/gmock/gmock.h"
27 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
28 26
29 using net::test::IsError; 27 using net::test::IsError;
30 using net::test::IsOk; 28 using net::test::IsOk;
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 EXPECT_EQ(1, delegate_.response_started_count()); 210 EXPECT_EQ(1, delegate_.response_started_count());
213 } 211 }
214 212
215 TEST_F(URLRequestSimpleJobTest, CancelAfterFirstReadStarted) { 213 TEST_F(URLRequestSimpleJobTest, CancelAfterFirstReadStarted) {
216 CancelAfterFirstReadURLRequestDelegate cancel_delegate; 214 CancelAfterFirstReadURLRequestDelegate cancel_delegate;
217 request_ = 215 request_ =
218 context_.CreateRequest(GURL("data:cancel"), DEFAULT_PRIORITY, 216 context_.CreateRequest(GURL("data:cancel"), DEFAULT_PRIORITY,
219 &cancel_delegate, TRAFFIC_ANNOTATION_FOR_TESTS); 217 &cancel_delegate, TRAFFIC_ANNOTATION_FOR_TESTS);
220 request_->Start(); 218 request_->Start();
221 cancel_delegate.WaitUntilHeadersReceived(); 219 cancel_delegate.WaitUntilHeadersReceived();
222 220 base::RunLoop().RunUntilIdle();
223 // Run TaskScheduler tasks and their reply on the main thread.
224 NetTestSuite::GetScopedTaskEnvironment()->RunUntilIdle();
225 221
226 EXPECT_THAT(cancel_delegate.request_status(), IsError(ERR_ABORTED)); 222 EXPECT_THAT(cancel_delegate.request_status(), IsError(ERR_ABORTED));
227 EXPECT_EQ(1, cancel_delegate.response_started_count()); 223 EXPECT_EQ(1, cancel_delegate.response_started_count());
228 EXPECT_EQ("", cancel_delegate.data_received()); 224 EXPECT_EQ("", cancel_delegate.data_received());
229 // Destroy the request so it doesn't outlive its delegate. 225 // Destroy the request so it doesn't outlive its delegate.
230 request_.reset(); 226 request_.reset();
231 } 227 }
232 228
233 } // namespace net 229 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698