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

Side by Side Diff: content/browser/service_worker/service_worker_cache_unittest.cc

Issue 649203005: [ServiceWorkerCache] Put should replace an existing entry to meet spec. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@staticize
Patch Set: Created 6 years, 2 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
« no previous file with comments | « content/browser/service_worker/service_worker_cache.cc ('k') | no next file » | 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 "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 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 base::Unretained(this), 321 base::Unretained(this),
322 base::Unretained(loop.get()))); 322 base::Unretained(loop.get())));
323 // The handle should be held by the cache now so the deref here should be 323 // The handle should be held by the cache now so the deref here should be
324 // okay. 324 // okay.
325 blob_handle_.reset(); 325 blob_handle_.reset();
326 loop->Run(); 326 loop->Run();
327 327
328 EXPECT_EQ(ServiceWorkerCache::ErrorTypeOK, callback_error_); 328 EXPECT_EQ(ServiceWorkerCache::ErrorTypeOK, callback_error_);
329 } 329 }
330 330
331 TEST_P(ServiceWorkerCacheTestP, PutReplace) {
332 EXPECT_TRUE(Put(body_request_, body_response_));
333 EXPECT_TRUE(Match(body_request_));
334 EXPECT_STREQ("http://example.com/body.html",
335 callback_response_->url.spec().c_str());
336
337 EXPECT_TRUE(Put(no_body_request_, no_body_response_));
338 EXPECT_TRUE(Match(no_body_request_));
339 EXPECT_STREQ("http://example.com/no_body.html",
340 callback_response_->url.spec().c_str());
341
342 EXPECT_TRUE(Put(body_request_, body_response_));
343 EXPECT_TRUE(Match(body_request_));
344 EXPECT_STREQ("http://example.com/body.html",
345 callback_response_->url.spec().c_str());
falken 2014/10/27 04:09:45 I'm a bit confused how this tests the new behavior
jkarlin 2014/10/27 12:15:28 Done. Thank you for catching this!
346 }
347
331 TEST_P(ServiceWorkerCacheTestP, MatchNoBody) { 348 TEST_P(ServiceWorkerCacheTestP, MatchNoBody) {
332 EXPECT_TRUE(Put(no_body_request_, no_body_response_)); 349 EXPECT_TRUE(Put(no_body_request_, no_body_response_));
333 EXPECT_TRUE(Match(no_body_request_)); 350 EXPECT_TRUE(Match(no_body_request_));
334 EXPECT_EQ(200, callback_response_->status_code); 351 EXPECT_EQ(200, callback_response_->status_code);
335 EXPECT_STREQ("OK", callback_response_->status_text.c_str()); 352 EXPECT_STREQ("OK", callback_response_->status_text.c_str());
336 EXPECT_STREQ("http://example.com/no_body.html", 353 EXPECT_STREQ("http://example.com/no_body.html",
337 callback_response_->url.spec().c_str()); 354 callback_response_->url.spec().c_str());
338 EXPECT_STREQ("", callback_response_->blob_uuid.c_str()); 355 EXPECT_STREQ("", callback_response_->blob_uuid.c_str());
339 EXPECT_EQ(0u, callback_response_->blob_size); 356 EXPECT_EQ(0u, callback_response_->blob_size);
340 } 357 }
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 request.headers["content-type"] = "foo"; 545 request.headers["content-type"] = "foo";
529 request.headers["Content-Type"] = "bar"; 546 request.headers["Content-Type"] = "bar";
530 EXPECT_EQ("bar", request.headers["content-type"]); 547 EXPECT_EQ("bar", request.headers["content-type"]);
531 } 548 }
532 549
533 INSTANTIATE_TEST_CASE_P(ServiceWorkerCacheTest, 550 INSTANTIATE_TEST_CASE_P(ServiceWorkerCacheTest,
534 ServiceWorkerCacheTestP, 551 ServiceWorkerCacheTestP,
535 ::testing::Values(false, true)); 552 ::testing::Values(false, true));
536 553
537 } // namespace content 554 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/service_worker/service_worker_cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698