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

Side by Side Diff: content/child/resource_dispatcher_unittest.cc

Issue 517853004: Move ResourceResponseHead::error_code to SyncLoadResult. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « content/browser/loader/resource_loader.cc ('k') | content/common/resource_messages.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 &message_queue_[0], &args)); 243 &message_queue_[0], &args));
244 EXPECT_EQ(expected_request_id, args.a); 244 EXPECT_EQ(expected_request_id, args.a);
245 message_queue_.erase(message_queue_.begin()); 245 message_queue_.erase(message_queue_.begin());
246 } 246 }
247 247
248 void NotifyReceivedRedirect(int request_id) { 248 void NotifyReceivedRedirect(int request_id) {
249 ResourceResponseHead head; 249 ResourceResponseHead head;
250 std::string raw_headers(kTestRedirectHeaders); 250 std::string raw_headers(kTestRedirectHeaders);
251 std::replace(raw_headers.begin(), raw_headers.end(), '\n', '\0'); 251 std::replace(raw_headers.begin(), raw_headers.end(), '\n', '\0');
252 head.headers = new net::HttpResponseHeaders(raw_headers); 252 head.headers = new net::HttpResponseHeaders(raw_headers);
253 head.error_code = net::OK;
254 net::RedirectInfo redirect_info; 253 net::RedirectInfo redirect_info;
255 redirect_info.status_code = 302; 254 redirect_info.status_code = 302;
256 redirect_info.new_method = "GET"; 255 redirect_info.new_method = "GET";
257 redirect_info.new_url = GURL(kTestPageUrl); 256 redirect_info.new_url = GURL(kTestPageUrl);
258 redirect_info.new_first_party_for_cookies = GURL(kTestPageUrl); 257 redirect_info.new_first_party_for_cookies = GURL(kTestPageUrl);
259 EXPECT_EQ(true, dispatcher_.OnMessageReceived( 258 EXPECT_EQ(true, dispatcher_.OnMessageReceived(
260 ResourceMsg_ReceivedRedirect(request_id, redirect_info, head))); 259 ResourceMsg_ReceivedRedirect(request_id, redirect_info, head)));
261 } 260 }
262 261
263 void NotifyReceivedResponse(int request_id) { 262 void NotifyReceivedResponse(int request_id) {
264 ResourceResponseHead head; 263 ResourceResponseHead head;
265 std::string raw_headers(kTestPageHeaders); 264 std::string raw_headers(kTestPageHeaders);
266 std::replace(raw_headers.begin(), raw_headers.end(), '\n', '\0'); 265 std::replace(raw_headers.begin(), raw_headers.end(), '\n', '\0');
267 head.headers = new net::HttpResponseHeaders(raw_headers); 266 head.headers = new net::HttpResponseHeaders(raw_headers);
268 head.mime_type = kTestPageMimeType; 267 head.mime_type = kTestPageMimeType;
269 head.charset = kTestPageCharset; 268 head.charset = kTestPageCharset;
270 head.error_code = net::OK;
271 EXPECT_EQ(true, 269 EXPECT_EQ(true,
272 dispatcher_.OnMessageReceived( 270 dispatcher_.OnMessageReceived(
273 ResourceMsg_ReceivedResponse(request_id, head))); 271 ResourceMsg_ReceivedResponse(request_id, head)));
274 } 272 }
275 273
276 void NotifySetDataBuffer(int request_id, size_t buffer_size) { 274 void NotifySetDataBuffer(int request_id, size_t buffer_size) {
277 base::SharedMemory* shared_memory = new base::SharedMemory(); 275 base::SharedMemory* shared_memory = new base::SharedMemory();
278 ASSERT_FALSE(shared_memory_map_[request_id]); 276 ASSERT_FALSE(shared_memory_map_[request_id]);
279 shared_memory_map_[request_id] = shared_memory; 277 shared_memory_map_[request_id] = shared_memory;
280 EXPECT_TRUE(shared_memory->CreateAndMapAnonymous(buffer_size)); 278 EXPECT_TRUE(shared_memory->CreateAndMapAnonymous(buffer_size));
(...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after
753 751
754 const ResourceResponseInfo& response_info() const { return response_info_; } 752 const ResourceResponseInfo& response_info() const { return response_info_; }
755 753
756 private: 754 private:
757 ResourceResponseInfo response_info_; 755 ResourceResponseInfo response_info_;
758 }; 756 };
759 757
760 // TODO(simonjam): Enable this when 10829031 lands. 758 // TODO(simonjam): Enable this when 10829031 lands.
761 TEST_F(TimeConversionTest, DISABLED_ProperlyInitialized) { 759 TEST_F(TimeConversionTest, DISABLED_ProperlyInitialized) {
762 ResourceResponseHead response_head; 760 ResourceResponseHead response_head;
763 response_head.error_code = net::OK;
764 response_head.request_start = base::TimeTicks::FromInternalValue(5); 761 response_head.request_start = base::TimeTicks::FromInternalValue(5);
765 response_head.response_start = base::TimeTicks::FromInternalValue(15); 762 response_head.response_start = base::TimeTicks::FromInternalValue(15);
766 response_head.load_timing.request_start_time = base::Time::Now(); 763 response_head.load_timing.request_start_time = base::Time::Now();
767 response_head.load_timing.request_start = 764 response_head.load_timing.request_start =
768 base::TimeTicks::FromInternalValue(10); 765 base::TimeTicks::FromInternalValue(10);
769 response_head.load_timing.connect_timing.connect_start = 766 response_head.load_timing.connect_timing.connect_start =
770 base::TimeTicks::FromInternalValue(13); 767 base::TimeTicks::FromInternalValue(13);
771 768
772 PerformTest(response_head); 769 PerformTest(response_head);
773 770
774 EXPECT_LT(base::TimeTicks(), response_info().load_timing.request_start); 771 EXPECT_LT(base::TimeTicks(), response_info().load_timing.request_start);
775 EXPECT_EQ(base::TimeTicks(), 772 EXPECT_EQ(base::TimeTicks(),
776 response_info().load_timing.connect_timing.dns_start); 773 response_info().load_timing.connect_timing.dns_start);
777 EXPECT_LE(response_head.load_timing.request_start, 774 EXPECT_LE(response_head.load_timing.request_start,
778 response_info().load_timing.connect_timing.connect_start); 775 response_info().load_timing.connect_timing.connect_start);
779 } 776 }
780 777
781 TEST_F(TimeConversionTest, PartiallyInitialized) { 778 TEST_F(TimeConversionTest, PartiallyInitialized) {
782 ResourceResponseHead response_head; 779 ResourceResponseHead response_head;
783 response_head.error_code = net::OK;
784 response_head.request_start = base::TimeTicks::FromInternalValue(5); 780 response_head.request_start = base::TimeTicks::FromInternalValue(5);
785 response_head.response_start = base::TimeTicks::FromInternalValue(15); 781 response_head.response_start = base::TimeTicks::FromInternalValue(15);
786 782
787 PerformTest(response_head); 783 PerformTest(response_head);
788 784
789 EXPECT_EQ(base::TimeTicks(), response_info().load_timing.request_start); 785 EXPECT_EQ(base::TimeTicks(), response_info().load_timing.request_start);
790 EXPECT_EQ(base::TimeTicks(), 786 EXPECT_EQ(base::TimeTicks(),
791 response_info().load_timing.connect_timing.dns_start); 787 response_info().load_timing.connect_timing.dns_start);
792 } 788 }
793 789
794 TEST_F(TimeConversionTest, NotInitialized) { 790 TEST_F(TimeConversionTest, NotInitialized) {
795 ResourceResponseHead response_head; 791 ResourceResponseHead response_head;
796 response_head.error_code = net::OK;
797 792
798 PerformTest(response_head); 793 PerformTest(response_head);
799 794
800 EXPECT_EQ(base::TimeTicks(), response_info().load_timing.request_start); 795 EXPECT_EQ(base::TimeTicks(), response_info().load_timing.request_start);
801 EXPECT_EQ(base::TimeTicks(), 796 EXPECT_EQ(base::TimeTicks(),
802 response_info().load_timing.connect_timing.dns_start); 797 response_info().load_timing.connect_timing.dns_start);
803 } 798 }
804 799
805 } // namespace content 800 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_loader.cc ('k') | content/common/resource_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698