| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_fetcher_impl.h" | 5 #include "net/url_request/url_fetcher_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 std::string data; | 517 std::string data; |
| 518 ASSERT_TRUE(delegate.fetcher()->GetResponseAsString(&data)); | 518 ASSERT_TRUE(delegate.fetcher()->GetResponseAsString(&data)); |
| 519 EXPECT_EQ(kDefaultResponseBody, data); | 519 EXPECT_EQ(kDefaultResponseBody, data); |
| 520 } | 520 } |
| 521 | 521 |
| 522 // Create the fetcher from a sequenced (not single-threaded) task. Verify that | 522 // Create the fetcher from a sequenced (not single-threaded) task. Verify that |
| 523 // the expected response is received. | 523 // the expected response is received. |
| 524 TEST_F(URLFetcherTest, SequencedTaskTest) { | 524 TEST_F(URLFetcherTest, SequencedTaskTest) { |
| 525 base::test::ScopedTaskScheduler scoped_task_scheduler( | 525 base::test::ScopedTaskScheduler scoped_task_scheduler( |
| 526 base::MessageLoop::current()); | 526 base::MessageLoop::current()); |
| 527 auto sequenced_task_runner = | 527 auto sequenced_task_runner = base::CreateSequencedTaskRunnerWithTraits({}); |
| 528 base::CreateSequencedTaskRunnerWithTraits(base::TaskTraits()); | |
| 529 | 528 |
| 530 auto delegate = base::MakeUnique<WaitingURLFetcherDelegate>(); | 529 auto delegate = base::MakeUnique<WaitingURLFetcherDelegate>(); |
| 531 sequenced_task_runner->PostTask( | 530 sequenced_task_runner->PostTask( |
| 532 FROM_HERE, base::Bind(&WaitingURLFetcherDelegate::CreateFetcher, | 531 FROM_HERE, base::Bind(&WaitingURLFetcherDelegate::CreateFetcher, |
| 533 base::Unretained(delegate.get()), | 532 base::Unretained(delegate.get()), |
| 534 test_server_->GetURL(kDefaultResponsePath), | 533 test_server_->GetURL(kDefaultResponsePath), |
| 535 URLFetcher::GET, CreateCrossThreadContextGetter())); | 534 URLFetcher::GET, CreateCrossThreadContextGetter())); |
| 536 base::RunLoop().RunUntilIdle(); | 535 base::RunLoop().RunUntilIdle(); |
| 537 delegate->StartFetcherAndWait(); | 536 delegate->StartFetcherAndWait(); |
| 538 | 537 |
| (...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1570 EXPECT_EQ(-1, delegate.fetcher()->GetResponseCode()); | 1569 EXPECT_EQ(-1, delegate.fetcher()->GetResponseCode()); |
| 1571 EXPECT_FALSE(delegate.fetcher()->GetResponseHeaders()); | 1570 EXPECT_FALSE(delegate.fetcher()->GetResponseHeaders()); |
| 1572 std::string data; | 1571 std::string data; |
| 1573 EXPECT_TRUE(delegate.fetcher()->GetResponseAsString(&data)); | 1572 EXPECT_TRUE(delegate.fetcher()->GetResponseAsString(&data)); |
| 1574 EXPECT_TRUE(data.empty()); | 1573 EXPECT_TRUE(data.empty()); |
| 1575 } | 1574 } |
| 1576 | 1575 |
| 1577 } // namespace | 1576 } // namespace |
| 1578 | 1577 |
| 1579 } // namespace net | 1578 } // namespace net |
| OLD | NEW |