| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 <map> | 5 #include <map> |
| 6 #include <memory> | 6 #include <memory> |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 void SetUp() override { | 121 void SetUp() override { |
| 122 BackgroundFetchTestBase::SetUp(); | 122 BackgroundFetchTestBase::SetUp(); |
| 123 | 123 |
| 124 StoragePartitionImpl* storage_partition = | 124 StoragePartitionImpl* storage_partition = |
| 125 static_cast<StoragePartitionImpl*>( | 125 static_cast<StoragePartitionImpl*>( |
| 126 BrowserContext::GetDefaultStoragePartition(browser_context())); | 126 BrowserContext::GetDefaultStoragePartition(browser_context())); |
| 127 | 127 |
| 128 context_ = new BackgroundFetchContext( | 128 context_ = new BackgroundFetchContext( |
| 129 browser_context(), storage_partition, | 129 browser_context(), storage_partition, |
| 130 make_scoped_refptr(embedded_worker_test_helper()->context_wrapper())); | 130 make_scoped_refptr(embedded_worker_test_helper()->context_wrapper())); |
| 131 context_->InitializeOnIOThread( |
| 132 make_scoped_refptr(storage_partition->GetURLRequestContext())); |
| 133 |
| 131 service_ = base::MakeUnique<BackgroundFetchServiceImpl>( | 134 service_ = base::MakeUnique<BackgroundFetchServiceImpl>( |
| 132 0 /* render_process_id */, context_); | 135 0 /* render_process_id */, context_); |
| 133 } | 136 } |
| 134 | 137 |
| 135 void TearDown() override { | 138 void TearDown() override { |
| 136 BackgroundFetchTestBase::TearDown(); | 139 BackgroundFetchTestBase::TearDown(); |
| 137 | 140 |
| 138 service_.reset(); | 141 service_.reset(); |
| 139 | 142 |
| 140 context_->Shutdown(); | 143 context_->Shutdown(); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 for (size_t i = 0; i < fetches.size(); ++i) { | 365 for (size_t i = 0; i < fetches.size(); ++i) { |
| 363 ASSERT_EQ(fetches[i].request.url, requests[i].url); | 366 ASSERT_EQ(fetches[i].request.url, requests[i].url); |
| 364 EXPECT_EQ(fetches[i].request.method, requests[i].method); | 367 EXPECT_EQ(fetches[i].request.method, requests[i].method); |
| 365 | 368 |
| 366 EXPECT_EQ(fetches[i].request.url, fetches[i].response.url_list[0]); | 369 EXPECT_EQ(fetches[i].request.url, fetches[i].response.url_list[0]); |
| 367 | 370 |
| 368 // TODO(peter): change-detector tests for unsupported properties. | 371 // TODO(peter): change-detector tests for unsupported properties. |
| 369 EXPECT_EQ(fetches[i].response.status_code, 0); | 372 EXPECT_EQ(fetches[i].response.status_code, 0); |
| 370 EXPECT_TRUE(fetches[i].response.status_text.empty()); | 373 EXPECT_TRUE(fetches[i].response.status_text.empty()); |
| 371 EXPECT_EQ(fetches[i].response.response_type, | 374 EXPECT_EQ(fetches[i].response.response_type, |
| 372 blink::WebServiceWorkerResponseTypeOpaque); | 375 blink::WebServiceWorkerResponseTypeDefault); |
| 373 EXPECT_TRUE(fetches[i].response.headers.empty()); | 376 EXPECT_TRUE(fetches[i].response.headers.empty()); |
| 374 EXPECT_EQ(fetches[i].response.error, | 377 EXPECT_EQ(fetches[i].response.error, |
| 375 blink::WebServiceWorkerResponseErrorUnknown); | 378 blink::WebServiceWorkerResponseErrorUnknown); |
| 376 | 379 |
| 377 // Verify that all properties have a sensible value. | 380 // Verify that all properties have a sensible value. |
| 378 EXPECT_FALSE(fetches[i].response.response_time.is_null()); | 381 EXPECT_FALSE(fetches[i].response.response_time.is_null()); |
| 379 | 382 |
| 380 // Verify that the response blobs have been populated. We cannot consume | 383 // Verify that the response blobs have been populated. We cannot consume |
| 381 // their data here since the handles have already been released. | 384 // their data here since the handles have already been released. |
| 382 ASSERT_FALSE(fetches[i].response.blob_uuid.empty()); | 385 ASSERT_FALSE(fetches[i].response.blob_uuid.empty()); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 const bool has_alternative_tag = | 525 const bool has_alternative_tag = |
| 523 tags[0] == kAlternativeTag || tags[1] == kAlternativeTag; | 526 tags[0] == kAlternativeTag || tags[1] == kAlternativeTag; |
| 524 | 527 |
| 525 EXPECT_TRUE(has_example_tag); | 528 EXPECT_TRUE(has_example_tag); |
| 526 EXPECT_TRUE(has_alternative_tag); | 529 EXPECT_TRUE(has_alternative_tag); |
| 527 } | 530 } |
| 528 } | 531 } |
| 529 | 532 |
| 530 } // namespace | 533 } // namespace |
| 531 } // namespace content | 534 } // namespace content |
| OLD | NEW |