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 TEST_F(URLFetcherTest, DifferentThreadsTest) { | 504 TEST_F(URLFetcherTest, FLAKY_DifferentThreadsTest) { |
505 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); | 505 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); |
506 ASSERT_TRUE(test_server.Start()); | 506 ASSERT_TRUE(test_server.Start()); |
507 | 507 |
508 // Create a separate thread that will create the URLFetcher. The current | 508 // 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 | 509 // (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 | 510 // 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 | 511 // message loop will be shut down automatically as the thread goes out of |
512 // scope. | 512 // scope. |
513 base::Thread t("URLFetcher test thread"); | 513 base::Thread t("URLFetcher test thread"); |
514 ASSERT_TRUE(t.Start()); | 514 ASSERT_TRUE(t.Start()); |
515 t.message_loop()->PostTask(FROM_HERE, new FetcherWrapperTask(this, | 515 t.message_loop()->PostTask(FROM_HERE, new FetcherWrapperTask(this, |
516 test_server.GetURL("defaultresponse"))); | 516 test_server.GetURL("defaultresponse"))); |
517 | 517 |
518 MessageLoop::current()->Run(); | 518 MessageLoop::current()->Run(); |
519 } | 519 } |
520 | 520 |
521 TEST_F(URLFetcherPostTest, Basic) { | 521 TEST_F(URLFetcherPostTest, FLAKY_Basic) { |
522 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); | 522 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); |
523 ASSERT_TRUE(test_server.Start()); | 523 ASSERT_TRUE(test_server.Start()); |
524 | 524 |
525 CreateFetcher(test_server.GetURL("echo")); | 525 CreateFetcher(test_server.GetURL("echo")); |
526 MessageLoop::current()->Run(); | 526 MessageLoop::current()->Run(); |
527 } | 527 } |
528 | 528 |
529 TEST_F(URLFetcherHeadersTest, Headers) { | 529 TEST_F(URLFetcherHeadersTest, Headers) { |
530 net::TestServer test_server(net::TestServer::TYPE_HTTP, | 530 net::TestServer test_server(net::TestServer::TYPE_HTTP, |
531 FilePath(FILE_PATH_LITERAL("net/data/url_request_unittest"))); | 531 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( | 595 net::URLRequestThrottlerManager::GetInstance()->OverrideEntryForTests( |
596 url, entry); | 596 url, entry); |
597 | 597 |
598 CreateFetcher(url); | 598 CreateFetcher(url); |
599 | 599 |
600 MessageLoop::current()->Run(); | 600 MessageLoop::current()->Run(); |
601 | 601 |
602 net::URLRequestThrottlerManager::GetInstance()->EraseEntryForTests(url); | 602 net::URLRequestThrottlerManager::GetInstance()->EraseEntryForTests(url); |
603 } | 603 } |
604 | 604 |
605 TEST_F(URLFetcherBadHTTPSTest, BadHTTPSTest) { | 605 TEST_F(URLFetcherBadHTTPSTest, FLAKY_BadHTTPSTest) { |
606 net::TestServer::HTTPSOptions https_options( | 606 net::TestServer::HTTPSOptions https_options( |
607 net::TestServer::HTTPSOptions::CERT_EXPIRED); | 607 net::TestServer::HTTPSOptions::CERT_EXPIRED); |
608 net::TestServer test_server(https_options, FilePath(kDocRoot)); | 608 net::TestServer test_server(https_options, FilePath(kDocRoot)); |
609 ASSERT_TRUE(test_server.Start()); | 609 ASSERT_TRUE(test_server.Start()); |
610 | 610 |
611 CreateFetcher(test_server.GetURL("defaultresponse")); | 611 CreateFetcher(test_server.GetURL("defaultresponse")); |
612 MessageLoop::current()->Run(); | 612 MessageLoop::current()->Run(); |
613 } | 613 } |
614 | 614 |
615 TEST_F(URLFetcherCancelTest, ReleasesContext) { | 615 TEST_F(URLFetcherCancelTest, FLAKY_ReleasesContext) { |
616 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); | 616 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); |
617 ASSERT_TRUE(test_server.Start()); | 617 ASSERT_TRUE(test_server.Start()); |
618 | 618 |
619 GURL url(test_server.GetURL("files/server-unavailable.html")); | 619 GURL url(test_server.GetURL("files/server-unavailable.html")); |
620 | 620 |
621 // Registers an entry for test url. The backoff time is calculated by: | 621 // Registers an entry for test url. The backoff time is calculated by: |
622 // new_backoff = 2.0 * old_backoff + 0 | 622 // new_backoff = 2.0 * old_backoff + 0 |
623 // The initial backoff is 2 seconds and maximum backoff is 4 seconds. | 623 // The initial backoff is 2 seconds and maximum backoff is 4 seconds. |
624 // Maximum retries allowed is set to 2. | 624 // Maximum retries allowed is set to 2. |
625 scoped_refptr<net::URLRequestThrottlerEntry> entry( | 625 scoped_refptr<net::URLRequestThrottlerEntry> entry( |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 | 676 |
677 // Create the fetcher on the main thread. Since IO will happen on the main | 677 // 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 | 678 // thread, this will test URLFetcher's ability to do everything on one |
679 // thread. | 679 // thread. |
680 CreateFetcher(test_server.GetURL("defaultresponse")); | 680 CreateFetcher(test_server.GetURL("defaultresponse")); |
681 | 681 |
682 MessageLoop::current()->Run(); | 682 MessageLoop::current()->Run(); |
683 } | 683 } |
684 | 684 |
685 } // namespace. | 685 } // namespace. |
OLD | NEW |