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

Side by Side Diff: chrome/browser/renderer_host/resource_dispatcher_host_unittest.cc

Issue 6166010: net: Remove typedef net::URLRequestStatus URLRequestStatus; (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 11 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 | Annotate | Revision Log
OLDNEW
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 <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/browser_thread.h" 10 #include "chrome/browser/browser_thread.h"
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 389
390 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1()); 390 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1());
391 CheckSuccessfulRequest(msgs[2], net::URLRequestTestJob::test_data_3()); 391 CheckSuccessfulRequest(msgs[2], net::URLRequestTestJob::test_data_3());
392 392
393 // Check that request 2 got canceled. 393 // Check that request 2 got canceled.
394 ASSERT_EQ(2U, msgs[1].size()); 394 ASSERT_EQ(2U, msgs[1].size());
395 ASSERT_EQ(ViewMsg_Resource_ReceivedResponse::ID, msgs[1][0].type()); 395 ASSERT_EQ(ViewMsg_Resource_ReceivedResponse::ID, msgs[1][0].type());
396 ASSERT_EQ(ViewMsg_Resource_RequestComplete::ID, msgs[1][1].type()); 396 ASSERT_EQ(ViewMsg_Resource_RequestComplete::ID, msgs[1][1].type());
397 397
398 int request_id; 398 int request_id;
399 URLRequestStatus status; 399 net::URLRequestStatus status;
400 400
401 void* iter = NULL; 401 void* iter = NULL;
402 ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &request_id)); 402 ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &request_id));
403 ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &status)); 403 ASSERT_TRUE(IPC::ReadParam(&msgs[1][1], &iter, &status));
404 404
405 EXPECT_EQ(URLRequestStatus::CANCELED, status.status()); 405 EXPECT_EQ(net::URLRequestStatus::CANCELED, status.status());
406 } 406 }
407 407
408 // The host delegate acts as a second one so we can have some requests 408 // The host delegate acts as a second one so we can have some requests
409 // pending and some canceled. 409 // pending and some canceled.
410 class TestFilter : public ForwardingFilter { 410 class TestFilter : public ForwardingFilter {
411 public: 411 public:
412 TestFilter() 412 TestFilter()
413 : ForwardingFilter(NULL), 413 : ForwardingFilter(NULL),
414 has_canceled_(false), 414 has_canceled_(false),
415 received_after_canceled_(0) { 415 received_after_canceled_(0) {
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 // (kMaxRequests + 2) were failed, since the per-process bound was reached. 759 // (kMaxRequests + 2) were failed, since the per-process bound was reached.
760 for (int i = 0; i < 2; ++i) { 760 for (int i = 0; i < 2; ++i) {
761 // Should have sent a single RequestComplete message. 761 // Should have sent a single RequestComplete message.
762 int index = kMaxRequests + i; 762 int index = kMaxRequests + i;
763 EXPECT_EQ(1U, msgs[index].size()); 763 EXPECT_EQ(1U, msgs[index].size());
764 EXPECT_EQ(ViewMsg_Resource_RequestComplete::ID, msgs[index][0].type()); 764 EXPECT_EQ(ViewMsg_Resource_RequestComplete::ID, msgs[index][0].type());
765 765
766 // The RequestComplete message should have had status 766 // The RequestComplete message should have had status
767 // (CANCELLED, ERR_INSUFFICIENT_RESOURCES). 767 // (CANCELLED, ERR_INSUFFICIENT_RESOURCES).
768 int request_id; 768 int request_id;
769 URLRequestStatus status; 769 net::URLRequestStatus status;
770 770
771 void* iter = NULL; 771 void* iter = NULL;
772 EXPECT_TRUE(IPC::ReadParam(&msgs[index][0], &iter, &request_id)); 772 EXPECT_TRUE(IPC::ReadParam(&msgs[index][0], &iter, &request_id));
773 EXPECT_TRUE(IPC::ReadParam(&msgs[index][0], &iter, &status)); 773 EXPECT_TRUE(IPC::ReadParam(&msgs[index][0], &iter, &status));
774 774
775 EXPECT_EQ(index + 1, request_id); 775 EXPECT_EQ(index + 1, request_id);
776 EXPECT_EQ(URLRequestStatus::CANCELED, status.status()); 776 EXPECT_EQ(net::URLRequestStatus::CANCELED, status.status());
777 EXPECT_EQ(net::ERR_INSUFFICIENT_RESOURCES, status.os_error()); 777 EXPECT_EQ(net::ERR_INSUFFICIENT_RESOURCES, status.os_error());
778 } 778 }
779 779
780 // The final 2 requests should have succeeded. 780 // The final 2 requests should have succeeded.
781 CheckSuccessfulRequest(msgs[kMaxRequests + 2], 781 CheckSuccessfulRequest(msgs[kMaxRequests + 2],
782 net::URLRequestTestJob::test_data_2()); 782 net::URLRequestTestJob::test_data_2());
783 CheckSuccessfulRequest(msgs[kMaxRequests + 3], 783 CheckSuccessfulRequest(msgs[kMaxRequests + 3],
784 net::URLRequestTestJob::test_data_2()); 784 net::URLRequestTestJob::test_data_2());
785 } 785 }
786 786
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 ResourceIPCAccumulator::ClassifiedMessages msgs; 923 ResourceIPCAccumulator::ClassifiedMessages msgs;
924 accum_.GetClassifiedMessages(&msgs); 924 accum_.GetClassifiedMessages(&msgs);
925 925
926 // We should have gotten one RequestComplete message. 926 // We should have gotten one RequestComplete message.
927 ASSERT_EQ(1U, msgs[0].size()); 927 ASSERT_EQ(1U, msgs[0].size());
928 EXPECT_EQ(ViewMsg_Resource_RequestComplete::ID, msgs[0][0].type()); 928 EXPECT_EQ(ViewMsg_Resource_RequestComplete::ID, msgs[0][0].type());
929 929
930 // The RequestComplete message should have had status 930 // The RequestComplete message should have had status
931 // (CANCELED, ERR_FILE_NOT_FOUND). 931 // (CANCELED, ERR_FILE_NOT_FOUND).
932 int request_id; 932 int request_id;
933 URLRequestStatus status; 933 net::URLRequestStatus status;
934 934
935 void* iter = NULL; 935 void* iter = NULL;
936 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id)); 936 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id));
937 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &status)); 937 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &status));
938 938
939 EXPECT_EQ(1, request_id); 939 EXPECT_EQ(1, request_id);
940 EXPECT_EQ(URLRequestStatus::CANCELED, status.status()); 940 EXPECT_EQ(net::URLRequestStatus::CANCELED, status.status());
941 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, status.os_error()); 941 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, status.os_error());
942 } 942 }
943 943
944 class DummyResourceHandler : public ResourceHandler { 944 class DummyResourceHandler : public ResourceHandler {
945 public: 945 public:
946 DummyResourceHandler() {} 946 DummyResourceHandler() {}
947 947
948 // Called as upload progress is made. 948 // Called as upload progress is made.
949 bool OnUploadProgress(int request_id, uint64 position, uint64 size) { 949 bool OnUploadProgress(int request_id, uint64 position, uint64 size) {
950 return true; 950 return true;
(...skipping 13 matching lines...) Expand all
964 } 964 }
965 965
966 bool OnWillRead( 966 bool OnWillRead(
967 int request_id, net::IOBuffer** buf, int* buf_size, int min_size) { 967 int request_id, net::IOBuffer** buf, int* buf_size, int min_size) {
968 return true; 968 return true;
969 } 969 }
970 970
971 bool OnReadCompleted(int request_id, int* bytes_read) { return true; } 971 bool OnReadCompleted(int request_id, int* bytes_read) { return true; }
972 972
973 bool OnResponseCompleted( 973 bool OnResponseCompleted(
974 int request_id, const URLRequestStatus& status, const std::string& info) { 974 int request_id,
975 const net::URLRequestStatus& status,
976 const std::string& info) {
975 return true; 977 return true;
976 } 978 }
977 979
978 void OnRequestClosed() {} 980 void OnRequestClosed() {}
979 981
980 private: 982 private:
981 DISALLOW_COPY_AND_ASSIGN(DummyResourceHandler); 983 DISALLOW_COPY_AND_ASSIGN(DummyResourceHandler);
982 }; 984 };
983 985
984 class ApplyExtensionLocalizationFilterTest : public testing::Test { 986 class ApplyExtensionLocalizationFilterTest : public testing::Test {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 EXPECT_TRUE(request_info_->replace_extension_localization_templates()); 1021 EXPECT_TRUE(request_info_->replace_extension_localization_templates());
1020 } 1022 }
1021 1023
1022 TEST_F(ApplyExtensionLocalizationFilterTest, GoodSchemeWrongResourceType) { 1024 TEST_F(ApplyExtensionLocalizationFilterTest, GoodSchemeWrongResourceType) {
1023 resource_type_ = ResourceType::MAIN_FRAME; 1025 resource_type_ = ResourceType::MAIN_FRAME;
1024 ResourceDispatcherHost::ApplyExtensionLocalizationFilter(*url_, 1026 ResourceDispatcherHost::ApplyExtensionLocalizationFilter(*url_,
1025 resource_type_, request_info_.get()); 1027 resource_type_, request_info_.get());
1026 1028
1027 EXPECT_FALSE(request_info_->replace_extension_localization_templates()); 1029 EXPECT_FALSE(request_info_->replace_extension_localization_templates());
1028 } 1030 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/resource_dispatcher_host.cc ('k') | chrome/browser/renderer_host/resource_queue.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698