OLD | NEW |
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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "content/browser/fileapi/chrome_blob_storage_context.h" | 10 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 TEST_F(ServiceWorkerURLRequestJobTest, BlobResponse) { | 264 TEST_F(ServiceWorkerURLRequestJobTest, BlobResponse) { |
265 ChromeBlobStorageContext* blob_storage_context = | 265 ChromeBlobStorageContext* blob_storage_context = |
266 ChromeBlobStorageContext::GetFor(browser_context_.get()); | 266 ChromeBlobStorageContext::GetFor(browser_context_.get()); |
267 std::string expected_response; | 267 std::string expected_response; |
268 expected_response.reserve((sizeof(kTestData) - 1) * 1024); | 268 expected_response.reserve((sizeof(kTestData) - 1) * 1024); |
269 for (int i = 0; i < 1024; ++i) { | 269 for (int i = 0; i < 1024; ++i) { |
270 blob_data_->AppendData(kTestData); | 270 blob_data_->AppendData(kTestData); |
271 expected_response += kTestData; | 271 expected_response += kTestData; |
272 } | 272 } |
273 scoped_ptr<storage::BlobDataHandle> blob_handle = | 273 scoped_ptr<storage::BlobDataHandle> blob_handle = |
274 blob_storage_context->context()->AddFinishedBlob(*blob_data_.get()); | 274 blob_storage_context->context()->AddFinishedBlob(blob_data_.get()); |
275 SetUpWithHelper(new BlobResponder( | 275 SetUpWithHelper(new BlobResponder( |
276 kProcessID, blob_handle->uuid(), expected_response.size())); | 276 kProcessID, blob_handle->uuid(), expected_response.size())); |
277 | 277 |
278 version_->SetStatus(ServiceWorkerVersion::ACTIVATED); | 278 version_->SetStatus(ServiceWorkerVersion::ACTIVATED); |
279 TestRequest(200, "OK", expected_response); | 279 TestRequest(200, "OK", expected_response); |
280 } | 280 } |
281 | 281 |
282 TEST_F(ServiceWorkerURLRequestJobTest, NonExistentBlobUUIDResponse) { | 282 TEST_F(ServiceWorkerURLRequestJobTest, NonExistentBlobUUIDResponse) { |
283 SetUpWithHelper(new BlobResponder(kProcessID, "blob-id:nothing-is-here", 0)); | 283 SetUpWithHelper(new BlobResponder(kProcessID, "blob-id:nothing-is-here", 0)); |
284 version_->SetStatus(ServiceWorkerVersion::ACTIVATED); | 284 version_->SetStatus(ServiceWorkerVersion::ACTIVATED); |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 stream->Finalize(); | 544 stream->Finalize(); |
545 | 545 |
546 base::RunLoop().RunUntilIdle(); | 546 base::RunLoop().RunUntilIdle(); |
547 EXPECT_FALSE(request_->status().is_success()); | 547 EXPECT_FALSE(request_->status().is_success()); |
548 } | 548 } |
549 | 549 |
550 // TODO(kinuko): Add more tests with different response data and also for | 550 // TODO(kinuko): Add more tests with different response data and also for |
551 // FallbackToNetwork case. | 551 // FallbackToNetwork case. |
552 | 552 |
553 } // namespace content | 553 } // namespace content |
OLD | NEW |