| 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 "content/browser/service_worker/service_worker_cache.h" | 5 #include "content/browser/service_worker/service_worker_cache.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 cache_.reset(); | 86 cache_.reset(); |
| 87 base::RunLoop().RunUntilIdle(); | 87 base::RunLoop().RunUntilIdle(); |
| 88 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); | 88 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); |
| 89 base::RunLoop().RunUntilIdle(); | 89 base::RunLoop().RunUntilIdle(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 void CreateRequests(ChromeBlobStorageContext* blob_storage_context) { | 92 void CreateRequests(ChromeBlobStorageContext* blob_storage_context) { |
| 93 std::map<std::string, std::string> headers; | 93 std::map<std::string, std::string> headers; |
| 94 headers.insert(std::make_pair("a", "a")); | 94 headers.insert(std::make_pair("a", "a")); |
| 95 headers.insert(std::make_pair("b", "b")); | 95 headers.insert(std::make_pair("b", "b")); |
| 96 body_request_.reset(new ServiceWorkerFetchRequest( | 96 body_request_ = ServiceWorkerFetchRequest( |
| 97 GURL("http://example.com/body.html"), "GET", headers, GURL(""), false)); | 97 GURL("http://example.com/body.html"), "GET", headers, GURL(""), false); |
| 98 no_body_request_.reset( | 98 no_body_request_ = |
| 99 new ServiceWorkerFetchRequest(GURL("http://example.com/no_body.html"), | 99 ServiceWorkerFetchRequest(GURL("http://example.com/no_body.html"), |
| 100 "GET", | 100 "GET", |
| 101 headers, | 101 headers, |
| 102 GURL(""), | 102 GURL(""), |
| 103 false)); | 103 false); |
| 104 | 104 |
| 105 std::string expected_response; | 105 std::string expected_response; |
| 106 for (int i = 0; i < 100; ++i) | 106 for (int i = 0; i < 100; ++i) |
| 107 expected_blob_data_ += kTestData; | 107 expected_blob_data_ += kTestData; |
| 108 | 108 |
| 109 scoped_refptr<storage::BlobData> blob_data( | 109 scoped_refptr<storage::BlobData> blob_data( |
| 110 new storage::BlobData("blob-id:myblob")); | 110 new storage::BlobData("blob-id:myblob")); |
| 111 blob_data->AppendData(expected_blob_data_); | 111 blob_data->AppendData(expected_blob_data_); |
| 112 | 112 |
| 113 blob_handle_ = | 113 blob_handle_ = |
| 114 blob_storage_context->context()->AddFinishedBlob(blob_data.get()); | 114 blob_storage_context->context()->AddFinishedBlob(blob_data.get()); |
| 115 | 115 |
| 116 body_response_.reset( | 116 body_response_ = ServiceWorkerResponse(GURL("http://example.com/body.html"), |
| 117 new ServiceWorkerResponse(GURL("http://example.com/body.html"), | 117 200, |
| 118 200, | 118 "OK", |
| 119 "OK", | 119 headers, |
| 120 headers, | 120 blob_handle_->uuid()); |
| 121 blob_handle_->uuid())); | |
| 122 | 121 |
| 123 no_body_response_.reset(new ServiceWorkerResponse( | 122 no_body_response_ = ServiceWorkerResponse( |
| 124 GURL("http://example.com/no_body.html"), 200, "OK", headers, "")); | 123 GURL("http://example.com/no_body.html"), 200, "OK", headers, ""); |
| 125 } | 124 } |
| 126 | 125 |
| 127 void CreateBackend() { | 126 void CreateBackend() { |
| 128 scoped_ptr<base::RunLoop> loop(new base::RunLoop()); | 127 scoped_ptr<base::RunLoop> loop(new base::RunLoop()); |
| 129 cache_->CreateBackend(base::Bind(&ServiceWorkerCacheTest::ErrorTypeCallback, | 128 cache_->CreateBackend(base::Bind(&ServiceWorkerCacheTest::ErrorTypeCallback, |
| 130 base::Unretained(this), | 129 base::Unretained(this), |
| 131 base::Unretained(loop.get()))); | 130 base::Unretained(loop.get()))); |
| 132 loop->Run(); | 131 loop->Run(); |
| 133 EXPECT_EQ(ServiceWorkerCache::ErrorTypeOK, callback_error_); | 132 EXPECT_EQ(ServiceWorkerCache::ErrorTypeOK, callback_error_); |
| 134 } | 133 } |
| 135 | 134 |
| 136 bool Put(ServiceWorkerFetchRequest* request, | 135 scoped_ptr<ServiceWorkerFetchRequest> CopyFetchRequest( |
| 137 ServiceWorkerResponse* response) { | 136 const ServiceWorkerFetchRequest& request) { |
| 137 return make_scoped_ptr(new ServiceWorkerFetchRequest(request.url, |
| 138 request.method, |
| 139 request.headers, |
| 140 request.referrer, |
| 141 request.is_reload)); |
| 142 } |
| 143 |
| 144 scoped_ptr<ServiceWorkerResponse> CopyFetchResponse( |
| 145 const ServiceWorkerResponse& response) { |
| 146 return make_scoped_ptr(new ServiceWorkerResponse(response.url, |
| 147 response.status_code, |
| 148 response.status_text, |
| 149 response.headers, |
| 150 response.blob_uuid)); |
| 151 } |
| 152 |
| 153 bool Put(const ServiceWorkerFetchRequest& request, |
| 154 const ServiceWorkerResponse& response) { |
| 138 scoped_ptr<base::RunLoop> loop(new base::RunLoop()); | 155 scoped_ptr<base::RunLoop> loop(new base::RunLoop()); |
| 139 | 156 |
| 140 cache_->Put(request, | 157 cache_->Put(CopyFetchRequest(request), |
| 141 response, | 158 CopyFetchResponse(response), |
| 142 base::Bind(&ServiceWorkerCacheTest::ErrorTypeCallback, | 159 base::Bind(&ServiceWorkerCacheTest::ErrorTypeCallback, |
| 143 base::Unretained(this), | 160 base::Unretained(this), |
| 144 base::Unretained(loop.get()))); | 161 base::Unretained(loop.get()))); |
| 145 // TODO(jkarlin): These functions should use base::RunLoop().RunUntilIdle() | 162 // TODO(jkarlin): These functions should use base::RunLoop().RunUntilIdle() |
| 146 // once the cache uses a passed in MessageLoopProxy instead of the CACHE | 163 // once the cache uses a passed in MessageLoopProxy instead of the CACHE |
| 147 // thread. | 164 // thread. |
| 148 loop->Run(); | 165 loop->Run(); |
| 149 | 166 |
| 150 return callback_error_ == ServiceWorkerCache::ErrorTypeOK; | 167 return callback_error_ == ServiceWorkerCache::ErrorTypeOK; |
| 151 } | 168 } |
| 152 | 169 |
| 153 bool Match(ServiceWorkerFetchRequest* request) { | 170 bool Match(const ServiceWorkerFetchRequest& request) { |
| 154 scoped_ptr<base::RunLoop> loop(new base::RunLoop()); | 171 scoped_ptr<base::RunLoop> loop(new base::RunLoop()); |
| 155 | 172 |
| 156 cache_->Match(request, | 173 cache_->Match(CopyFetchRequest(request), |
| 157 base::Bind(&ServiceWorkerCacheTest::ResponseAndErrorCallback, | 174 base::Bind(&ServiceWorkerCacheTest::ResponseAndErrorCallback, |
| 158 base::Unretained(this), | 175 base::Unretained(this), |
| 159 base::Unretained(loop.get()))); | 176 base::Unretained(loop.get()))); |
| 160 loop->Run(); | 177 loop->Run(); |
| 161 | 178 |
| 162 return callback_error_ == ServiceWorkerCache::ErrorTypeOK; | 179 return callback_error_ == ServiceWorkerCache::ErrorTypeOK; |
| 163 } | 180 } |
| 164 | 181 |
| 165 bool Delete(ServiceWorkerFetchRequest* request) { | 182 bool Delete(const ServiceWorkerFetchRequest& request) { |
| 166 scoped_ptr<base::RunLoop> loop(new base::RunLoop()); | 183 scoped_ptr<base::RunLoop> loop(new base::RunLoop()); |
| 167 | 184 |
| 168 cache_->Delete(request, | 185 cache_->Delete(CopyFetchRequest(request), |
| 169 base::Bind(&ServiceWorkerCacheTest::ErrorTypeCallback, | 186 base::Bind(&ServiceWorkerCacheTest::ErrorTypeCallback, |
| 170 base::Unretained(this), | 187 base::Unretained(this), |
| 171 base::Unretained(loop.get()))); | 188 base::Unretained(loop.get()))); |
| 172 loop->Run(); | 189 loop->Run(); |
| 173 | 190 |
| 174 return callback_error_ == ServiceWorkerCache::ErrorTypeOK; | 191 return callback_error_ == ServiceWorkerCache::ErrorTypeOK; |
| 175 } | 192 } |
| 176 | 193 |
| 177 bool Keys() { | 194 bool Keys() { |
| 178 scoped_ptr<base::RunLoop> loop(new base::RunLoop()); | 195 scoped_ptr<base::RunLoop> loop(new base::RunLoop()); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 | 260 |
| 244 protected: | 261 protected: |
| 245 TestBrowserContext browser_context_; | 262 TestBrowserContext browser_context_; |
| 246 TestBrowserThreadBundle browser_thread_bundle_; | 263 TestBrowserThreadBundle browser_thread_bundle_; |
| 247 scoped_ptr<net::URLRequestJobFactoryImpl> url_request_job_factory_; | 264 scoped_ptr<net::URLRequestJobFactoryImpl> url_request_job_factory_; |
| 248 storage::BlobStorageContext* blob_storage_context_; | 265 storage::BlobStorageContext* blob_storage_context_; |
| 249 | 266 |
| 250 base::ScopedTempDir temp_dir_; | 267 base::ScopedTempDir temp_dir_; |
| 251 scoped_ptr<ServiceWorkerCache> cache_; | 268 scoped_ptr<ServiceWorkerCache> cache_; |
| 252 | 269 |
| 253 scoped_ptr<ServiceWorkerFetchRequest> body_request_; | 270 ServiceWorkerFetchRequest body_request_; |
| 254 scoped_ptr<ServiceWorkerResponse> body_response_; | 271 ServiceWorkerResponse body_response_; |
| 255 scoped_ptr<ServiceWorkerFetchRequest> no_body_request_; | 272 ServiceWorkerFetchRequest no_body_request_; |
| 256 scoped_ptr<ServiceWorkerResponse> no_body_response_; | 273 ServiceWorkerResponse no_body_response_; |
| 257 scoped_ptr<storage::BlobDataHandle> blob_handle_; | 274 scoped_ptr<storage::BlobDataHandle> blob_handle_; |
| 258 std::string expected_blob_data_; | 275 std::string expected_blob_data_; |
| 259 | 276 |
| 260 ServiceWorkerCache::ErrorType callback_error_; | 277 ServiceWorkerCache::ErrorType callback_error_; |
| 261 scoped_ptr<ServiceWorkerResponse> callback_response_; | 278 scoped_ptr<ServiceWorkerResponse> callback_response_; |
| 262 scoped_ptr<storage::BlobDataHandle> callback_response_data_; | 279 scoped_ptr<storage::BlobDataHandle> callback_response_data_; |
| 263 std::vector<std::string> callback_strings_; | 280 std::vector<std::string> callback_strings_; |
| 264 }; | 281 }; |
| 265 | 282 |
| 266 class ServiceWorkerCacheTestP : public ServiceWorkerCacheTest, | 283 class ServiceWorkerCacheTestP : public ServiceWorkerCacheTest, |
| 267 public testing::WithParamInterface<bool> { | 284 public testing::WithParamInterface<bool> { |
| 268 virtual bool MemoryOnly() OVERRIDE { return !GetParam(); } | 285 virtual bool MemoryOnly() OVERRIDE { return !GetParam(); } |
| 269 }; | 286 }; |
| 270 | 287 |
| 271 TEST_P(ServiceWorkerCacheTestP, PutNoBody) { | 288 TEST_P(ServiceWorkerCacheTestP, PutNoBody) { |
| 272 EXPECT_TRUE(Put(no_body_request_.get(), no_body_response_.get())); | 289 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); |
| 273 } | 290 } |
| 274 | 291 |
| 275 TEST_P(ServiceWorkerCacheTestP, PutBody) { | 292 TEST_P(ServiceWorkerCacheTestP, PutBody) { |
| 276 EXPECT_TRUE(Put(body_request_.get(), body_response_.get())); | 293 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 277 } | 294 } |
| 278 | 295 |
| 279 TEST_P(ServiceWorkerCacheTestP, PutBodyDropBlobRef) { | 296 TEST_P(ServiceWorkerCacheTestP, PutBodyDropBlobRef) { |
| 280 scoped_ptr<base::RunLoop> loop(new base::RunLoop()); | 297 scoped_ptr<base::RunLoop> loop(new base::RunLoop()); |
| 281 cache_->Put(body_request_.get(), | 298 cache_->Put(CopyFetchRequest(body_request_), |
| 282 body_response_.get(), | 299 CopyFetchResponse(body_response_), |
| 283 base::Bind(&ServiceWorkerCacheTestP::ErrorTypeCallback, | 300 base::Bind(&ServiceWorkerCacheTestP::ErrorTypeCallback, |
| 284 base::Unretained(this), | 301 base::Unretained(this), |
| 285 base::Unretained(loop.get()))); | 302 base::Unretained(loop.get()))); |
| 286 // The handle should be held by the cache now so the deref here should be | 303 // The handle should be held by the cache now so the deref here should be |
| 287 // okay. | 304 // okay. |
| 288 blob_handle_.reset(); | 305 blob_handle_.reset(); |
| 289 loop->Run(); | 306 loop->Run(); |
| 290 | 307 |
| 291 EXPECT_EQ(ServiceWorkerCache::ErrorTypeOK, callback_error_); | 308 EXPECT_EQ(ServiceWorkerCache::ErrorTypeOK, callback_error_); |
| 292 } | 309 } |
| 293 | 310 |
| 294 TEST_P(ServiceWorkerCacheTestP, MatchNoBody) { | 311 TEST_P(ServiceWorkerCacheTestP, MatchNoBody) { |
| 295 EXPECT_TRUE(Put(no_body_request_.get(), no_body_response_.get())); | 312 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); |
| 296 EXPECT_TRUE(Match(no_body_request_.get())); | 313 EXPECT_TRUE(Match(no_body_request_)); |
| 297 EXPECT_EQ(200, callback_response_->status_code); | 314 EXPECT_EQ(200, callback_response_->status_code); |
| 298 EXPECT_STREQ("OK", callback_response_->status_text.c_str()); | 315 EXPECT_STREQ("OK", callback_response_->status_text.c_str()); |
| 299 EXPECT_STREQ("http://example.com/no_body.html", | 316 EXPECT_STREQ("http://example.com/no_body.html", |
| 300 callback_response_->url.spec().c_str()); | 317 callback_response_->url.spec().c_str()); |
| 301 } | 318 } |
| 302 | 319 |
| 303 TEST_P(ServiceWorkerCacheTestP, MatchBody) { | 320 TEST_P(ServiceWorkerCacheTestP, MatchBody) { |
| 304 EXPECT_TRUE(Put(body_request_.get(), body_response_.get())); | 321 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 305 EXPECT_TRUE(Match(body_request_.get())); | 322 EXPECT_TRUE(Match(body_request_)); |
| 306 EXPECT_EQ(200, callback_response_->status_code); | 323 EXPECT_EQ(200, callback_response_->status_code); |
| 307 EXPECT_STREQ("OK", callback_response_->status_text.c_str()); | 324 EXPECT_STREQ("OK", callback_response_->status_text.c_str()); |
| 308 EXPECT_STREQ("http://example.com/body.html", | 325 EXPECT_STREQ("http://example.com/body.html", |
| 309 callback_response_->url.spec().c_str()); | 326 callback_response_->url.spec().c_str()); |
| 310 std::string response_body; | 327 std::string response_body; |
| 311 CopyBody(callback_response_data_.get(), &response_body); | 328 CopyBody(callback_response_data_.get(), &response_body); |
| 312 EXPECT_STREQ(expected_blob_data_.c_str(), response_body.c_str()); | 329 EXPECT_STREQ(expected_blob_data_.c_str(), response_body.c_str()); |
| 313 } | 330 } |
| 314 | 331 |
| 315 TEST_P(ServiceWorkerCacheTestP, EmptyKeys) { | 332 TEST_P(ServiceWorkerCacheTestP, EmptyKeys) { |
| 316 EXPECT_TRUE(Keys()); | 333 EXPECT_TRUE(Keys()); |
| 317 EXPECT_EQ(0u, callback_strings_.size()); | 334 EXPECT_EQ(0u, callback_strings_.size()); |
| 318 } | 335 } |
| 319 | 336 |
| 320 TEST_P(ServiceWorkerCacheTestP, TwoKeys) { | 337 TEST_P(ServiceWorkerCacheTestP, TwoKeys) { |
| 321 EXPECT_TRUE(Put(no_body_request_.get(), no_body_response_.get())); | 338 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); |
| 322 EXPECT_TRUE(Put(body_request_.get(), body_response_.get())); | 339 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 323 EXPECT_TRUE(Keys()); | 340 EXPECT_TRUE(Keys()); |
| 324 EXPECT_EQ(2u, callback_strings_.size()); | 341 EXPECT_EQ(2u, callback_strings_.size()); |
| 325 std::vector<std::string> expected_keys; | 342 std::vector<std::string> expected_keys; |
| 326 expected_keys.push_back(no_body_request_->url.spec()); | 343 expected_keys.push_back(no_body_request_.url.spec()); |
| 327 expected_keys.push_back(body_request_->url.spec()); | 344 expected_keys.push_back(body_request_.url.spec()); |
| 328 EXPECT_TRUE(VerifyKeys(expected_keys)); | 345 EXPECT_TRUE(VerifyKeys(expected_keys)); |
| 329 } | 346 } |
| 330 | 347 |
| 331 TEST_P(ServiceWorkerCacheTestP, TwoKeysThenOne) { | 348 TEST_P(ServiceWorkerCacheTestP, TwoKeysThenOne) { |
| 332 EXPECT_TRUE(Put(no_body_request_.get(), no_body_response_.get())); | 349 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); |
| 333 EXPECT_TRUE(Put(body_request_.get(), body_response_.get())); | 350 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 334 EXPECT_TRUE(Keys()); | 351 EXPECT_TRUE(Keys()); |
| 335 EXPECT_EQ(2u, callback_strings_.size()); | 352 EXPECT_EQ(2u, callback_strings_.size()); |
| 336 std::vector<std::string> expected_keys; | 353 std::vector<std::string> expected_keys; |
| 337 expected_keys.push_back(no_body_request_->url.spec()); | 354 expected_keys.push_back(no_body_request_.url.spec()); |
| 338 expected_keys.push_back(body_request_->url.spec()); | 355 expected_keys.push_back(body_request_.url.spec()); |
| 339 EXPECT_TRUE(VerifyKeys(expected_keys)); | 356 EXPECT_TRUE(VerifyKeys(expected_keys)); |
| 340 | 357 |
| 341 EXPECT_TRUE(Delete(body_request_.get())); | 358 EXPECT_TRUE(Delete(body_request_)); |
| 342 EXPECT_TRUE(Keys()); | 359 EXPECT_TRUE(Keys()); |
| 343 EXPECT_EQ(1u, callback_strings_.size()); | 360 EXPECT_EQ(1u, callback_strings_.size()); |
| 344 std::vector<std::string> expected_key; | 361 std::vector<std::string> expected_key; |
| 345 expected_key.push_back(no_body_request_->url.spec()); | 362 expected_key.push_back(no_body_request_.url.spec()); |
| 346 EXPECT_TRUE(VerifyKeys(expected_key)); | 363 EXPECT_TRUE(VerifyKeys(expected_key)); |
| 347 } | 364 } |
| 348 | 365 |
| 349 // TODO(jkarlin): Once SimpleCache is working bug-free on Windows reenable these | 366 // TODO(jkarlin): Once SimpleCache is working bug-free on Windows reenable these |
| 350 // tests. In the meanwhile we know that Windows operations will be a little | 367 // tests. In the meanwhile we know that Windows operations will be a little |
| 351 // flaky (though not crashy). See https://crbug.com/409109 | 368 // flaky (though not crashy). See https://crbug.com/409109 |
| 352 #ifndef OS_WIN | 369 #ifndef OS_WIN |
| 353 TEST_P(ServiceWorkerCacheTestP, DeleteNoBody) { | 370 TEST_P(ServiceWorkerCacheTestP, DeleteNoBody) { |
| 354 EXPECT_TRUE(Put(no_body_request_.get(), no_body_response_.get())); | 371 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); |
| 355 EXPECT_TRUE(Match(no_body_request_.get())); | 372 EXPECT_TRUE(Match(no_body_request_)); |
| 356 EXPECT_TRUE(Delete(no_body_request_.get())); | 373 EXPECT_TRUE(Delete(no_body_request_)); |
| 357 EXPECT_FALSE(Match(no_body_request_.get())); | 374 EXPECT_FALSE(Match(no_body_request_)); |
| 358 EXPECT_FALSE(Delete(no_body_request_.get())); | 375 EXPECT_FALSE(Delete(no_body_request_)); |
| 359 EXPECT_TRUE(Put(no_body_request_.get(), no_body_response_.get())); | 376 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); |
| 360 EXPECT_TRUE(Match(no_body_request_.get())); | 377 EXPECT_TRUE(Match(no_body_request_)); |
| 361 EXPECT_TRUE(Delete(no_body_request_.get())); | 378 EXPECT_TRUE(Delete(no_body_request_)); |
| 362 } | 379 } |
| 363 | 380 |
| 364 TEST_P(ServiceWorkerCacheTestP, DeleteBody) { | 381 TEST_P(ServiceWorkerCacheTestP, DeleteBody) { |
| 365 EXPECT_TRUE(Put(body_request_.get(), body_response_.get())); | 382 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 366 EXPECT_TRUE(Match(body_request_.get())); | 383 EXPECT_TRUE(Match(body_request_)); |
| 367 EXPECT_TRUE(Delete(body_request_.get())); | 384 EXPECT_TRUE(Delete(body_request_)); |
| 368 EXPECT_FALSE(Match(body_request_.get())); | 385 EXPECT_FALSE(Match(body_request_)); |
| 369 EXPECT_FALSE(Delete(body_request_.get())); | 386 EXPECT_FALSE(Delete(body_request_)); |
| 370 EXPECT_TRUE(Put(body_request_.get(), body_response_.get())); | 387 EXPECT_TRUE(Put(body_request_, body_response_)); |
| 371 EXPECT_TRUE(Match(body_request_.get())); | 388 EXPECT_TRUE(Match(body_request_)); |
| 372 EXPECT_TRUE(Delete(body_request_.get())); | 389 EXPECT_TRUE(Delete(body_request_)); |
| 373 } | 390 } |
| 374 | 391 |
| 375 TEST_P(ServiceWorkerCacheTestP, QuickStressNoBody) { | 392 TEST_P(ServiceWorkerCacheTestP, QuickStressNoBody) { |
| 376 for (int i = 0; i < 100; ++i) { | 393 for (int i = 0; i < 100; ++i) { |
| 377 EXPECT_FALSE(Match(no_body_request_.get())); | 394 EXPECT_FALSE(Match(no_body_request_)); |
| 378 EXPECT_TRUE(Put(no_body_request_.get(), no_body_response_.get())); | 395 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); |
| 379 EXPECT_TRUE(Match(no_body_request_.get())); | 396 EXPECT_TRUE(Match(no_body_request_)); |
| 380 EXPECT_TRUE(Delete(no_body_request_.get())); | 397 EXPECT_TRUE(Delete(no_body_request_)); |
| 381 } | 398 } |
| 382 } | 399 } |
| 383 | 400 |
| 384 TEST_P(ServiceWorkerCacheTestP, QuickStressBody) { | 401 TEST_P(ServiceWorkerCacheTestP, QuickStressBody) { |
| 385 for (int i = 0; i < 100; ++i) { | 402 for (int i = 0; i < 100; ++i) { |
| 386 ASSERT_FALSE(Match(body_request_.get())); | 403 ASSERT_FALSE(Match(body_request_)); |
| 387 ASSERT_TRUE(Put(body_request_.get(), body_response_.get())); | 404 ASSERT_TRUE(Put(body_request_, body_response_)); |
| 388 ASSERT_TRUE(Match(body_request_.get())); | 405 ASSERT_TRUE(Match(body_request_)); |
| 389 ASSERT_TRUE(Delete(body_request_.get())); | 406 ASSERT_TRUE(Delete(body_request_)); |
| 390 } | 407 } |
| 391 } | 408 } |
| 392 #endif // OS_WIN | 409 #endif // OS_WIN |
| 393 | 410 |
| 394 INSTANTIATE_TEST_CASE_P(ServiceWorkerCacheTest, | 411 INSTANTIATE_TEST_CASE_P(ServiceWorkerCacheTest, |
| 395 ServiceWorkerCacheTestP, | 412 ServiceWorkerCacheTestP, |
| 396 ::testing::Values(false, true)); | 413 ::testing::Values(false, true)); |
| 397 | 414 |
| 398 } // namespace content | 415 } // namespace content |
| OLD | NEW |