Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/message_loop_proxy.h" | 5 #include "base/message_loop_proxy.h" |
| 6 #include "base/threading/thread.h" | 6 #include "base/threading/thread.h" |
| 7 #include "base/synchronization/waitable_event.h" | 7 #include "base/synchronization/waitable_event.h" |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 #include "chrome/common/chrome_plugin_lib.h" | 9 #include "chrome/common/chrome_plugin_lib.h" |
| 10 #include "chrome/common/net/url_fetcher.h" | 10 #include "chrome/common/net/url_fetcher.h" |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 494 ASSERT_TRUE(test_server.Start()); | 494 ASSERT_TRUE(test_server.Start()); |
| 495 | 495 |
| 496 // Create the fetcher on the main thread. Since IO will happen on the main | 496 // Create the fetcher on the main thread. Since IO will happen on the main |
| 497 // thread, this will test URLFetcher's ability to do everything on one | 497 // thread, this will test URLFetcher's ability to do everything on one |
| 498 // thread. | 498 // thread. |
| 499 CreateFetcher(test_server.GetURL("defaultresponse")); | 499 CreateFetcher(test_server.GetURL("defaultresponse")); |
| 500 | 500 |
| 501 MessageLoop::current()->Run(); | 501 MessageLoop::current()->Run(); |
| 502 } | 502 } |
| 503 | 503 |
| 504 #if !defined(OS_MACOSX) | |
|
Paweł Hajdan Jr.
2011/01/24 17:00:26
nit: I think it should be #if defined FLAKY #else
Denis Lagno
2011/01/24 17:27:10
Done. Though the other way round also has its rat
| |
| 505 TEST_F(URLFetcherTest, DifferentThreadsTest) { | |
| 506 #else | |
| 507 // SIGSEGV on Mac: http://crbug.com/70608 | |
| 504 TEST_F(URLFetcherTest, FLAKY_DifferentThreadsTest) { | 508 TEST_F(URLFetcherTest, FLAKY_DifferentThreadsTest) { |
| 509 #endif | |
| 505 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); | 510 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); |
| 506 ASSERT_TRUE(test_server.Start()); | 511 ASSERT_TRUE(test_server.Start()); |
| 507 | 512 |
| 508 // Create a separate thread that will create the URLFetcher. The current | 513 // Create a separate thread that will create the URLFetcher. The current |
| 509 // (main) thread will do the IO, and when the fetch is complete it will | 514 // (main) thread will do the IO, and when the fetch is complete it will |
| 510 // terminate the main thread's message loop; then the other thread's | 515 // terminate the main thread's message loop; then the other thread's |
| 511 // message loop will be shut down automatically as the thread goes out of | 516 // message loop will be shut down automatically as the thread goes out of |
| 512 // scope. | 517 // scope. |
| 513 base::Thread t("URLFetcher test thread"); | 518 base::Thread t("URLFetcher test thread"); |
| 514 ASSERT_TRUE(t.Start()); | 519 ASSERT_TRUE(t.Start()); |
| 515 t.message_loop()->PostTask(FROM_HERE, new FetcherWrapperTask(this, | 520 t.message_loop()->PostTask(FROM_HERE, new FetcherWrapperTask(this, |
| 516 test_server.GetURL("defaultresponse"))); | 521 test_server.GetURL("defaultresponse"))); |
| 517 | 522 |
| 518 MessageLoop::current()->Run(); | 523 MessageLoop::current()->Run(); |
| 519 } | 524 } |
| 520 | 525 |
| 526 #if !defined(OS_MACOSX) | |
| 527 TEST_F(URLFetcherPostTest, Basic) { | |
| 528 #else | |
| 529 // SIGSEGV on Mac: http://crbug.com/70608 | |
| 521 TEST_F(URLFetcherPostTest, FLAKY_Basic) { | 530 TEST_F(URLFetcherPostTest, FLAKY_Basic) { |
| 531 #endif | |
| 522 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); | 532 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); |
| 523 ASSERT_TRUE(test_server.Start()); | 533 ASSERT_TRUE(test_server.Start()); |
| 524 | 534 |
| 525 CreateFetcher(test_server.GetURL("echo")); | 535 CreateFetcher(test_server.GetURL("echo")); |
| 526 MessageLoop::current()->Run(); | 536 MessageLoop::current()->Run(); |
| 527 } | 537 } |
| 528 | 538 |
| 529 TEST_F(URLFetcherHeadersTest, Headers) { | 539 TEST_F(URLFetcherHeadersTest, Headers) { |
| 530 net::TestServer test_server(net::TestServer::TYPE_HTTP, | 540 net::TestServer test_server(net::TestServer::TYPE_HTTP, |
| 531 FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))); | 541 FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 595 net::URLRequestThrottlerManager::GetInstance()->OverrideEntryForTests( | 605 net::URLRequestThrottlerManager::GetInstance()->OverrideEntryForTests( |
| 596 url, entry); | 606 url, entry); |
| 597 | 607 |
| 598 CreateFetcher(url); | 608 CreateFetcher(url); |
| 599 | 609 |
| 600 MessageLoop::current()->Run(); | 610 MessageLoop::current()->Run(); |
| 601 | 611 |
| 602 net::URLRequestThrottlerManager::GetInstance()->EraseEntryForTests(url); | 612 net::URLRequestThrottlerManager::GetInstance()->EraseEntryForTests(url); |
| 603 } | 613 } |
| 604 | 614 |
| 615 #if !defined(OS_MACOSX) | |
| 616 TEST_F(URLFetcherBadHTTPSTest, BadHTTPSTest) { | |
| 617 #else | |
| 618 // SIGSEGV on Mac: http://crbug.com/70608 | |
| 605 TEST_F(URLFetcherBadHTTPSTest, FLAKY_BadHTTPSTest) { | 619 TEST_F(URLFetcherBadHTTPSTest, FLAKY_BadHTTPSTest) { |
| 620 #endif | |
| 606 net::TestServer::HTTPSOptions https_options( | 621 net::TestServer::HTTPSOptions https_options( |
| 607 net::TestServer::HTTPSOptions::CERT_EXPIRED); | 622 net::TestServer::HTTPSOptions::CERT_EXPIRED); |
| 608 net::TestServer test_server(https_options, FilePath(kDocRoot)); | 623 net::TestServer test_server(https_options, FilePath(kDocRoot)); |
| 609 ASSERT_TRUE(test_server.Start()); | 624 ASSERT_TRUE(test_server.Start()); |
| 610 | 625 |
| 611 CreateFetcher(test_server.GetURL("defaultresponse")); | 626 CreateFetcher(test_server.GetURL("defaultresponse")); |
| 612 MessageLoop::current()->Run(); | 627 MessageLoop::current()->Run(); |
| 613 } | 628 } |
| 614 | 629 |
| 630 #if !defined(OS_MACOSX) | |
| 631 TEST_F(URLFetcherCancelTest, ReleasesContext) { | |
| 632 #else | |
| 633 // SIGSEGV on Mac: http://crbug.com/70608 | |
| 615 TEST_F(URLFetcherCancelTest, FLAKY_ReleasesContext) { | 634 TEST_F(URLFetcherCancelTest, FLAKY_ReleasesContext) { |
| 635 #endif | |
| 616 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); | 636 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); |
| 617 ASSERT_TRUE(test_server.Start()); | 637 ASSERT_TRUE(test_server.Start()); |
| 618 | 638 |
| 619 GURL url(test_server.GetURL("files/server-unavailable.html")); | 639 GURL url(test_server.GetURL("files/server-unavailable.html")); |
| 620 | 640 |
| 621 // Registers an entry for test url. The backoff time is calculated by: | 641 // Registers an entry for test url. The backoff time is calculated by: |
| 622 // new_backoff = 2.0 * old_backoff + 0 | 642 // new_backoff = 2.0 * old_backoff + 0 |
| 623 // The initial backoff is 2 seconds and maximum backoff is 4 seconds. | 643 // The initial backoff is 2 seconds and maximum backoff is 4 seconds. |
| 624 // Maximum retries allowed is set to 2. | 644 // Maximum retries allowed is set to 2. |
| 625 scoped_refptr<net::URLRequestThrottlerEntry> entry( | 645 scoped_refptr<net::URLRequestThrottlerEntry> entry( |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 676 | 696 |
| 677 // Create the fetcher on the main thread. Since IO will happen on the main | 697 // Create the fetcher on the main thread. Since IO will happen on the main |
| 678 // thread, this will test URLFetcher's ability to do everything on one | 698 // thread, this will test URLFetcher's ability to do everything on one |
| 679 // thread. | 699 // thread. |
| 680 CreateFetcher(test_server.GetURL("defaultresponse")); | 700 CreateFetcher(test_server.GetURL("defaultresponse")); |
| 681 | 701 |
| 682 MessageLoop::current()->Run(); | 702 MessageLoop::current()->Run(); |
| 683 } | 703 } |
| 684 | 704 |
| 685 } // namespace. | 705 } // namespace. |
| OLD | NEW |