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

Side by Side Diff: content/browser/appcache/appcache_response_unittest.cc

Issue 494473002: Cleanup: Change const char* foo to const char foo[] in content/browser. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 4 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 | « no previous file | content/browser/fileapi/chrome_blob_storage_context.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <stack> 5 #include <stack>
6 #include <string> 6 #include <string>
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 13 matching lines...) Expand all
24 using net::WrappedIOBuffer; 24 using net::WrappedIOBuffer;
25 25
26 namespace content { 26 namespace content {
27 27
28 static const int kNumBlocks = 4; 28 static const int kNumBlocks = 4;
29 static const int kBlockSize = 1024; 29 static const int kBlockSize = 1024;
30 static const int kNoSuchResponseId = 123; 30 static const int kNoSuchResponseId = 123;
31 31
32 class AppCacheResponseTest : public testing::Test { 32 class AppCacheResponseTest : public testing::Test {
33 public: 33 public:
34
35 // Test Harness ------------------------------------------------------------- 34 // Test Harness -------------------------------------------------------------
36 35
37 // Helper class used to verify test results 36 // Helper class used to verify test results
38 class MockStorageDelegate : public AppCacheStorage::Delegate { 37 class MockStorageDelegate : public AppCacheStorage::Delegate {
39 public: 38 public:
40 explicit MockStorageDelegate(AppCacheResponseTest* test) 39 explicit MockStorageDelegate(AppCacheResponseTest* test)
41 : loaded_info_id_(0), test_(test) { 40 : loaded_info_id_(0), test_(test) {
42 } 41 }
43 42
44 virtual void OnResponseInfoLoaded(AppCacheResponseInfo* info, 43 virtual void OnResponseInfoLoaded(AppCacheResponseInfo* info,
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 task.Run(); 147 task.Run();
149 else 148 else
150 base::MessageLoop::current()->PostTask(FROM_HERE, task); 149 base::MessageLoop::current()->PostTask(FROM_HERE, task);
151 } 150 }
152 151
153 // Wrappers to call AppCacheResponseReader/Writer Read and Write methods 152 // Wrappers to call AppCacheResponseReader/Writer Read and Write methods
154 153
155 void WriteBasicResponse() { 154 void WriteBasicResponse() {
156 static const char kHttpHeaders[] = 155 static const char kHttpHeaders[] =
157 "HTTP/1.0 200 OK\0Content-Length: 5\0\0"; 156 "HTTP/1.0 200 OK\0Content-Length: 5\0\0";
158 static const char* kHttpBody = "Hello"; 157 static const char kHttpBody[] = "Hello";
159 scoped_refptr<IOBuffer> body(new WrappedIOBuffer(kHttpBody)); 158 scoped_refptr<IOBuffer> body(new WrappedIOBuffer(kHttpBody));
160 std::string raw_headers(kHttpHeaders, arraysize(kHttpHeaders)); 159 std::string raw_headers(kHttpHeaders, arraysize(kHttpHeaders));
161 WriteResponse( 160 WriteResponse(
162 MakeHttpResponseInfo(raw_headers), body.get(), strlen(kHttpBody)); 161 MakeHttpResponseInfo(raw_headers), body.get(), strlen(kHttpBody));
163 } 162 }
164 163
165 int basic_response_size() { return 5; } // should match kHttpBody above 164 int basic_response_size() { return 5; } // should match kHttpBody above
166 165
167 void WriteResponse(net::HttpResponseInfo* head, 166 void WriteResponse(net::HttpResponseInfo* head,
168 IOBuffer* body, int body_len) { 167 IOBuffer* body, int body_len) {
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 write_info_buffer_->http_info.get(), 369 write_info_buffer_->http_info.get(),
371 storage_delegate_->loaded_info_->http_response_info())); 370 storage_delegate_->loaded_info_->http_response_info()));
372 EXPECT_EQ(basic_response_size(), 371 EXPECT_EQ(basic_response_size(),
373 storage_delegate_->loaded_info_->response_data_size()); 372 storage_delegate_->loaded_info_->response_data_size());
374 TestFinished(); 373 TestFinished();
375 } 374 }
376 375
377 // AmountWritten ---------------------------------------------------- 376 // AmountWritten ----------------------------------------------------
378 377
379 void AmountWritten() { 378 void AmountWritten() {
380 static const char kHttpHeaders[] = 379 static const char kHttpHeaders[] = "HTTP/1.0 200 OK\0\0";
381 "HTTP/1.0 200 OK\0\0";
382 std::string raw_headers(kHttpHeaders, arraysize(kHttpHeaders)); 380 std::string raw_headers(kHttpHeaders, arraysize(kHttpHeaders));
383 net::HttpResponseInfo* head = MakeHttpResponseInfo(raw_headers); 381 net::HttpResponseInfo* head = MakeHttpResponseInfo(raw_headers);
384 int expected_amount_written = 382 int expected_amount_written =
385 GetHttpResponseInfoSize(head) + kNumBlocks * kBlockSize; 383 GetHttpResponseInfoSize(head) + kNumBlocks * kBlockSize;
386 384
387 // Push tasks in reverse order. 385 // Push tasks in reverse order.
388 PushNextTask(base::Bind(&AppCacheResponseTest::Verify_AmountWritten, 386 PushNextTask(base::Bind(&AppCacheResponseTest::Verify_AmountWritten,
389 base::Unretained(this), expected_amount_written)); 387 base::Unretained(this), expected_amount_written));
390 for (int i = 0; i < kNumBlocks; ++i) { 388 for (int i = 0; i < kNumBlocks; ++i) {
391 PushNextTask(base::Bind(&AppCacheResponseTest::WriteOneBlock, 389 PushNextTask(base::Bind(&AppCacheResponseTest::WriteOneBlock,
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 706
709 TEST_F(AppCacheResponseTest, DeleteWithinCallbacks) { 707 TEST_F(AppCacheResponseTest, DeleteWithinCallbacks) {
710 RunTestOnIOThread(&AppCacheResponseTest::DeleteWithinCallbacks); 708 RunTestOnIOThread(&AppCacheResponseTest::DeleteWithinCallbacks);
711 } 709 }
712 710
713 TEST_F(AppCacheResponseTest, DeleteWithIOPending) { 711 TEST_F(AppCacheResponseTest, DeleteWithIOPending) {
714 RunTestOnIOThread(&AppCacheResponseTest::DeleteWithIOPending); 712 RunTestOnIOThread(&AppCacheResponseTest::DeleteWithIOPending);
715 } 713 }
716 714
717 } // namespace content 715 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/fileapi/chrome_blob_storage_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698