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

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

Issue 12210030: Linux/ChromeOS Chromium style checker cleanup, content/ edition. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 7 years, 10 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
« no previous file with comments | « content/common/resource_dispatcher.cc ('k') | content/common/socket_stream_dispatcher.cc » ('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/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/process.h" 10 #include "base/process.h"
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 int encoded_data_length) OVERRIDE { 65 int encoded_data_length) OVERRIDE {
66 EXPECT_FALSE(complete_); 66 EXPECT_FALSE(complete_);
67 data_.append(data, data_length); 67 data_.append(data, data_length);
68 total_encoded_data_length_ += encoded_data_length; 68 total_encoded_data_length_ += encoded_data_length;
69 } 69 }
70 70
71 virtual void OnCompletedRequest( 71 virtual void OnCompletedRequest(
72 int error_code, 72 int error_code,
73 bool was_ignored_by_handler, 73 bool was_ignored_by_handler,
74 const std::string& security_info, 74 const std::string& security_info,
75 const base::TimeTicks& completion_time) { 75 const base::TimeTicks& completion_time) OVERRIDE {
76 EXPECT_FALSE(complete_); 76 EXPECT_FALSE(complete_);
77 complete_ = true; 77 complete_ = true;
78 } 78 }
79 79
80 bool complete() const { 80 bool complete() const {
81 return complete_; 81 return complete_;
82 } 82 }
83 const std::string& data() const { 83 const std::string& data() const {
84 return data_; 84 return data_;
85 } 85 }
86 int total_encoded_data_length() const { 86 int total_encoded_data_length() const {
87 return total_encoded_data_length_; 87 return total_encoded_data_length_;
88 } 88 }
89 89
90 private: 90 private:
91 bool complete_; 91 bool complete_;
92 std::string data_; 92 std::string data_;
93 int total_encoded_data_length_; 93 int total_encoded_data_length_;
94 }; 94 };
95 95
96 96
97 // Sets up the message sender override for the unit test 97 // Sets up the message sender override for the unit test
98 class ResourceDispatcherTest : public testing::Test, public IPC::Sender { 98 class ResourceDispatcherTest : public testing::Test, public IPC::Sender {
99 public: 99 public:
100 // Emulates IPC send operations (IPC::Sender) by adding 100 // Emulates IPC send operations (IPC::Sender) by adding
101 // pending messages to the queue. 101 // pending messages to the queue.
102 virtual bool Send(IPC::Message* msg) { 102 virtual bool Send(IPC::Message* msg) OVERRIDE {
103 message_queue_.push_back(IPC::Message(*msg)); 103 message_queue_.push_back(IPC::Message(*msg));
104 delete msg; 104 delete msg;
105 return true; 105 return true;
106 } 106 }
107 107
108 // Emulates the browser process and processes the pending IPC messages, 108 // Emulates the browser process and processes the pending IPC messages,
109 // returning the hardcoded file contents. 109 // returning the hardcoded file contents.
110 void ProcessMessages() { 110 void ProcessMessages() {
111 while (!message_queue_.empty()) { 111 while (!message_queue_.empty()) {
112 int request_id; 112 int request_id;
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 int data_length, 291 int data_length,
292 int encoded_data_length) OVERRIDE { 292 int encoded_data_length) OVERRIDE {
293 EXPECT_EQ(defer_loading_, false); 293 EXPECT_EQ(defer_loading_, false);
294 set_defer_loading(false); 294 set_defer_loading(false);
295 } 295 }
296 296
297 virtual void OnCompletedRequest( 297 virtual void OnCompletedRequest(
298 int error_code, 298 int error_code,
299 bool was_ignored_by_handler, 299 bool was_ignored_by_handler,
300 const std::string& security_info, 300 const std::string& security_info,
301 const base::TimeTicks& completion_time) { 301 const base::TimeTicks& completion_time) OVERRIDE {
302 } 302 }
303 303
304 protected: 304 protected:
305 virtual void SetUp() OVERRIDE { 305 virtual void SetUp() OVERRIDE {
306 ResourceDispatcherTest::SetUp(); 306 ResourceDispatcherTest::SetUp();
307 shared_handle_.Delete(kShmemSegmentName); 307 shared_handle_.Delete(kShmemSegmentName);
308 EXPECT_TRUE(shared_handle_.CreateNamed(kShmemSegmentName, false, 100)); 308 EXPECT_TRUE(shared_handle_.CreateNamed(kShmemSegmentName, false, 100));
309 } 309 }
310 310
311 virtual void TearDown() OVERRIDE { 311 virtual void TearDown() OVERRIDE {
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 } 358 }
359 359
360 // ResourceLoaderBridge::Peer methods. 360 // ResourceLoaderBridge::Peer methods.
361 virtual void OnUploadProgress(uint64 position, uint64 size) OVERRIDE { 361 virtual void OnUploadProgress(uint64 position, uint64 size) OVERRIDE {
362 } 362 }
363 363
364 virtual bool OnReceivedRedirect( 364 virtual bool OnReceivedRedirect(
365 const GURL& new_url, 365 const GURL& new_url,
366 const ResourceResponseInfo& info, 366 const ResourceResponseInfo& info,
367 bool* has_new_first_party_for_cookies, 367 bool* has_new_first_party_for_cookies,
368 GURL* new_first_party_for_cookies) { 368 GURL* new_first_party_for_cookies) OVERRIDE {
369 return true; 369 return true;
370 } 370 }
371 371
372 virtual void OnReceivedResponse(const ResourceResponseInfo& info) OVERRIDE { 372 virtual void OnReceivedResponse(const ResourceResponseInfo& info) OVERRIDE {
373 response_info_ = info; 373 response_info_ = info;
374 } 374 }
375 375
376 virtual void OnDownloadedData(int len) OVERRIDE { 376 virtual void OnDownloadedData(int len) OVERRIDE {
377 } 377 }
378 378
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 ResourceResponseHead response_head; 428 ResourceResponseHead response_head;
429 response_head.error_code = net::OK; 429 response_head.error_code = net::OK;
430 430
431 PerformTest(response_head); 431 PerformTest(response_head);
432 432
433 EXPECT_EQ(0, response_info().load_timing.base_ticks.ToInternalValue()); 433 EXPECT_EQ(0, response_info().load_timing.base_ticks.ToInternalValue());
434 EXPECT_EQ(-1, response_info().load_timing.dns_start); 434 EXPECT_EQ(-1, response_info().load_timing.dns_start);
435 } 435 }
436 436
437 } // namespace content 437 } // namespace content
OLDNEW
« no previous file with comments | « content/common/resource_dispatcher.cc ('k') | content/common/socket_stream_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698