| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "chrome/browser/child_process_security_policy.h" | 10 #include "chrome/browser/child_process_security_policy.h" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 ASSERT_EQ(0, memcmp(reference_data.c_str(), data, data_len)); | 313 ASSERT_EQ(0, memcmp(reference_data.c_str(), data, data_len)); |
| 314 | 314 |
| 315 // followed by a 0-byte read | 315 // followed by a 0-byte read |
| 316 //ASSERT_EQ(ViewMsg_Resource_DataReceived::ID, messages[2].type()); | 316 //ASSERT_EQ(ViewMsg_Resource_DataReceived::ID, messages[2].type()); |
| 317 | 317 |
| 318 // the last message should be all data received | 318 // the last message should be all data received |
| 319 ASSERT_EQ(ViewMsg_Resource_RequestComplete::ID, messages[2].type()); | 319 ASSERT_EQ(ViewMsg_Resource_RequestComplete::ID, messages[2].type()); |
| 320 } | 320 } |
| 321 | 321 |
| 322 // Tests whether many messages get dispatched properly. | 322 // Tests whether many messages get dispatched properly. |
| 323 // TODO(jorlow): Re-enable once bug 28364 is fixed. | 323 TEST_F(ResourceDispatcherHostTest, TestMany) { |
| 324 TEST_F(ResourceDispatcherHostTest, DISABLED_TestMany) { | |
| 325 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); | 324 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); |
| 326 | 325 |
| 327 MakeTestRequest(0, 1, URLRequestTestJob::test_url_1()); | 326 MakeTestRequest(0, 1, URLRequestTestJob::test_url_1()); |
| 328 MakeTestRequest(0, 2, URLRequestTestJob::test_url_2()); | 327 MakeTestRequest(0, 2, URLRequestTestJob::test_url_2()); |
| 329 MakeTestRequest(0, 3, URLRequestTestJob::test_url_3()); | 328 MakeTestRequest(0, 3, URLRequestTestJob::test_url_3()); |
| 330 | 329 |
| 331 // flush all the pending requests | 330 // flush all the pending requests |
| 332 while (URLRequestTestJob::ProcessOnePendingMessage()); | 331 while (URLRequestTestJob::ProcessOnePendingMessage()); |
| 333 | 332 |
| 334 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); | 333 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); |
| 335 | 334 |
| 336 // sorts out all the messages we saw by request | 335 // sorts out all the messages we saw by request |
| 337 ResourceIPCAccumulator::ClassifiedMessages msgs; | 336 ResourceIPCAccumulator::ClassifiedMessages msgs; |
| 338 accum_.GetClassifiedMessages(&msgs); | 337 accum_.GetClassifiedMessages(&msgs); |
| 339 | 338 |
| 340 // there are three requests, so we should have gotten them classified as such | 339 // there are three requests, so we should have gotten them classified as such |
| 341 ASSERT_EQ(3U, msgs.size()); | 340 ASSERT_EQ(3U, msgs.size()); |
| 342 | 341 |
| 343 CheckSuccessfulRequest(msgs[0], URLRequestTestJob::test_data_1()); | 342 CheckSuccessfulRequest(msgs[0], URLRequestTestJob::test_data_1()); |
| 344 CheckSuccessfulRequest(msgs[1], URLRequestTestJob::test_data_2()); | 343 CheckSuccessfulRequest(msgs[1], URLRequestTestJob::test_data_2()); |
| 345 CheckSuccessfulRequest(msgs[2], URLRequestTestJob::test_data_3()); | 344 CheckSuccessfulRequest(msgs[2], URLRequestTestJob::test_data_3()); |
| 346 } | 345 } |
| 347 | 346 |
| 348 // Tests whether messages get canceled properly. We issue three requests, | 347 // Tests whether messages get canceled properly. We issue three requests, |
| 349 // cancel one of them, and make sure that each sent the proper notifications. | 348 // cancel one of them, and make sure that each sent the proper notifications. |
| 350 // TODO(jorlow): Re-enable once bug 28364 is fixed. | 349 TEST_F(ResourceDispatcherHostTest, Cancel) { |
| 351 TEST_F(ResourceDispatcherHostTest, DISABLED_Cancel) { | |
| 352 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); | 350 EXPECT_EQ(0, host_.GetOutstandingRequestsMemoryCost(0)); |
| 353 | 351 |
| 354 MakeTestRequest(0, 1, URLRequestTestJob::test_url_1()); | 352 MakeTestRequest(0, 1, URLRequestTestJob::test_url_1()); |
| 355 MakeTestRequest(0, 2, URLRequestTestJob::test_url_2()); | 353 MakeTestRequest(0, 2, URLRequestTestJob::test_url_2()); |
| 356 MakeTestRequest(0, 3, URLRequestTestJob::test_url_3()); | 354 MakeTestRequest(0, 3, URLRequestTestJob::test_url_3()); |
| 357 MakeCancelRequest(2); | 355 MakeCancelRequest(2); |
| 358 | 356 |
| 359 // flush all the pending requests | 357 // flush all the pending requests |
| 360 while (URLRequestTestJob::ProcessOnePendingMessage()); | 358 while (URLRequestTestJob::ProcessOnePendingMessage()); |
| 361 MessageLoop::current()->RunAllPending(); | 359 MessageLoop::current()->RunAllPending(); |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 CheckSuccessfulRequest(msgs[0], URLRequestTestJob::test_data_1()); | 599 CheckSuccessfulRequest(msgs[0], URLRequestTestJob::test_data_1()); |
| 602 CheckSuccessfulRequest(msgs[1], URLRequestTestJob::test_data_3()); | 600 CheckSuccessfulRequest(msgs[1], URLRequestTestJob::test_data_3()); |
| 603 | 601 |
| 604 EXPECT_TRUE(host_.blocked_requests_map_.empty()); | 602 EXPECT_TRUE(host_.blocked_requests_map_.empty()); |
| 605 } | 603 } |
| 606 | 604 |
| 607 // Tests that blocked requests don't leak when the ResourceDispatcherHost goes | 605 // Tests that blocked requests don't leak when the ResourceDispatcherHost goes |
| 608 // away. Note that we rely on Purify for finding the leaks if any. | 606 // away. Note that we rely on Purify for finding the leaks if any. |
| 609 // If this test turns the Purify bot red, check the ResourceDispatcherHost | 607 // If this test turns the Purify bot red, check the ResourceDispatcherHost |
| 610 // destructor to make sure the blocked requests are deleted. | 608 // destructor to make sure the blocked requests are deleted. |
| 611 // TODO(jorlow): Re-enable once bug 28364 is fixed. | 609 TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsDontLeak) { |
| 612 TEST_F(ResourceDispatcherHostTest, DISABLED_TestBlockedRequestsDontLeak) { | |
| 613 // This second receiver is used to emulate a second process. | 610 // This second receiver is used to emulate a second process. |
| 614 ForwardingReceiver second_receiver(this); | 611 ForwardingReceiver second_receiver(this); |
| 615 | 612 |
| 616 host_.BlockRequestsForRoute(id(), 1); | 613 host_.BlockRequestsForRoute(id(), 1); |
| 617 host_.BlockRequestsForRoute(id(), 2); | 614 host_.BlockRequestsForRoute(id(), 2); |
| 618 host_.BlockRequestsForRoute(second_receiver.id(), 1); | 615 host_.BlockRequestsForRoute(second_receiver.id(), 1); |
| 619 | 616 |
| 620 MakeTestRequest(this, 0, 1, URLRequestTestJob::test_url_1()); | 617 MakeTestRequest(this, 0, 1, URLRequestTestJob::test_url_1()); |
| 621 MakeTestRequest(this, 1, 2, URLRequestTestJob::test_url_2()); | 618 MakeTestRequest(this, 1, 2, URLRequestTestJob::test_url_2()); |
| 622 MakeTestRequest(this, 0, 3, URLRequestTestJob::test_url_3()); | 619 MakeTestRequest(this, 0, 3, URLRequestTestJob::test_url_3()); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 | 871 |
| 875 // Sorts out all the messages we saw by request. | 872 // Sorts out all the messages we saw by request. |
| 876 ResourceIPCAccumulator::ClassifiedMessages msgs; | 873 ResourceIPCAccumulator::ClassifiedMessages msgs; |
| 877 accum_.GetClassifiedMessages(&msgs); | 874 accum_.GetClassifiedMessages(&msgs); |
| 878 ASSERT_EQ(1U, msgs.size()); | 875 ASSERT_EQ(1U, msgs.size()); |
| 879 | 876 |
| 880 ResourceResponseHead response_head; | 877 ResourceResponseHead response_head; |
| 881 GetResponseHead(msgs[0], &response_head); | 878 GetResponseHead(msgs[0], &response_head); |
| 882 ASSERT_EQ("text/plain", response_head.mime_type); | 879 ASSERT_EQ("text/plain", response_head.mime_type); |
| 883 } | 880 } |
| OLD | NEW |