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
3 // found in the LICENSE file.
10 #include "base/bind_helpers.h"
11 #include "base/callback.h"
12 #include "base/compiler_specific.h"
13 #include "base/pickle.h"
14 #include "base/threading/thread.h"
15 #include "base/synchronization/waitable_event.h"
16 #include "net/base/io_buffer.h"
17 #include "net/base/net_errors.h"
18 #include "net/http/http_response_headers.h"
19 #include "testing/gtest/include/gtest/gtest.h"
20 #include "webkit/appcache/appcache_response.h"
21 #include "webkit/appcache/mock_appcache_service.h"
24 using net::WrappedIOBuffer
;
28 static const int kNumBlocks
= 4;
29 static const int kBlockSize
= 1024;
30 static const int kNoSuchResponseId
= 123;
32 class AppCacheResponseTest
: public testing::Test
{
35 // Test Harness -------------------------------------------------------------
37 // Helper class used to verify test results
38 class MockStorageDelegate
: public AppCacheStorage::Delegate
{
40 explicit MockStorageDelegate(AppCacheResponseTest
* test
)
41 : loaded_info_id_(0), test_(test
) {
44 virtual void OnResponseInfoLoaded(AppCacheResponseInfo
* info
,
45 int64 response_id
) OVERRIDE
{
47 loaded_info_id_
= response_id
;
48 test_
->ScheduleNextTask();
51 scoped_refptr
<AppCacheResponseInfo
> loaded_info_
;
52 int64 loaded_info_id_
;
53 AppCacheResponseTest
* test_
;
56 // Helper callback to run a test on our io_thread. The io_thread is spun up
57 // once and reused for all tests.
58 template <class Method
>
59 void MethodWrapper(Method method
) {
64 static void SetUpTestCase() {
65 io_thread_
.reset(new base::Thread("AppCacheResponseTest Thread"));
66 base::Thread::Options
options(MessageLoop::TYPE_IO
, 0);
67 io_thread_
->StartWithOptions(options
);
70 static void TearDownTestCase() {
71 io_thread_
.reset(NULL
);
74 AppCacheResponseTest() {}
76 template <class Method
>
77 void RunTestOnIOThread(Method method
) {
78 test_finished_event_
.reset(new base::WaitableEvent(false, false));
79 io_thread_
->message_loop()->PostTask(
80 FROM_HERE
, base::Bind(&AppCacheResponseTest::MethodWrapper
<Method
>,
81 base::Unretained(this), method
));
82 test_finished_event_
->Wait();
86 DCHECK(MessageLoop::current() == io_thread_
->message_loop());
87 DCHECK(task_stack_
.empty());
88 storage_delegate_
.reset(new MockStorageDelegate(this));
89 service_
.reset(new MockAppCacheService());
90 expected_read_result_
= 0;
91 expected_write_result_
= 0;
92 written_response_id_
= 0;
93 should_delete_reader_in_completion_callback_
= false;
94 should_delete_writer_in_completion_callback_
= false;
95 reader_deletion_count_down_
= 0;
96 writer_deletion_count_down_
= 0;
97 read_callback_was_called_
= false;
98 write_callback_was_called_
= false;
101 void TearDownTest() {
102 DCHECK(MessageLoop::current() == io_thread_
->message_loop());
103 while (!task_stack_
.empty())
108 read_info_buffer_
= NULL
;
110 write_buffer_
= NULL
;
111 write_info_buffer_
= NULL
;
112 storage_delegate_
.reset();
116 void TestFinished() {
117 // We unwind the stack prior to finishing up to let stack
118 // based objects get deleted.
119 DCHECK(MessageLoop::current() == io_thread_
->message_loop());
120 MessageLoop::current()->PostTask(
121 FROM_HERE
, base::Bind(&AppCacheResponseTest::TestFinishedUnwound
,
122 base::Unretained(this)));
125 void TestFinishedUnwound() {
127 test_finished_event_
->Signal();
130 void PushNextTask(const base::Closure
& task
) {
131 task_stack_
.push(std::pair
<base::Closure
, bool>(task
, false));
134 void PushNextTaskAsImmediate(const base::Closure
& task
) {
135 task_stack_
.push(std::pair
<base::Closure
, bool>(task
, true));
138 void ScheduleNextTask() {
139 DCHECK(MessageLoop::current() == io_thread_
->message_loop());
140 if (task_stack_
.empty()) {
144 base::Closure task
= task_stack_
.top().first
;
145 bool immediate
= task_stack_
.top().second
;
150 MessageLoop::current()->PostTask(FROM_HERE
, task
);
153 // Wrappers to call AppCacheResponseReader/Writer Read and Write methods
155 void WriteBasicResponse() {
156 static const char kHttpHeaders
[] =
157 "HTTP/1.0 200 OK\0Content-Length: 5\0\0";
158 static const char* kHttpBody
= "Hello";
159 scoped_refptr
<IOBuffer
> body(new WrappedIOBuffer(kHttpBody
));
160 std::string
raw_headers(kHttpHeaders
, arraysize(kHttpHeaders
));
161 WriteResponse(MakeHttpResponseInfo(raw_headers
), body
, strlen(kHttpBody
));
164 int basic_response_size() { return 5; } // should match kHttpBody above
166 void WriteResponse(net::HttpResponseInfo
* head
,
167 IOBuffer
* body
, int body_len
) {
169 scoped_refptr
<IOBuffer
> body_ref(body
);
170 PushNextTask(base::Bind(&AppCacheResponseTest::WriteResponseBody
,
171 base::Unretained(this), body_ref
, body_len
));
172 WriteResponseHead(head
);
175 void WriteResponseHead(net::HttpResponseInfo
* head
) {
176 EXPECT_FALSE(writer_
->IsWritePending());
177 expected_write_result_
= GetHttpResponseInfoSize(head
);
178 write_info_buffer_
= new HttpResponseInfoIOBuffer(head
);
181 base::Bind(&AppCacheResponseTest::OnWriteInfoComplete
,
182 base::Unretained(this)));
185 void WriteResponseBody(scoped_refptr
<IOBuffer
> io_buffer
, int buf_len
) {
186 EXPECT_FALSE(writer_
->IsWritePending());
187 write_buffer_
= io_buffer
;
188 expected_write_result_
= buf_len
;
190 write_buffer_
, buf_len
,
191 base::Bind(&AppCacheResponseTest::OnWriteComplete
,
192 base::Unretained(this)));
195 void ReadResponseBody(scoped_refptr
<IOBuffer
> io_buffer
, int buf_len
) {
196 EXPECT_FALSE(reader_
->IsReadPending());
197 read_buffer_
= io_buffer
;
198 expected_read_result_
= buf_len
;
200 read_buffer_
, buf_len
,
201 base::Bind(&AppCacheResponseTest::OnReadComplete
,
202 base::Unretained(this)));
205 // AppCacheResponseReader / Writer completion callbacks
207 void OnWriteInfoComplete(int result
) {
208 EXPECT_FALSE(writer_
->IsWritePending());
209 EXPECT_EQ(expected_write_result_
, result
);
213 void OnWriteComplete(int result
) {
214 EXPECT_FALSE(writer_
->IsWritePending());
215 write_callback_was_called_
= true;
216 EXPECT_EQ(expected_write_result_
, result
);
217 if (should_delete_writer_in_completion_callback_
&&
218 --writer_deletion_count_down_
== 0) {
224 void OnReadInfoComplete(int result
) {
225 EXPECT_FALSE(reader_
->IsReadPending());
226 EXPECT_EQ(expected_read_result_
, result
);
230 void OnReadComplete(int result
) {
231 EXPECT_FALSE(reader_
->IsReadPending());
232 read_callback_was_called_
= true;
233 EXPECT_EQ(expected_read_result_
, result
);
234 if (should_delete_reader_in_completion_callback_
&&
235 --reader_deletion_count_down_
== 0) {
241 // Helpers to work with HttpResponseInfo objects
243 net::HttpResponseInfo
* MakeHttpResponseInfo(const std::string
& raw_headers
) {
244 net::HttpResponseInfo
* info
= new net::HttpResponseInfo
;
245 info
->request_time
= base::Time::Now();
246 info
->response_time
= base::Time::Now();
247 info
->was_cached
= false;
248 info
->headers
= new net::HttpResponseHeaders(raw_headers
);
252 int GetHttpResponseInfoSize(const net::HttpResponseInfo
* info
) {
254 return PickleHttpResonseInfo(&pickle
, info
);
257 bool CompareHttpResponseInfos(const net::HttpResponseInfo
* info1
,
258 const net::HttpResponseInfo
* info2
) {
261 PickleHttpResonseInfo(&pickle1
, info1
);
262 PickleHttpResonseInfo(&pickle2
, info2
);
263 return (pickle1
.size() == pickle2
.size()) &&
264 (0 == memcmp(pickle1
.data(), pickle2
.data(), pickle1
.size()));
267 int PickleHttpResonseInfo(Pickle
* pickle
, const net::HttpResponseInfo
* info
) {
268 const bool kSkipTransientHeaders
= true;
269 const bool kTruncated
= false;
270 info
->Persist(pickle
, kSkipTransientHeaders
, kTruncated
);
271 return pickle
->size();
274 // Helpers to fill and verify blocks of memory with a value
276 void FillData(char value
, char* data
, int data_len
) {
277 memset(data
, value
, data_len
);
280 bool CheckData(char value
, const char* data
, int data_len
) {
281 for (int i
= 0; i
< data_len
; ++i
, ++data
) {
288 // Individual Tests ---------------------------------------------------------
289 // Most of the individual tests involve multiple async steps. Each test
290 // is delineated with a section header.
293 // ReadNonExistentResponse -------------------------------------------
294 void ReadNonExistentResponse() {
295 // 1. Attempt to ReadInfo
296 // 2. Attempt to ReadData
298 reader_
.reset(service_
->storage()->CreateResponseReader(
299 GURL(), 0, kNoSuchResponseId
));
301 // Push tasks in reverse order
302 PushNextTask(base::Bind(&AppCacheResponseTest::ReadNonExistentData
,
303 base::Unretained(this)));
304 PushNextTask(base::Bind(&AppCacheResponseTest::ReadNonExistentInfo
,
305 base::Unretained(this)));
309 void ReadNonExistentInfo() {
310 EXPECT_FALSE(reader_
->IsReadPending());
311 read_info_buffer_
= new HttpResponseInfoIOBuffer();
314 base::Bind(&AppCacheResponseTest::OnReadInfoComplete
,
315 base::Unretained(this)));
316 EXPECT_TRUE(reader_
->IsReadPending());
317 expected_read_result_
= net::ERR_CACHE_MISS
;
320 void ReadNonExistentData() {
321 EXPECT_FALSE(reader_
->IsReadPending());
322 read_buffer_
= new IOBuffer(kBlockSize
);
324 read_buffer_
, kBlockSize
,
325 base::Bind(&AppCacheResponseTest::OnReadComplete
,
326 base::Unretained(this)));
327 EXPECT_TRUE(reader_
->IsReadPending());
328 expected_read_result_
= net::ERR_CACHE_MISS
;
331 // LoadResponseInfo_Miss ----------------------------------------------------
332 void LoadResponseInfo_Miss() {
333 PushNextTask(base::Bind(&AppCacheResponseTest::LoadResponseInfo_Miss_Verify
,
334 base::Unretained(this)));
335 service_
->storage()->LoadResponseInfo(GURL(), 0, kNoSuchResponseId
,
336 storage_delegate_
.get());
339 void LoadResponseInfo_Miss_Verify() {
340 EXPECT_EQ(kNoSuchResponseId
, storage_delegate_
->loaded_info_id_
);
341 EXPECT_TRUE(!storage_delegate_
->loaded_info_
.get());
345 // LoadResponseInfo_Hit ----------------------------------------------------
346 void LoadResponseInfo_Hit() {
347 // This tests involves multiple async steps.
348 // 1. Write a response headers and body to storage
351 // 2. Use LoadResponseInfo to read the response headers back out
352 PushNextTask(base::Bind(&AppCacheResponseTest::LoadResponseInfo_Hit_Step2
,
353 base::Unretained(this)));
354 writer_
.reset(service_
->storage()->CreateResponseWriter(GURL(), 0));
355 written_response_id_
= writer_
->response_id();
356 WriteBasicResponse();
359 void LoadResponseInfo_Hit_Step2() {
361 PushNextTask(base::Bind(&AppCacheResponseTest::LoadResponseInfo_Hit_Verify
,
362 base::Unretained(this)));
363 service_
->storage()->LoadResponseInfo(GURL(), 0, written_response_id_
,
364 storage_delegate_
.get());
367 void LoadResponseInfo_Hit_Verify() {
368 EXPECT_EQ(written_response_id_
, storage_delegate_
->loaded_info_id_
);
369 EXPECT_TRUE(storage_delegate_
->loaded_info_
.get());
370 EXPECT_TRUE(CompareHttpResponseInfos(
371 write_info_buffer_
->http_info
.get(),
372 storage_delegate_
->loaded_info_
->http_response_info()));
373 EXPECT_EQ(basic_response_size(),
374 storage_delegate_
->loaded_info_
->response_data_size());
378 // AmountWritten ----------------------------------------------------
380 void AmountWritten() {
381 static const char kHttpHeaders
[] =
382 "HTTP/1.0 200 OK\0\0";
383 std::string
raw_headers(kHttpHeaders
, arraysize(kHttpHeaders
));
384 net::HttpResponseInfo
* head
= MakeHttpResponseInfo(raw_headers
);
385 int expected_amount_written
=
386 GetHttpResponseInfoSize(head
) + kNumBlocks
* kBlockSize
;
388 // Push tasks in reverse order.
389 PushNextTask(base::Bind(&AppCacheResponseTest::Verify_AmountWritten
,
390 base::Unretained(this), expected_amount_written
));
391 for (int i
= 0; i
< kNumBlocks
; ++i
) {
392 PushNextTask(base::Bind(&AppCacheResponseTest::WriteOneBlock
,
393 base::Unretained(this), kNumBlocks
- i
));
395 PushNextTask(base::Bind(&AppCacheResponseTest::WriteResponseHead
,
396 base::Unretained(this), head
));
398 writer_
.reset(service_
->storage()->CreateResponseWriter(GURL(), 0));
399 written_response_id_
= writer_
->response_id();
403 void Verify_AmountWritten(int expected_amount_written
) {
404 EXPECT_EQ(expected_amount_written
, writer_
->amount_written());
409 // WriteThenVariouslyReadResponse -------------------------------------------
411 void WriteThenVariouslyReadResponse() {
412 // This tests involves multiple async steps.
413 // 1. First, write a large body using multiple writes, we don't bother
414 // with a response head for this test.
415 // 2. Read the entire body, using multiple reads
416 // 3. Read the entire body, using one read.
417 // 4. Attempt to read beyond the EOF.
418 // 5. Read just a range.
419 // 6. Attempt to read beyond EOF of a range.
421 // Push tasks in reverse order
422 PushNextTask(base::Bind(&AppCacheResponseTest::ReadRangeFullyBeyondEOF
,
423 base::Unretained(this)));
424 PushNextTask(base::Bind(&AppCacheResponseTest::ReadRangePartiallyBeyondEOF
,
425 base::Unretained(this)));
426 PushNextTask(base::Bind(&AppCacheResponseTest::ReadPastEOF
,
427 base::Unretained(this)));
428 PushNextTask(base::Bind(&AppCacheResponseTest::ReadRange
,
429 base::Unretained(this)));
430 PushNextTask(base::Bind(&AppCacheResponseTest::ReadPastEOF
,
431 base::Unretained(this)));
432 PushNextTask(base::Bind(&AppCacheResponseTest::ReadAllAtOnce
,
433 base::Unretained(this)));
434 PushNextTask(base::Bind(&AppCacheResponseTest::ReadInBlocks
,
435 base::Unretained(this)));
436 PushNextTask(base::Bind(&AppCacheResponseTest::WriteOutBlocks
,
437 base::Unretained(this)));
443 void WriteOutBlocks() {
444 writer_
.reset(service_
->storage()->CreateResponseWriter(GURL(), 0));
445 written_response_id_
= writer_
->response_id();
446 for (int i
= 0; i
< kNumBlocks
; ++i
) {
447 PushNextTask(base::Bind(&AppCacheResponseTest::WriteOneBlock
,
448 base::Unretained(this), kNumBlocks
- i
));
453 void WriteOneBlock(int block_number
) {
454 scoped_refptr
<IOBuffer
> io_buffer(
455 new IOBuffer(kBlockSize
));
456 FillData(block_number
, io_buffer
->data(), kBlockSize
);
457 WriteResponseBody(io_buffer
, kBlockSize
);
460 void ReadInBlocks() {
462 reader_
.reset(service_
->storage()->CreateResponseReader(
463 GURL(), 0, written_response_id_
));
464 for (int i
= 0; i
< kNumBlocks
; ++i
) {
465 PushNextTask(base::Bind(&AppCacheResponseTest::ReadOneBlock
,
466 base::Unretained(this), kNumBlocks
- i
));
471 void ReadOneBlock(int block_number
) {
472 PushNextTask(base::Bind(&AppCacheResponseTest::VerifyOneBlock
,
473 base::Unretained(this), block_number
));
474 ReadResponseBody(new IOBuffer(kBlockSize
), kBlockSize
);
477 void VerifyOneBlock(int block_number
) {
478 EXPECT_TRUE(CheckData(block_number
, read_buffer_
->data(), kBlockSize
));
482 void ReadAllAtOnce() {
483 PushNextTask(base::Bind(&AppCacheResponseTest::VerifyAllAtOnce
,
484 base::Unretained(this)));
485 reader_
.reset(service_
->storage()->CreateResponseReader(
486 GURL(), 0, written_response_id_
));
487 int big_size
= kNumBlocks
* kBlockSize
;
488 ReadResponseBody(new IOBuffer(big_size
), big_size
);
491 void VerifyAllAtOnce() {
492 char* p
= read_buffer_
->data();
493 for (int i
= 0; i
< kNumBlocks
; ++i
, p
+= kBlockSize
)
494 EXPECT_TRUE(CheckData(i
+ 1, p
, kBlockSize
));
499 EXPECT_FALSE(reader_
->IsReadPending());
500 read_buffer_
= new IOBuffer(kBlockSize
);
501 expected_read_result_
= 0;
503 read_buffer_
, kBlockSize
,
504 base::Bind(&AppCacheResponseTest::OnReadComplete
,
505 base::Unretained(this)));
509 PushNextTask(base::Bind(&AppCacheResponseTest::VerifyRange
,
510 base::Unretained(this)));
511 reader_
.reset(service_
->storage()->CreateResponseReader(
512 GURL(), 0, written_response_id_
));
513 reader_
->SetReadRange(kBlockSize
, kBlockSize
);
514 ReadResponseBody(new IOBuffer(kBlockSize
), kBlockSize
);
518 EXPECT_TRUE(CheckData(2, read_buffer_
->data(), kBlockSize
));
519 ScheduleNextTask(); // ReadPastEOF is scheduled next
522 void ReadRangePartiallyBeyondEOF() {
523 PushNextTask(base::Bind(&AppCacheResponseTest::VerifyRangeBeyondEOF
,
524 base::Unretained(this)));
525 reader_
.reset(service_
->storage()->CreateResponseReader(
526 GURL(), 0, written_response_id_
));
527 reader_
->SetReadRange(kBlockSize
, kNumBlocks
* kBlockSize
);
528 ReadResponseBody(new IOBuffer(kNumBlocks
* kBlockSize
),
529 kNumBlocks
* kBlockSize
);
530 expected_read_result_
= (kNumBlocks
- 1) * kBlockSize
;
533 void VerifyRangeBeyondEOF() {
534 // Just verify the first 1k
538 void ReadRangeFullyBeyondEOF() {
539 reader_
.reset(service_
->storage()->CreateResponseReader(
540 GURL(), 0, written_response_id_
));
541 reader_
->SetReadRange((kNumBlocks
* kBlockSize
) + 1, kBlockSize
);
542 ReadResponseBody(new IOBuffer(kBlockSize
), kBlockSize
);
543 expected_read_result_
= 0;
546 // IOChaining -------------------------------------------
548 // 1. Write several blocks out initiating the subsequent write
549 // from within the completion callback of the previous write.
550 // 2. Read and verify several blocks in similarly chaining reads.
552 // Push tasks in reverse order
553 PushNextTaskAsImmediate(
554 base::Bind(&AppCacheResponseTest::ReadInBlocksImmediately
,
555 base::Unretained(this)));
556 PushNextTaskAsImmediate(
557 base::Bind(&AppCacheResponseTest::WriteOutBlocksImmediately
,
558 base::Unretained(this)));
564 void WriteOutBlocksImmediately() {
565 writer_
.reset(service_
->storage()->CreateResponseWriter(GURL(), 0));
566 written_response_id_
= writer_
->response_id();
567 for (int i
= 0; i
< kNumBlocks
; ++i
) {
568 PushNextTaskAsImmediate(
569 base::Bind(&AppCacheResponseTest::WriteOneBlock
,
570 base::Unretained(this), kNumBlocks
- i
));
575 void ReadInBlocksImmediately() {
577 reader_
.reset(service_
->storage()->CreateResponseReader(
578 GURL(), 0, written_response_id_
));
579 for (int i
= 0; i
< kNumBlocks
; ++i
) {
580 PushNextTaskAsImmediate(
581 base::Bind(&AppCacheResponseTest::ReadOneBlockImmediately
,
582 base::Unretained(this),
588 void ReadOneBlockImmediately(int block_number
) {
589 PushNextTaskAsImmediate(base::Bind(&AppCacheResponseTest::VerifyOneBlock
,
590 base::Unretained(this), block_number
));
591 ReadResponseBody(new IOBuffer(kBlockSize
), kBlockSize
);
594 // DeleteWithinCallbacks -------------------------------------------
595 void DeleteWithinCallbacks() {
596 // 1. Write out a few blocks normally, and upon
597 // completion of the last write, delete the writer.
598 // 2. Read in a few blocks normally, and upon completion
599 // of the last read, delete the reader.
601 should_delete_reader_in_completion_callback_
= true;
602 reader_deletion_count_down_
= kNumBlocks
;
603 should_delete_writer_in_completion_callback_
= true;
604 writer_deletion_count_down_
= kNumBlocks
;
606 PushNextTask(base::Bind(&AppCacheResponseTest::ReadInBlocks
,
607 base::Unretained(this)));
608 PushNextTask(base::Bind(&AppCacheResponseTest::WriteOutBlocks
,
609 base::Unretained(this)));
613 // DeleteWithIOPending -------------------------------------------
614 void DeleteWithIOPending() {
615 // 1. Write a few blocks normally.
616 // 2. Start a write, delete with it pending.
617 // 3. Start a read, delete with it pending.
618 PushNextTask(base::Bind(&AppCacheResponseTest::ReadThenDelete
,
619 base::Unretained(this)));
620 PushNextTask(base::Bind(&AppCacheResponseTest::WriteThenDelete
,
621 base::Unretained(this)));
622 PushNextTask(base::Bind(&AppCacheResponseTest::WriteOutBlocks
,
623 base::Unretained(this)));
627 void WriteThenDelete() {
628 write_callback_was_called_
= false;
630 EXPECT_TRUE(writer_
->IsWritePending());
635 void ReadThenDelete() {
636 read_callback_was_called_
= false;
637 reader_
.reset(service_
->storage()->CreateResponseReader(
638 GURL(), 0, written_response_id_
));
639 ReadResponseBody(new IOBuffer(kBlockSize
), kBlockSize
);
640 EXPECT_TRUE(reader_
->IsReadPending());
643 // Wait a moment to verify no callbacks.
644 MessageLoop::current()->PostDelayedTask(
645 FROM_HERE
, base::Bind(&AppCacheResponseTest::VerifyNoCallbacks
,
646 base::Unretained(this)),
647 base::TimeDelta::FromMilliseconds(10));
650 void VerifyNoCallbacks() {
651 EXPECT_TRUE(!write_callback_was_called_
);
652 EXPECT_TRUE(!read_callback_was_called_
);
658 scoped_ptr
<base::WaitableEvent
> test_finished_event_
;
659 scoped_ptr
<MockStorageDelegate
> storage_delegate_
;
660 scoped_ptr
<MockAppCacheService
> service_
;
661 std::stack
<std::pair
<base::Closure
, bool> > task_stack_
;
663 scoped_ptr
<AppCacheResponseReader
> reader_
;
664 scoped_refptr
<HttpResponseInfoIOBuffer
> read_info_buffer_
;
665 scoped_refptr
<IOBuffer
> read_buffer_
;
666 int expected_read_result_
;
667 bool should_delete_reader_in_completion_callback_
;
668 int reader_deletion_count_down_
;
669 bool read_callback_was_called_
;
671 int64 written_response_id_
;
672 scoped_ptr
<AppCacheResponseWriter
> writer_
;
673 scoped_refptr
<HttpResponseInfoIOBuffer
> write_info_buffer_
;
674 scoped_refptr
<IOBuffer
> write_buffer_
;
675 int expected_write_result_
;
676 bool should_delete_writer_in_completion_callback_
;
677 int writer_deletion_count_down_
;
678 bool write_callback_was_called_
;
680 static scoped_ptr
<base::Thread
> io_thread_
;
684 scoped_ptr
<base::Thread
> AppCacheResponseTest::io_thread_
;
686 TEST_F(AppCacheResponseTest
, ReadNonExistentResponse
) {
687 RunTestOnIOThread(&AppCacheResponseTest::ReadNonExistentResponse
);
690 TEST_F(AppCacheResponseTest
, LoadResponseInfo_Miss
) {
691 RunTestOnIOThread(&AppCacheResponseTest::LoadResponseInfo_Miss
);
694 TEST_F(AppCacheResponseTest
, LoadResponseInfo_Hit
) {
695 RunTestOnIOThread(&AppCacheResponseTest::LoadResponseInfo_Hit
);
698 TEST_F(AppCacheResponseTest
, AmountWritten
) {
699 RunTestOnIOThread(&AppCacheResponseTest::AmountWritten
);
702 TEST_F(AppCacheResponseTest
, WriteThenVariouslyReadResponse
) {
703 RunTestOnIOThread(&AppCacheResponseTest::WriteThenVariouslyReadResponse
);
706 TEST_F(AppCacheResponseTest
, IOChaining
) {
707 RunTestOnIOThread(&AppCacheResponseTest::IOChaining
);
710 TEST_F(AppCacheResponseTest
, DeleteWithinCallbacks
) {
711 RunTestOnIOThread(&AppCacheResponseTest::DeleteWithinCallbacks
);
714 TEST_F(AppCacheResponseTest
, DeleteWithIOPending
) {
715 RunTestOnIOThread(&AppCacheResponseTest::DeleteWithIOPending
);
718 } // namespace appcache