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

Side by Side Diff: webkit/appcache/appcache_response_unittest.cc

Issue 300043: MockAppCacheStorage implemenation (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authos. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authos. 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/compiler_specific.h" 5 #include "base/compiler_specific.h"
6 #include "base/pickle.h" 6 #include "base/pickle.h"
7 #include "base/thread.h" 7 #include "base/thread.h"
8 #include "base/waitable_event.h" 8 #include "base/waitable_event.h"
9 #include "net/base/io_buffer.h" 9 #include "net/base/io_buffer.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 if (*data != value) 280 if (*data != value)
281 return false; 281 return false;
282 } 282 }
283 return true; 283 return true;
284 } 284 }
285 285
286 // Individual Tests --------------------------------------------------------- 286 // Individual Tests ---------------------------------------------------------
287 // Most of the individual tests involve multiple async steps. Each test 287 // Most of the individual tests involve multiple async steps. Each test
288 // is delineated with a section header. 288 // is delineated with a section header.
289 289
290 // DelegateReferences -------------------------------------------------------
291 // TODO(michaeln): maybe this one belongs in appcache_storage_unittest.cc
292 void DelegateReferences() {
293 typedef scoped_refptr<AppCacheStorage::DelegateReference>
294 ScopedDelegateReference;
295 MockStorageDelegate delegate(this);
296 ScopedDelegateReference delegate_reference1;
297 ScopedDelegateReference delegate_reference2;
298 290
299 EXPECT_FALSE(service_->storage()->GetDelegateReference(&delegate));
300
301 delegate_reference1 =
302 service_->storage()->GetOrCreateDelegateReference(&delegate);
303 EXPECT_TRUE(delegate_reference1.get());
304 EXPECT_TRUE(delegate_reference1->HasOneRef());
305 EXPECT_TRUE(service_->storage()->GetDelegateReference(&delegate));
306 EXPECT_EQ(&delegate,
307 service_->storage()->GetDelegateReference(&delegate)->delegate);
308 EXPECT_EQ(service_->storage()->GetDelegateReference(&delegate),
309 service_->storage()->GetOrCreateDelegateReference(&delegate));
310 delegate_reference1 = NULL;
311 EXPECT_FALSE(service_->storage()->GetDelegateReference(&delegate));
312
313 delegate_reference1 =
314 service_->storage()->GetOrCreateDelegateReference(&delegate);
315 service_->storage()->CancelDelegateCallbacks(&delegate);
316 EXPECT_TRUE(delegate_reference1.get());
317 EXPECT_TRUE(delegate_reference1->HasOneRef());
318 EXPECT_FALSE(delegate_reference1->delegate);
319 EXPECT_FALSE(service_->storage()->GetDelegateReference(&delegate));
320
321 delegate_reference2 =
322 service_->storage()->GetOrCreateDelegateReference(&delegate);
323 EXPECT_TRUE(delegate_reference2.get());
324 EXPECT_TRUE(delegate_reference2->HasOneRef());
325 EXPECT_EQ(&delegate, delegate_reference2->delegate);
326 EXPECT_NE(delegate_reference1.get(), delegate_reference2.get());
327
328 TestFinished();
329 }
330 291
331 // ReadNonExistentResponse ------------------------------------------- 292 // ReadNonExistentResponse -------------------------------------------
332 void ReadNonExistentResponse() { 293 void ReadNonExistentResponse() {
333 // 1. Attempt to ReadInfo 294 // 1. Attempt to ReadInfo
334 // 2. Attempt to ReadData 295 // 2. Attempt to ReadData
335 296
336 reader_.reset(service_->storage()->CreateResponseReader( 297 reader_.reset(service_->storage()->CreateResponseReader(
337 GURL(), kNoSuchResponseId)); 298 GURL(), kNoSuchResponseId));
338 299
339 // Push tasks in reverse order 300 // Push tasks in reverse order
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 bool should_delete_writer_in_completion_callback_; 634 bool should_delete_writer_in_completion_callback_;
674 int writer_deletion_count_down_; 635 int writer_deletion_count_down_;
675 bool write_callback_was_called_; 636 bool write_callback_was_called_;
676 637
677 static scoped_ptr<base::Thread> io_thread_; 638 static scoped_ptr<base::Thread> io_thread_;
678 }; 639 };
679 640
680 // static 641 // static
681 scoped_ptr<base::Thread> AppCacheResponseTest::io_thread_; 642 scoped_ptr<base::Thread> AppCacheResponseTest::io_thread_;
682 643
683 TEST_F(AppCacheResponseTest, DelegateReferences) {
684 RunTestOnIOThread(&AppCacheResponseTest::DelegateReferences);
685 }
686
687 TEST_F(AppCacheResponseTest, ReadNonExistentResponse) { 644 TEST_F(AppCacheResponseTest, ReadNonExistentResponse) {
688 RunTestOnIOThread(&AppCacheResponseTest::ReadNonExistentResponse); 645 RunTestOnIOThread(&AppCacheResponseTest::ReadNonExistentResponse);
689 } 646 }
690 647
691 TEST_F(AppCacheResponseTest, LoadResponseInfo_Miss) { 648 TEST_F(AppCacheResponseTest, LoadResponseInfo_Miss) {
692 RunTestOnIOThread(&AppCacheResponseTest::LoadResponseInfo_Miss); 649 RunTestOnIOThread(&AppCacheResponseTest::LoadResponseInfo_Miss);
693 } 650 }
694 651
695 TEST_F(AppCacheResponseTest, LoadResponseInfo_Hit) { 652 TEST_F(AppCacheResponseTest, LoadResponseInfo_Hit) {
696 RunTestOnIOThread(&AppCacheResponseTest::LoadResponseInfo_Hit); 653 RunTestOnIOThread(&AppCacheResponseTest::LoadResponseInfo_Hit);
(...skipping 10 matching lines...) Expand all
707 TEST_F(AppCacheResponseTest, DeleteWithinCallbacks) { 664 TEST_F(AppCacheResponseTest, DeleteWithinCallbacks) {
708 RunTestOnIOThread(&AppCacheResponseTest::DeleteWithinCallbacks); 665 RunTestOnIOThread(&AppCacheResponseTest::DeleteWithinCallbacks);
709 } 666 }
710 667
711 TEST_F(AppCacheResponseTest, DeleteWithIOPending) { 668 TEST_F(AppCacheResponseTest, DeleteWithIOPending) {
712 RunTestOnIOThread(&AppCacheResponseTest::DeleteWithIOPending); 669 RunTestOnIOThread(&AppCacheResponseTest::DeleteWithIOPending);
713 } 670 }
714 671
715 } // namespace appcache 672 } // namespace appcache
716 673
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698