OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "base/threading/thread.h" | 8 #include "base/threading/thread.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
11 #include "net/http/http_response_headers.h" | 11 #include "net/http/http_response_headers.h" |
12 #include "net/url_request/url_request_error_job.h" | 12 #include "net/url_request/url_request_error_job.h" |
13 #include "net/url_request/url_request_job_factory.h" | 13 #include "net/url_request/url_request_job_factory.h" |
14 #include "net/url_request/url_request_test_job.h" | 14 #include "net/url_request/url_request_test_job.h" |
15 #include "net/url_request/url_request_test_util.h" | 15 #include "net/url_request/url_request_test_util.h" |
16 #include "webkit/appcache/appcache_group.h" | 16 #include "webkit/appcache/appcache_group.h" |
17 #include "webkit/appcache/appcache_host.h" | 17 #include "webkit/appcache/appcache_host.h" |
18 #include "webkit/appcache/appcache_policy.h" | |
19 #include "webkit/appcache/appcache_response.h" | 18 #include "webkit/appcache/appcache_response.h" |
20 #include "webkit/appcache/appcache_update_job.h" | 19 #include "webkit/appcache/appcache_update_job.h" |
21 #include "webkit/appcache/mock_appcache_service.h" | 20 #include "webkit/appcache/mock_appcache_service.h" |
22 | 21 |
23 namespace appcache { | 22 namespace appcache { |
24 class AppCacheUpdateJobTest; | 23 class AppCacheUpdateJobTest; |
25 | 24 |
26 namespace { | 25 namespace { |
27 | 26 |
28 const char kManifest1Contents[] = | 27 const char kManifest1Contents[] = |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 } | 543 } |
545 | 544 |
546 private: | 545 private: |
547 scoped_ptr<net::URLRequestJobFactory> job_factory_; | 546 scoped_ptr<net::URLRequestJobFactory> job_factory_; |
548 scoped_refptr<net::URLRequestContext> request_context_; | 547 scoped_refptr<net::URLRequestContext> request_context_; |
549 }; | 548 }; |
550 | 549 |
551 class AppCacheUpdateJobTest : public testing::Test, | 550 class AppCacheUpdateJobTest : public testing::Test, |
552 public AppCacheGroup::UpdateObserver { | 551 public AppCacheGroup::UpdateObserver { |
553 public: | 552 public: |
554 class MockAppCachePolicy : public AppCachePolicy { | |
555 public: | |
556 MockAppCachePolicy() | |
557 : can_create_return_value_(net::OK), return_immediately_(true), | |
558 callback_(NULL) { | |
559 } | |
560 | |
561 virtual bool CanLoadAppCache(const GURL& manifest_url) { | |
562 return true; | |
563 } | |
564 | |
565 virtual int CanCreateAppCache(const GURL& manifest_url, | |
566 net::CompletionCallback* callback) { | |
567 requested_manifest_url_ = manifest_url; | |
568 callback_ = callback; | |
569 if (return_immediately_) | |
570 return can_create_return_value_; | |
571 | |
572 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( | |
573 this, &MockAppCachePolicy::CompleteCanCreateAppCache)); | |
574 return net::ERR_IO_PENDING; | |
575 } | |
576 | |
577 void CompleteCanCreateAppCache() { | |
578 callback_->Run(can_create_return_value_); | |
579 } | |
580 | |
581 int can_create_return_value_; | |
582 bool return_immediately_; | |
583 GURL requested_manifest_url_; | |
584 net::CompletionCallback* callback_; | |
585 }; | |
586 | |
587 | |
588 AppCacheUpdateJobTest() | 553 AppCacheUpdateJobTest() |
589 : do_checks_after_update_finished_(false), | 554 : do_checks_after_update_finished_(false), |
590 expect_group_obsolete_(false), | 555 expect_group_obsolete_(false), |
591 expect_group_has_cache_(false), | 556 expect_group_has_cache_(false), |
592 expect_old_cache_(NULL), | 557 expect_old_cache_(NULL), |
593 expect_newest_cache_(NULL), | 558 expect_newest_cache_(NULL), |
594 expect_non_null_update_time_(false), | 559 expect_non_null_update_time_(false), |
595 tested_manifest_(NONE), | 560 tested_manifest_(NONE), |
596 tested_manifest_path_override_(NULL) { | 561 tested_manifest_path_override_(NULL) { |
597 io_thread_.reset(new IOThread("AppCacheUpdateJob IO test thread")); | 562 io_thread_.reset(new IOThread("AppCacheUpdateJob IO test thread")); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 EXPECT_EQ(expected, events.size()); | 602 EXPECT_EQ(expected, events.size()); |
638 EXPECT_EQ(expected, events[0].first.size()); | 603 EXPECT_EQ(expected, events[0].first.size()); |
639 EXPECT_EQ(host.host_id(), events[0].first[0]); | 604 EXPECT_EQ(host.host_id(), events[0].first[0]); |
640 EXPECT_EQ(CHECKING_EVENT, events[0].second); | 605 EXPECT_EQ(CHECKING_EVENT, events[0].second); |
641 | 606 |
642 // Abort as we're not testing actual URL fetches in this test. | 607 // Abort as we're not testing actual URL fetches in this test. |
643 delete update; | 608 delete update; |
644 UpdateFinished(); | 609 UpdateFinished(); |
645 } | 610 } |
646 | 611 |
647 void ImmediatelyBlockCacheAttemptTest() { | |
648 BlockCacheAttemptTest(true); | |
649 } | |
650 | |
651 void DelayedBlockCacheAttemptTest() { | |
652 BlockCacheAttemptTest(false); | |
653 } | |
654 | |
655 void BlockCacheAttemptTest(bool immediately) { | |
656 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); | |
657 | |
658 GURL manifest_url = GURL("http://failme"); | |
659 | |
660 // Setup to block the cache attempt immediately. | |
661 policy_.return_immediately_ = immediately; | |
662 policy_.can_create_return_value_ = net::ERR_ACCESS_DENIED; | |
663 | |
664 MakeService(); | |
665 group_ = new AppCacheGroup(service_.get(), manifest_url, | |
666 service_->storage()->NewGroupId()); | |
667 | |
668 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); | |
669 group_->update_job_ = update; | |
670 | |
671 MockFrontend mock_frontend; | |
672 AppCacheHost host(1, &mock_frontend, service_.get()); | |
673 | |
674 update->StartUpdate(&host, GURL()); | |
675 EXPECT_EQ(manifest_url, policy_.requested_manifest_url_); | |
676 | |
677 // Verify state. | |
678 EXPECT_EQ(AppCacheUpdateJob::CACHE_ATTEMPT, update->update_type_); | |
679 EXPECT_EQ(AppCacheUpdateJob::FETCH_MANIFEST, update->internal_state_); | |
680 EXPECT_EQ(AppCacheGroup::CHECKING, group_->update_status()); | |
681 | |
682 // Verify notifications. | |
683 MockFrontend::RaisedEvents& events = mock_frontend.raised_events_; | |
684 size_t expected = 1; | |
685 EXPECT_EQ(expected, events.size()); | |
686 EXPECT_EQ(1U, events[0].first.size()); | |
687 EXPECT_EQ(host.host_id(), events[0].first[0]); | |
688 EXPECT_EQ(CHECKING_EVENT, events[0].second); | |
689 | |
690 WaitForUpdateToFinish(); | |
691 } | |
692 | |
693 void StartUpgradeAttemptTest() { | 612 void StartUpgradeAttemptTest() { |
694 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); | 613 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); |
695 | 614 |
696 { | 615 { |
697 MakeService(); | 616 MakeService(); |
698 group_ = new AppCacheGroup(service_.get(), GURL("http://failme"), | 617 group_ = new AppCacheGroup(service_.get(), GURL("http://failme"), |
699 service_->storage()->NewGroupId()); | 618 service_->storage()->NewGroupId()); |
700 | 619 |
701 // Give the group some existing caches. | 620 // Give the group some existing caches. |
702 AppCache* cache1 = MakeCacheForGroup(1, 111); | 621 AppCache* cache1 = MakeCacheForGroup(1, 111); |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 EXPECT_TRUE(update->manifest_fetcher_ != NULL); | 970 EXPECT_TRUE(update->manifest_fetcher_ != NULL); |
1052 | 971 |
1053 WaitForUpdateToFinish(); | 972 WaitForUpdateToFinish(); |
1054 } | 973 } |
1055 | 974 |
1056 void BasicCacheAttemptSuccessTest() { | 975 void BasicCacheAttemptSuccessTest() { |
1057 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); | 976 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); |
1058 | 977 |
1059 GURL manifest_url = MockHttpServer::GetMockUrl("files/manifest1"); | 978 GURL manifest_url = MockHttpServer::GetMockUrl("files/manifest1"); |
1060 | 979 |
1061 // We also test the async AppCachePolicy return path in this test case. | |
1062 policy_.return_immediately_ = false; | |
1063 policy_.can_create_return_value_ = net::OK; | |
1064 | |
1065 MakeService(); | 980 MakeService(); |
1066 group_ = new AppCacheGroup( | 981 group_ = new AppCacheGroup( |
1067 service_.get(), manifest_url, | 982 service_.get(), manifest_url, |
1068 service_->storage()->NewGroupId()); | 983 service_->storage()->NewGroupId()); |
1069 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); | 984 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); |
1070 group_->update_job_ = update; | 985 group_->update_job_ = update; |
1071 | 986 |
1072 MockFrontend* frontend = MakeMockFrontend(); | 987 MockFrontend* frontend = MakeMockFrontend(); |
1073 AppCacheHost* host = MakeHost(1, frontend); | 988 AppCacheHost* host = MakeHost(1, frontend); |
1074 update->StartUpdate(host, GURL()); | 989 update->StartUpdate(host, GURL()); |
1075 EXPECT_EQ(manifest_url, policy_.requested_manifest_url_);; | |
1076 | 990 |
1077 // Set up checks for when update job finishes. | 991 // Set up checks for when update job finishes. |
1078 do_checks_after_update_finished_ = true; | 992 do_checks_after_update_finished_ = true; |
1079 expect_group_obsolete_ = false; | 993 expect_group_obsolete_ = false; |
1080 expect_group_has_cache_ = true; | 994 expect_group_has_cache_ = true; |
1081 tested_manifest_ = MANIFEST1; | 995 tested_manifest_ = MANIFEST1; |
1082 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), | 996 frontend->AddExpectedEvent(MockFrontend::HostIds(1, host->host_id()), |
1083 CHECKING_EVENT); | 997 CHECKING_EVENT); |
1084 | 998 |
1085 WaitForUpdateToFinish(); | 999 WaitForUpdateToFinish(); |
(...skipping 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1861 | 1775 |
1862 group_ = new AppCacheGroup( | 1776 group_ = new AppCacheGroup( |
1863 service_.get(), kManifestUrl, | 1777 service_.get(), kManifestUrl, |
1864 service_->storage()->NewGroupId()); | 1778 service_->storage()->NewGroupId()); |
1865 scoped_refptr<AppCache> cache( | 1779 scoped_refptr<AppCache> cache( |
1866 MakeCacheForGroup(service_->storage()->NewCacheId(), | 1780 MakeCacheForGroup(service_->storage()->NewCacheId(), |
1867 kManifestResponseId)); | 1781 kManifestResponseId)); |
1868 | 1782 |
1869 MockFrontend* frontend = MakeMockFrontend(); | 1783 MockFrontend* frontend = MakeMockFrontend(); |
1870 AppCacheHost* host = MakeHost(1, frontend); | 1784 AppCacheHost* host = MakeHost(1, frontend); |
| 1785 host->first_party_url_ = kManifestUrl; |
1871 host->SelectCache(MockHttpServer::GetMockUrl("files/empty1"), | 1786 host->SelectCache(MockHttpServer::GetMockUrl("files/empty1"), |
1872 kNoCacheId, kManifestUrl); | 1787 kNoCacheId, kManifestUrl); |
1873 | 1788 |
1874 // Set up checks for when update job finishes. | 1789 // Set up checks for when update job finishes. |
1875 do_checks_after_update_finished_ = true; | 1790 do_checks_after_update_finished_ = true; |
1876 tested_manifest_ = EMPTY_MANIFEST; | 1791 tested_manifest_ = EMPTY_MANIFEST; |
1877 tested_manifest_path_override_ = "files/notmodified"; | 1792 tested_manifest_path_override_ = "files/notmodified"; |
1878 expect_group_obsolete_ = false; | 1793 expect_group_obsolete_ = false; |
1879 expect_group_has_cache_ = true; | 1794 expect_group_has_cache_ = true; |
1880 expect_newest_cache_ = cache; // unchanged | 1795 expect_newest_cache_ = cache; // unchanged |
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2836 MakeService(); | 2751 MakeService(); |
2837 group_ = new AppCacheGroup( | 2752 group_ = new AppCacheGroup( |
2838 service_.get(), manifest_url, | 2753 service_.get(), manifest_url, |
2839 service_->storage()->NewGroupId()); | 2754 service_->storage()->NewGroupId()); |
2840 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); | 2755 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); |
2841 group_->update_job_ = update; | 2756 group_->update_job_ = update; |
2842 | 2757 |
2843 MockFrontend* frontend = MakeMockFrontend(); | 2758 MockFrontend* frontend = MakeMockFrontend(); |
2844 AppCacheHost* host = MakeHost(1, frontend); | 2759 AppCacheHost* host = MakeHost(1, frontend); |
2845 update->StartUpdate(host, GURL()); | 2760 update->StartUpdate(host, GURL()); |
2846 EXPECT_EQ(manifest_url, policy_.requested_manifest_url_); | |
2847 | 2761 |
2848 // Set up checks for when update job finishes. | 2762 // Set up checks for when update job finishes. |
2849 do_checks_after_update_finished_ = true; | 2763 do_checks_after_update_finished_ = true; |
2850 expect_group_obsolete_ = false; | 2764 expect_group_obsolete_ = false; |
2851 expect_group_has_cache_ = true; | 2765 expect_group_has_cache_ = true; |
2852 tested_manifest_ = NONE; | 2766 tested_manifest_ = NONE; |
2853 MockFrontend::HostIds host_ids(1, host->host_id()); | 2767 MockFrontend::HostIds host_ids(1, host->host_id()); |
2854 frontend->AddExpectedEvent(host_ids, CHECKING_EVENT); | 2768 frontend->AddExpectedEvent(host_ids, CHECKING_EVENT); |
2855 | 2769 |
2856 WaitForUpdateToFinish(); | 2770 WaitForUpdateToFinish(); |
2857 } | 2771 } |
2858 | 2772 |
2859 void CrossOriginHttpsDeniedTest() { | 2773 void CrossOriginHttpsDeniedTest() { |
2860 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); | 2774 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); |
2861 | 2775 |
2862 GURL manifest_url = MockHttpServer::GetMockHttpsUrl( | 2776 GURL manifest_url = MockHttpServer::GetMockHttpsUrl( |
2863 "files/invalid_cross_origin_https_manifest"); | 2777 "files/invalid_cross_origin_https_manifest"); |
2864 | 2778 |
2865 MakeService(); | 2779 MakeService(); |
2866 group_ = new AppCacheGroup( | 2780 group_ = new AppCacheGroup( |
2867 service_.get(), manifest_url, | 2781 service_.get(), manifest_url, |
2868 service_->storage()->NewGroupId()); | 2782 service_->storage()->NewGroupId()); |
2869 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); | 2783 AppCacheUpdateJob* update = new AppCacheUpdateJob(service_.get(), group_); |
2870 group_->update_job_ = update; | 2784 group_->update_job_ = update; |
2871 | 2785 |
2872 MockFrontend* frontend = MakeMockFrontend(); | 2786 MockFrontend* frontend = MakeMockFrontend(); |
2873 AppCacheHost* host = MakeHost(1, frontend); | 2787 AppCacheHost* host = MakeHost(1, frontend); |
2874 update->StartUpdate(host, GURL()); | 2788 update->StartUpdate(host, GURL()); |
2875 EXPECT_EQ(manifest_url, policy_.requested_manifest_url_); | |
2876 | 2789 |
2877 // Set up checks for when update job finishes. | 2790 // Set up checks for when update job finishes. |
2878 do_checks_after_update_finished_ = true; | 2791 do_checks_after_update_finished_ = true; |
2879 expect_group_obsolete_ = false; | 2792 expect_group_obsolete_ = false; |
2880 expect_group_has_cache_ = false; | 2793 expect_group_has_cache_ = false; |
2881 tested_manifest_ = NONE; | 2794 tested_manifest_ = NONE; |
2882 MockFrontend::HostIds host_ids(1, host->host_id()); | 2795 MockFrontend::HostIds host_ids(1, host->host_id()); |
2883 frontend->AddExpectedEvent(host_ids, CHECKING_EVENT); | 2796 frontend->AddExpectedEvent(host_ids, CHECKING_EVENT); |
2884 | 2797 |
2885 WaitForUpdateToFinish(); | 2798 WaitForUpdateToFinish(); |
2886 } | 2799 } |
2887 | 2800 |
2888 void WaitForUpdateToFinish() { | 2801 void WaitForUpdateToFinish() { |
2889 if (group_->update_status() == AppCacheGroup::IDLE) | 2802 if (group_->update_status() == AppCacheGroup::IDLE) |
2890 UpdateFinished(); | 2803 UpdateFinished(); |
2891 else | 2804 else |
2892 group_->AddUpdateObserver(this); | 2805 group_->AddUpdateObserver(this); |
2893 } | 2806 } |
2894 | 2807 |
2895 void OnUpdateComplete(AppCacheGroup* group) { | 2808 void OnUpdateComplete(AppCacheGroup* group) { |
2896 ASSERT_EQ(group_, group); | 2809 ASSERT_EQ(group_, group); |
2897 protect_newest_cache_ = group->newest_complete_cache(); | 2810 protect_newest_cache_ = group->newest_complete_cache(); |
2898 UpdateFinished(); | 2811 UpdateFinished(); |
2899 } | 2812 } |
2900 | 2813 |
2901 void OnContentBlocked(AppCacheGroup* group) { | |
2902 } | |
2903 | |
2904 void UpdateFinished() { | 2814 void UpdateFinished() { |
2905 // We unwind the stack prior to finishing up to let stack-based objects | 2815 // We unwind the stack prior to finishing up to let stack-based objects |
2906 // get deleted. | 2816 // get deleted. |
2907 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( | 2817 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( |
2908 this, &AppCacheUpdateJobTest::UpdateFinishedUnwound)); | 2818 this, &AppCacheUpdateJobTest::UpdateFinishedUnwound)); |
2909 } | 2819 } |
2910 | 2820 |
2911 void UpdateFinishedUnwound() { | 2821 void UpdateFinishedUnwound() { |
2912 EXPECT_EQ(AppCacheGroup::IDLE, group_->update_status()); | 2822 EXPECT_EQ(AppCacheGroup::IDLE, group_->update_status()); |
2913 EXPECT_TRUE(group_->update_job() == NULL); | 2823 EXPECT_TRUE(group_->update_job() == NULL); |
2914 if (do_checks_after_update_finished_) | 2824 if (do_checks_after_update_finished_) |
2915 VerifyExpectations(); | 2825 VerifyExpectations(); |
2916 | 2826 |
2917 // Clean up everything that was created on the IO thread. | 2827 // Clean up everything that was created on the IO thread. |
2918 protect_newest_cache_ = NULL; | 2828 protect_newest_cache_ = NULL; |
2919 group_ = NULL; | 2829 group_ = NULL; |
2920 STLDeleteContainerPointers(hosts_.begin(), hosts_.end()); | 2830 STLDeleteContainerPointers(hosts_.begin(), hosts_.end()); |
2921 STLDeleteContainerPointers(frontends_.begin(), frontends_.end()); | 2831 STLDeleteContainerPointers(frontends_.begin(), frontends_.end()); |
2922 response_infos_.clear(); | 2832 response_infos_.clear(); |
2923 service_.reset(NULL); | 2833 service_.reset(NULL); |
2924 | 2834 |
2925 event_->Signal(); | 2835 event_->Signal(); |
2926 } | 2836 } |
2927 | 2837 |
2928 void MakeService() { | 2838 void MakeService() { |
2929 service_.reset(new MockAppCacheService()); | 2839 service_.reset(new MockAppCacheService()); |
2930 service_->set_request_context(io_thread_->request_context()); | 2840 service_->set_request_context(io_thread_->request_context()); |
2931 service_->set_appcache_policy(&policy_); | |
2932 } | 2841 } |
2933 | 2842 |
2934 AppCache* MakeCacheForGroup(int64 cache_id, int64 manifest_response_id) { | 2843 AppCache* MakeCacheForGroup(int64 cache_id, int64 manifest_response_id) { |
2935 AppCache* cache = new AppCache(service_.get(), cache_id); | 2844 AppCache* cache = new AppCache(service_.get(), cache_id); |
2936 cache->set_complete(true); | 2845 cache->set_complete(true); |
2937 cache->set_update_time(base::Time::Now()); | 2846 cache->set_update_time(base::Time::Now()); |
2938 group_->AddCache(cache); | 2847 group_->AddCache(cache); |
2939 | 2848 |
2940 // Add manifest entry to cache. | 2849 // Add manifest entry to cache. |
2941 cache->AddEntry(group_->manifest_url(), | 2850 cache->AddEntry(group_->manifest_url(), |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3234 EMPTY_FILE_MANIFEST, | 3143 EMPTY_FILE_MANIFEST, |
3235 PENDING_MASTER_NO_UPDATE, | 3144 PENDING_MASTER_NO_UPDATE, |
3236 }; | 3145 }; |
3237 | 3146 |
3238 scoped_ptr<IOThread> io_thread_; | 3147 scoped_ptr<IOThread> io_thread_; |
3239 | 3148 |
3240 scoped_ptr<MockAppCacheService> service_; | 3149 scoped_ptr<MockAppCacheService> service_; |
3241 scoped_refptr<AppCacheGroup> group_; | 3150 scoped_refptr<AppCacheGroup> group_; |
3242 scoped_refptr<AppCache> protect_newest_cache_; | 3151 scoped_refptr<AppCache> protect_newest_cache_; |
3243 scoped_ptr<base::WaitableEvent> event_; | 3152 scoped_ptr<base::WaitableEvent> event_; |
3244 MockAppCachePolicy policy_; | |
3245 | 3153 |
3246 scoped_ptr<AppCacheResponseWriter> response_writer_; | 3154 scoped_ptr<AppCacheResponseWriter> response_writer_; |
3247 scoped_ptr<net::CompletionCallbackImpl<AppCacheUpdateJobTest> > | 3155 scoped_ptr<net::CompletionCallbackImpl<AppCacheUpdateJobTest> > |
3248 write_callback_; | 3156 write_callback_; |
3249 | 3157 |
3250 // Hosts used by an async test that need to live until update job finishes. | 3158 // Hosts used by an async test that need to live until update job finishes. |
3251 // Otherwise, test can put host on the stack instead of here. | 3159 // Otherwise, test can put host on the stack instead of here. |
3252 std::vector<AppCacheHost*> hosts_; | 3160 std::vector<AppCacheHost*> hosts_; |
3253 | 3161 |
3254 // Response infos used by an async test that need to live until update job | 3162 // Response infos used by an async test that need to live until update job |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3328 EXPECT_EQ(host.host_id(), events[1].first[0]); | 3236 EXPECT_EQ(host.host_id(), events[1].first[0]); |
3329 EXPECT_EQ(appcache::DOWNLOADING_EVENT, events[1].second); | 3237 EXPECT_EQ(appcache::DOWNLOADING_EVENT, events[1].second); |
3330 | 3238 |
3331 EXPECT_EQ(AppCacheGroup::DOWNLOADING, group->update_status()); | 3239 EXPECT_EQ(AppCacheGroup::DOWNLOADING, group->update_status()); |
3332 } | 3240 } |
3333 | 3241 |
3334 TEST_F(AppCacheUpdateJobTest, StartCacheAttempt) { | 3242 TEST_F(AppCacheUpdateJobTest, StartCacheAttempt) { |
3335 RunTestOnIOThread(&AppCacheUpdateJobTest::StartCacheAttemptTest); | 3243 RunTestOnIOThread(&AppCacheUpdateJobTest::StartCacheAttemptTest); |
3336 } | 3244 } |
3337 | 3245 |
3338 TEST_F(AppCacheUpdateJobTest, ImmediatelyBlockCacheAttemptTest) { | |
3339 RunTestOnIOThread(&AppCacheUpdateJobTest::ImmediatelyBlockCacheAttemptTest); | |
3340 } | |
3341 | |
3342 TEST_F(AppCacheUpdateJobTest, DelayedBlockCacheAttemptTest) { | |
3343 RunTestOnIOThread(&AppCacheUpdateJobTest::DelayedBlockCacheAttemptTest); | |
3344 } | |
3345 | |
3346 TEST_F(AppCacheUpdateJobTest, StartUpgradeAttempt) { | 3246 TEST_F(AppCacheUpdateJobTest, StartUpgradeAttempt) { |
3347 RunTestOnIOThread(&AppCacheUpdateJobTest::StartUpgradeAttemptTest); | 3247 RunTestOnIOThread(&AppCacheUpdateJobTest::StartUpgradeAttemptTest); |
3348 } | 3248 } |
3349 | 3249 |
3350 TEST_F(AppCacheUpdateJobTest, CacheAttemptFetchManifestFail) { | 3250 TEST_F(AppCacheUpdateJobTest, CacheAttemptFetchManifestFail) { |
3351 RunTestOnIOThread(&AppCacheUpdateJobTest::CacheAttemptFetchManifestFailTest); | 3251 RunTestOnIOThread(&AppCacheUpdateJobTest::CacheAttemptFetchManifestFailTest); |
3352 } | 3252 } |
3353 | 3253 |
3354 TEST_F(AppCacheUpdateJobTest, UpgradeFetchManifestFail) { | 3254 TEST_F(AppCacheUpdateJobTest, UpgradeFetchManifestFail) { |
3355 RunTestOnIOThread(&AppCacheUpdateJobTest::UpgradeFetchManifestFailTest); | 3255 RunTestOnIOThread(&AppCacheUpdateJobTest::UpgradeFetchManifestFailTest); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3543 | 3443 |
3544 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsDenied) { | 3444 TEST_F(AppCacheUpdateJobTest, CrossOriginHttpsDenied) { |
3545 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsDeniedTest); | 3445 RunTestOnIOThread(&AppCacheUpdateJobTest::CrossOriginHttpsDeniedTest); |
3546 } | 3446 } |
3547 | 3447 |
3548 } // namespace appcache | 3448 } // namespace appcache |
3549 | 3449 |
3550 // AppCacheUpdateJobTest is expected to always live longer than the | 3450 // AppCacheUpdateJobTest is expected to always live longer than the |
3551 // runnable methods. This lets us call NewRunnableMethod on its instances. | 3451 // runnable methods. This lets us call NewRunnableMethod on its instances. |
3552 DISABLE_RUNNABLE_METHOD_REFCOUNT(appcache::AppCacheUpdateJobTest); | 3452 DISABLE_RUNNABLE_METHOD_REFCOUNT(appcache::AppCacheUpdateJobTest); |
3553 DISABLE_RUNNABLE_METHOD_REFCOUNT( | |
3554 appcache::AppCacheUpdateJobTest::MockAppCachePolicy); | |
OLD | NEW |