OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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-inl.h" | 7 #include "base/stl_util-inl.h" |
8 #include "base/thread.h" | 8 #include "base/thread.h" |
9 #include "base/waitable_event.h" | 9 #include "base/waitable_event.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
(...skipping 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 expect_newest_cache_ = cache; // newest cache unaffected by update | 990 expect_newest_cache_ = cache; // newest cache unaffected by update |
991 MockFrontend::HostIds ids1(1, host1->host_id()); | 991 MockFrontend::HostIds ids1(1, host1->host_id()); |
992 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT); | 992 frontend1->AddExpectedEvent(ids1, CHECKING_EVENT); |
993 frontend1->AddExpectedEvent(ids1, NO_UPDATE_EVENT); | 993 frontend1->AddExpectedEvent(ids1, NO_UPDATE_EVENT); |
994 MockFrontend::HostIds ids2(1, host2->host_id()); | 994 MockFrontend::HostIds ids2(1, host2->host_id()); |
995 frontend2->AddExpectedEvent(ids2, CHECKING_EVENT); | 995 frontend2->AddExpectedEvent(ids2, CHECKING_EVENT); |
996 frontend2->AddExpectedEvent(ids2, NO_UPDATE_EVENT); | 996 frontend2->AddExpectedEvent(ids2, NO_UPDATE_EVENT); |
997 | 997 |
998 // Seed storage with expected manifest data. | 998 // Seed storage with expected manifest data. |
999 const std::string seed_data(kManifest1Contents); | 999 const std::string seed_data(kManifest1Contents); |
1000 scoped_refptr<net::StringIOBuffer> io_buffer = | 1000 scoped_refptr<net::StringIOBuffer> io_buffer( |
1001 new net::StringIOBuffer(seed_data); | 1001 new net::StringIOBuffer(seed_data)); |
1002 write_callback_.reset( | 1002 write_callback_.reset( |
1003 new net::CompletionCallbackImpl<AppCacheUpdateJobTest>(this, | 1003 new net::CompletionCallbackImpl<AppCacheUpdateJobTest>(this, |
1004 &AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData)); | 1004 &AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData)); |
1005 response_writer_->WriteData(io_buffer, seed_data.length(), | 1005 response_writer_->WriteData(io_buffer, seed_data.length(), |
1006 write_callback_.get()); | 1006 write_callback_.get()); |
1007 | 1007 |
1008 // Start update after data write completes asynchronously. | 1008 // Start update after data write completes asynchronously. |
1009 } | 1009 } |
1010 | 1010 |
1011 void StartUpdateAfterSeedingStorageData(int result) { | 1011 void StartUpdateAfterSeedingStorageData(int result) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 MockFrontend::HostIds ids2(1, host2->host_id()); | 1093 MockFrontend::HostIds ids2(1, host2->host_id()); |
1094 frontend2->AddExpectedEvent(ids2, CHECKING_EVENT); | 1094 frontend2->AddExpectedEvent(ids2, CHECKING_EVENT); |
1095 frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT); | 1095 frontend2->AddExpectedEvent(ids2, DOWNLOADING_EVENT); |
1096 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); | 1096 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); |
1097 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); | 1097 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); |
1098 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // final | 1098 frontend2->AddExpectedEvent(ids2, PROGRESS_EVENT); // final |
1099 frontend2->AddExpectedEvent(ids2, UPDATE_READY_EVENT); | 1099 frontend2->AddExpectedEvent(ids2, UPDATE_READY_EVENT); |
1100 | 1100 |
1101 // Seed storage with expected manifest data different from manifest1. | 1101 // Seed storage with expected manifest data different from manifest1. |
1102 const std::string seed_data("different"); | 1102 const std::string seed_data("different"); |
1103 scoped_refptr<net::StringIOBuffer> io_buffer = | 1103 scoped_refptr<net::StringIOBuffer> io_buffer( |
1104 new net::StringIOBuffer(seed_data); | 1104 new net::StringIOBuffer(seed_data)); |
1105 write_callback_.reset( | 1105 write_callback_.reset( |
1106 new net::CompletionCallbackImpl<AppCacheUpdateJobTest>(this, | 1106 new net::CompletionCallbackImpl<AppCacheUpdateJobTest>(this, |
1107 &AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData)); | 1107 &AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData)); |
1108 response_writer_->WriteData(io_buffer, seed_data.length(), | 1108 response_writer_->WriteData(io_buffer, seed_data.length(), |
1109 write_callback_.get()); | 1109 write_callback_.get()); |
1110 | 1110 |
1111 // Start update after data write completes asynchronously. | 1111 // Start update after data write completes asynchronously. |
1112 } | 1112 } |
1113 | 1113 |
1114 void UpgradeLoadFromNewestCacheTest() { | 1114 void UpgradeLoadFromNewestCacheTest() { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1155 const char data[] = | 1155 const char data[] = |
1156 "HTTP/1.1 200 OK\0" | 1156 "HTTP/1.1 200 OK\0" |
1157 "Cache-Control: max-age=8675309\0" | 1157 "Cache-Control: max-age=8675309\0" |
1158 "\0"; | 1158 "\0"; |
1159 net::HttpResponseHeaders* headers = | 1159 net::HttpResponseHeaders* headers = |
1160 new net::HttpResponseHeaders(std::string(data, arraysize(data))); | 1160 new net::HttpResponseHeaders(std::string(data, arraysize(data))); |
1161 net::HttpResponseInfo* response_info = new net::HttpResponseInfo(); | 1161 net::HttpResponseInfo* response_info = new net::HttpResponseInfo(); |
1162 response_info->request_time = base::Time::Now(); | 1162 response_info->request_time = base::Time::Now(); |
1163 response_info->response_time = base::Time::Now(); | 1163 response_info->response_time = base::Time::Now(); |
1164 response_info->headers = headers; // adds ref to headers | 1164 response_info->headers = headers; // adds ref to headers |
1165 scoped_refptr<HttpResponseInfoIOBuffer> io_buffer = | 1165 scoped_refptr<HttpResponseInfoIOBuffer> io_buffer( |
1166 new HttpResponseInfoIOBuffer(response_info); // adds ref to info | 1166 new HttpResponseInfoIOBuffer(response_info)); // adds ref to info |
1167 write_callback_.reset( | 1167 write_callback_.reset( |
1168 new net::CompletionCallbackImpl<AppCacheUpdateJobTest>(this, | 1168 new net::CompletionCallbackImpl<AppCacheUpdateJobTest>(this, |
1169 &AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData)); | 1169 &AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData)); |
1170 response_writer_->WriteInfo(io_buffer, write_callback_.get()); | 1170 response_writer_->WriteInfo(io_buffer, write_callback_.get()); |
1171 | 1171 |
1172 // Start update after data write completes asynchronously. | 1172 // Start update after data write completes asynchronously. |
1173 } | 1173 } |
1174 | 1174 |
1175 void UpgradeNoLoadFromNewestCacheTest() { | 1175 void UpgradeNoLoadFromNewestCacheTest() { |
1176 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); | 1176 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1213 const char data[] = | 1213 const char data[] = |
1214 "HTTP/1.1 200 OK\0" | 1214 "HTTP/1.1 200 OK\0" |
1215 "Expires: Thu, 01 Dec 1994 16:00:00 GMT\0" | 1215 "Expires: Thu, 01 Dec 1994 16:00:00 GMT\0" |
1216 "\0"; | 1216 "\0"; |
1217 net::HttpResponseHeaders* headers = | 1217 net::HttpResponseHeaders* headers = |
1218 new net::HttpResponseHeaders(std::string(data, arraysize(data))); | 1218 new net::HttpResponseHeaders(std::string(data, arraysize(data))); |
1219 net::HttpResponseInfo* response_info = new net::HttpResponseInfo(); | 1219 net::HttpResponseInfo* response_info = new net::HttpResponseInfo(); |
1220 response_info->request_time = base::Time::Now(); | 1220 response_info->request_time = base::Time::Now(); |
1221 response_info->response_time = base::Time::Now(); | 1221 response_info->response_time = base::Time::Now(); |
1222 response_info->headers = headers; // adds ref to headers | 1222 response_info->headers = headers; // adds ref to headers |
1223 scoped_refptr<HttpResponseInfoIOBuffer> io_buffer = | 1223 scoped_refptr<HttpResponseInfoIOBuffer> io_buffer( |
1224 new HttpResponseInfoIOBuffer(response_info); // adds ref to info | 1224 new HttpResponseInfoIOBuffer(response_info)); // adds ref to info |
1225 write_callback_.reset( | 1225 write_callback_.reset( |
1226 new net::CompletionCallbackImpl<AppCacheUpdateJobTest>(this, | 1226 new net::CompletionCallbackImpl<AppCacheUpdateJobTest>(this, |
1227 &AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData)); | 1227 &AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData)); |
1228 response_writer_->WriteInfo(io_buffer, write_callback_.get()); | 1228 response_writer_->WriteInfo(io_buffer, write_callback_.get()); |
1229 | 1229 |
1230 // Start update after data write completes asynchronously. | 1230 // Start update after data write completes asynchronously. |
1231 } | 1231 } |
1232 | 1232 |
1233 void UpgradeLoadFromNewestCacheVaryHeaderTest() { | 1233 void UpgradeLoadFromNewestCacheVaryHeaderTest() { |
1234 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); | 1234 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1271 "HTTP/1.1 200 OK\0" | 1271 "HTTP/1.1 200 OK\0" |
1272 "Cache-Control: max-age=8675309\0" | 1272 "Cache-Control: max-age=8675309\0" |
1273 "Vary: blah\0" | 1273 "Vary: blah\0" |
1274 "\0"; | 1274 "\0"; |
1275 net::HttpResponseHeaders* headers = | 1275 net::HttpResponseHeaders* headers = |
1276 new net::HttpResponseHeaders(std::string(data, arraysize(data))); | 1276 new net::HttpResponseHeaders(std::string(data, arraysize(data))); |
1277 net::HttpResponseInfo* response_info = new net::HttpResponseInfo(); | 1277 net::HttpResponseInfo* response_info = new net::HttpResponseInfo(); |
1278 response_info->request_time = base::Time::Now(); | 1278 response_info->request_time = base::Time::Now(); |
1279 response_info->response_time = base::Time::Now(); | 1279 response_info->response_time = base::Time::Now(); |
1280 response_info->headers = headers; // adds ref to headers | 1280 response_info->headers = headers; // adds ref to headers |
1281 scoped_refptr<HttpResponseInfoIOBuffer> io_buffer = | 1281 scoped_refptr<HttpResponseInfoIOBuffer> io_buffer( |
1282 new HttpResponseInfoIOBuffer(response_info); // adds ref to info | 1282 new HttpResponseInfoIOBuffer(response_info)); // adds ref to info |
1283 write_callback_.reset( | 1283 write_callback_.reset( |
1284 new net::CompletionCallbackImpl<AppCacheUpdateJobTest>(this, | 1284 new net::CompletionCallbackImpl<AppCacheUpdateJobTest>(this, |
1285 &AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData)); | 1285 &AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData)); |
1286 response_writer_->WriteInfo(io_buffer, write_callback_.get()); | 1286 response_writer_->WriteInfo(io_buffer, write_callback_.get()); |
1287 | 1287 |
1288 // Start update after data write completes asynchronously. | 1288 // Start update after data write completes asynchronously. |
1289 } | 1289 } |
1290 | 1290 |
1291 void UpgradeSuccessMergedTypesTest() { | 1291 void UpgradeSuccessMergedTypesTest() { |
1292 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); | 1292 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1822 "HTTP/1.1 200 OK\0" | 1822 "HTTP/1.1 200 OK\0" |
1823 "Content-type: text/cache-manifest\0" | 1823 "Content-type: text/cache-manifest\0" |
1824 "Last-Modified: Sat, 29 Oct 1994 19:43:31 GMT\0" | 1824 "Last-Modified: Sat, 29 Oct 1994 19:43:31 GMT\0" |
1825 "\0"; | 1825 "\0"; |
1826 const std::string kRawHeaders(kData, arraysize(kData)); | 1826 const std::string kRawHeaders(kData, arraysize(kData)); |
1827 MakeAppCacheResponseInfo(kManifestUrl, kManifestResponseId, kRawHeaders); | 1827 MakeAppCacheResponseInfo(kManifestUrl, kManifestResponseId, kRawHeaders); |
1828 | 1828 |
1829 group_ = new AppCacheGroup( | 1829 group_ = new AppCacheGroup( |
1830 service_.get(), kManifestUrl, | 1830 service_.get(), kManifestUrl, |
1831 service_->storage()->NewGroupId()); | 1831 service_->storage()->NewGroupId()); |
1832 scoped_refptr<AppCache> cache = | 1832 scoped_refptr<AppCache> cache( |
1833 MakeCacheForGroup(service_->storage()->NewCacheId(), | 1833 MakeCacheForGroup(service_->storage()->NewCacheId(), |
1834 kManifestResponseId); | 1834 kManifestResponseId)); |
1835 | 1835 |
1836 MockFrontend* frontend = MakeMockFrontend(); | 1836 MockFrontend* frontend = MakeMockFrontend(); |
1837 AppCacheHost* host = MakeHost(1, frontend); | 1837 AppCacheHost* host = MakeHost(1, frontend); |
1838 host->SelectCache(MockHttpServer::GetMockUrl("files/empty1"), | 1838 host->SelectCache(MockHttpServer::GetMockUrl("files/empty1"), |
1839 kNoCacheId, kManifestUrl); | 1839 kNoCacheId, kManifestUrl); |
1840 | 1840 |
1841 // Set up checks for when update job finishes. | 1841 // Set up checks for when update job finishes. |
1842 do_checks_after_update_finished_ = true; | 1842 do_checks_after_update_finished_ = true; |
1843 tested_manifest_ = EMPTY_MANIFEST; | 1843 tested_manifest_ = EMPTY_MANIFEST; |
1844 tested_manifest_path_override_ = "files/notmodified"; | 1844 tested_manifest_path_override_ = "files/notmodified"; |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2679 // Seed storage with expected manifest response info that will cause | 2679 // Seed storage with expected manifest response info that will cause |
2680 // an If-Modified-Since header to be put in the manifest fetch request. | 2680 // an If-Modified-Since header to be put in the manifest fetch request. |
2681 const char data[] = | 2681 const char data[] = |
2682 "HTTP/1.1 200 OK\0" | 2682 "HTTP/1.1 200 OK\0" |
2683 "Last-Modified: Sat, 29 Oct 1994 19:43:31 GMT\0" | 2683 "Last-Modified: Sat, 29 Oct 1994 19:43:31 GMT\0" |
2684 "\0"; | 2684 "\0"; |
2685 net::HttpResponseHeaders* headers = | 2685 net::HttpResponseHeaders* headers = |
2686 new net::HttpResponseHeaders(std::string(data, arraysize(data))); | 2686 new net::HttpResponseHeaders(std::string(data, arraysize(data))); |
2687 net::HttpResponseInfo* response_info = new net::HttpResponseInfo(); | 2687 net::HttpResponseInfo* response_info = new net::HttpResponseInfo(); |
2688 response_info->headers = headers; // adds ref to headers | 2688 response_info->headers = headers; // adds ref to headers |
2689 scoped_refptr<HttpResponseInfoIOBuffer> io_buffer = | 2689 scoped_refptr<HttpResponseInfoIOBuffer> io_buffer( |
2690 new HttpResponseInfoIOBuffer(response_info); // adds ref to info | 2690 new HttpResponseInfoIOBuffer(response_info)); // adds ref to info |
2691 write_callback_.reset( | 2691 write_callback_.reset( |
2692 new net::CompletionCallbackImpl<AppCacheUpdateJobTest>(this, | 2692 new net::CompletionCallbackImpl<AppCacheUpdateJobTest>(this, |
2693 &AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData)); | 2693 &AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData)); |
2694 response_writer_->WriteInfo(io_buffer, write_callback_.get()); | 2694 response_writer_->WriteInfo(io_buffer, write_callback_.get()); |
2695 | 2695 |
2696 // Start update after data write completes asynchronously. | 2696 // Start update after data write completes asynchronously. |
2697 } | 2697 } |
2698 | 2698 |
2699 void IfNoneMatchUpgradeTest() { | 2699 void IfNoneMatchUpgradeTest() { |
2700 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); | 2700 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2737 // Seed storage with expected manifest response info that will cause | 2737 // Seed storage with expected manifest response info that will cause |
2738 // an If-None-Match header to be put in the manifest fetch request. | 2738 // an If-None-Match header to be put in the manifest fetch request. |
2739 const char data[] = | 2739 const char data[] = |
2740 "HTTP/1.1 200 OK\0" | 2740 "HTTP/1.1 200 OK\0" |
2741 "ETag: \"LadeDade\"\0" | 2741 "ETag: \"LadeDade\"\0" |
2742 "\0"; | 2742 "\0"; |
2743 net::HttpResponseHeaders* headers = | 2743 net::HttpResponseHeaders* headers = |
2744 new net::HttpResponseHeaders(std::string(data, arraysize(data))); | 2744 new net::HttpResponseHeaders(std::string(data, arraysize(data))); |
2745 net::HttpResponseInfo* response_info = new net::HttpResponseInfo(); | 2745 net::HttpResponseInfo* response_info = new net::HttpResponseInfo(); |
2746 response_info->headers = headers; // adds ref to headers | 2746 response_info->headers = headers; // adds ref to headers |
2747 scoped_refptr<HttpResponseInfoIOBuffer> io_buffer = | 2747 scoped_refptr<HttpResponseInfoIOBuffer> io_buffer( |
2748 new HttpResponseInfoIOBuffer(response_info); // adds ref to info | 2748 new HttpResponseInfoIOBuffer(response_info)); // adds ref to info |
2749 write_callback_.reset( | 2749 write_callback_.reset( |
2750 new net::CompletionCallbackImpl<AppCacheUpdateJobTest>(this, | 2750 new net::CompletionCallbackImpl<AppCacheUpdateJobTest>(this, |
2751 &AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData)); | 2751 &AppCacheUpdateJobTest::StartUpdateAfterSeedingStorageData)); |
2752 response_writer_->WriteInfo(io_buffer, write_callback_.get()); | 2752 response_writer_->WriteInfo(io_buffer, write_callback_.get()); |
2753 | 2753 |
2754 // Start update after data write completes asynchronously. | 2754 // Start update after data write completes asynchronously. |
2755 } | 2755 } |
2756 | 2756 |
2757 void IfNoneMatchRefetchTest() { | 2757 void IfNoneMatchRefetchTest() { |
2758 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); | 2758 ASSERT_EQ(MessageLoop::TYPE_IO, MessageLoop::current()->type()); |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2888 AppCacheHost* host = new AppCacheHost(host_id, frontend, service_.get()); | 2888 AppCacheHost* host = new AppCacheHost(host_id, frontend, service_.get()); |
2889 hosts_.push_back(host); | 2889 hosts_.push_back(host); |
2890 return host; | 2890 return host; |
2891 } | 2891 } |
2892 | 2892 |
2893 AppCacheResponseInfo* MakeAppCacheResponseInfo( | 2893 AppCacheResponseInfo* MakeAppCacheResponseInfo( |
2894 const GURL& manifest_url, int64 response_id, | 2894 const GURL& manifest_url, int64 response_id, |
2895 const std::string& raw_headers) { | 2895 const std::string& raw_headers) { |
2896 net::HttpResponseInfo* http_info = new net::HttpResponseInfo(); | 2896 net::HttpResponseInfo* http_info = new net::HttpResponseInfo(); |
2897 http_info->headers = new net::HttpResponseHeaders(raw_headers); | 2897 http_info->headers = new net::HttpResponseHeaders(raw_headers); |
2898 scoped_refptr<AppCacheResponseInfo> info = | 2898 scoped_refptr<AppCacheResponseInfo> info( |
2899 new AppCacheResponseInfo(service_.get(), manifest_url, | 2899 new AppCacheResponseInfo(service_.get(), manifest_url, |
2900 response_id, http_info, 0); | 2900 response_id, http_info, 0)); |
2901 response_infos_.push_back(info); | 2901 response_infos_.push_back(info); |
2902 return info; | 2902 return info; |
2903 } | 2903 } |
2904 | 2904 |
2905 MockFrontend* MakeMockFrontend() { | 2905 MockFrontend* MakeMockFrontend() { |
2906 MockFrontend* frontend = new MockFrontend(); | 2906 MockFrontend* frontend = new MockFrontend(); |
2907 frontends_.push_back(frontend); | 2907 frontends_.push_back(frontend); |
2908 return frontend; | 2908 return frontend; |
2909 } | 2909 } |
2910 | 2910 |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3212 URLRequest::ProtocolFactory* old_factory_; | 3212 URLRequest::ProtocolFactory* old_factory_; |
3213 }; | 3213 }; |
3214 | 3214 |
3215 // static | 3215 // static |
3216 IOThread* AppCacheUpdateJobTest::io_thread_ = NULL; | 3216 IOThread* AppCacheUpdateJobTest::io_thread_ = NULL; |
3217 base::WaitableEvent* AppCacheUpdateJobTest::io_thread_shutdown_event_ = NULL; | 3217 base::WaitableEvent* AppCacheUpdateJobTest::io_thread_shutdown_event_ = NULL; |
3218 | 3218 |
3219 | 3219 |
3220 TEST_F(AppCacheUpdateJobTest, AlreadyChecking) { | 3220 TEST_F(AppCacheUpdateJobTest, AlreadyChecking) { |
3221 MockAppCacheService service; | 3221 MockAppCacheService service; |
3222 scoped_refptr<AppCacheGroup> group = | 3222 scoped_refptr<AppCacheGroup> group( |
3223 new AppCacheGroup(&service, GURL("http://manifesturl.com"), | 3223 new AppCacheGroup(&service, GURL("http://manifesturl.com"), |
3224 service.storage()->NewGroupId()); | 3224 service.storage()->NewGroupId())); |
3225 | 3225 |
3226 AppCacheUpdateJob update(&service, group); | 3226 AppCacheUpdateJob update(&service, group); |
3227 | 3227 |
3228 // Pretend group is in checking state. | 3228 // Pretend group is in checking state. |
3229 group->update_job_ = &update; | 3229 group->update_job_ = &update; |
3230 group->update_status_ = AppCacheGroup::CHECKING; | 3230 group->update_status_ = AppCacheGroup::CHECKING; |
3231 | 3231 |
3232 update.StartUpdate(NULL, GURL()); | 3232 update.StartUpdate(NULL, GURL()); |
3233 EXPECT_EQ(AppCacheGroup::CHECKING, group->update_status()); | 3233 EXPECT_EQ(AppCacheGroup::CHECKING, group->update_status()); |
3234 | 3234 |
3235 MockFrontend mock_frontend; | 3235 MockFrontend mock_frontend; |
3236 AppCacheHost host(1, &mock_frontend, &service); | 3236 AppCacheHost host(1, &mock_frontend, &service); |
3237 update.StartUpdate(&host, GURL()); | 3237 update.StartUpdate(&host, GURL()); |
3238 | 3238 |
3239 MockFrontend::RaisedEvents events = mock_frontend.raised_events_; | 3239 MockFrontend::RaisedEvents events = mock_frontend.raised_events_; |
3240 size_t expected = 1; | 3240 size_t expected = 1; |
3241 EXPECT_EQ(expected, events.size()); | 3241 EXPECT_EQ(expected, events.size()); |
3242 EXPECT_EQ(expected, events[0].first.size()); | 3242 EXPECT_EQ(expected, events[0].first.size()); |
3243 EXPECT_EQ(host.host_id(), events[0].first[0]); | 3243 EXPECT_EQ(host.host_id(), events[0].first[0]); |
3244 EXPECT_EQ(CHECKING_EVENT, events[0].second); | 3244 EXPECT_EQ(CHECKING_EVENT, events[0].second); |
3245 EXPECT_EQ(AppCacheGroup::CHECKING, group->update_status()); | 3245 EXPECT_EQ(AppCacheGroup::CHECKING, group->update_status()); |
3246 } | 3246 } |
3247 | 3247 |
3248 TEST_F(AppCacheUpdateJobTest, AlreadyDownloading) { | 3248 TEST_F(AppCacheUpdateJobTest, AlreadyDownloading) { |
3249 MockAppCacheService service; | 3249 MockAppCacheService service; |
3250 scoped_refptr<AppCacheGroup> group = | 3250 scoped_refptr<AppCacheGroup> group( |
3251 new AppCacheGroup(&service, GURL("http://manifesturl.com"), | 3251 new AppCacheGroup(&service, GURL("http://manifesturl.com"), |
3252 service.storage()->NewGroupId()); | 3252 service.storage()->NewGroupId())); |
3253 | 3253 |
3254 AppCacheUpdateJob update(&service, group); | 3254 AppCacheUpdateJob update(&service, group); |
3255 | 3255 |
3256 // Pretend group is in downloading state. | 3256 // Pretend group is in downloading state. |
3257 group->update_job_ = &update; | 3257 group->update_job_ = &update; |
3258 group->update_status_ = AppCacheGroup::DOWNLOADING; | 3258 group->update_status_ = AppCacheGroup::DOWNLOADING; |
3259 | 3259 |
3260 update.StartUpdate(NULL, GURL()); | 3260 update.StartUpdate(NULL, GURL()); |
3261 EXPECT_EQ(AppCacheGroup::DOWNLOADING, group->update_status()); | 3261 EXPECT_EQ(AppCacheGroup::DOWNLOADING, group->update_status()); |
3262 | 3262 |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3489 RunTestOnIOThread(&AppCacheUpdateJobTest::MultipleHeadersRefetchTest); | 3489 RunTestOnIOThread(&AppCacheUpdateJobTest::MultipleHeadersRefetchTest); |
3490 } | 3490 } |
3491 | 3491 |
3492 } // namespace appcache | 3492 } // namespace appcache |
3493 | 3493 |
3494 // AppCacheUpdateJobTest is expected to always live longer than the | 3494 // AppCacheUpdateJobTest is expected to always live longer than the |
3495 // runnable methods. This lets us call NewRunnableMethod on its instances. | 3495 // runnable methods. This lets us call NewRunnableMethod on its instances. |
3496 DISABLE_RUNNABLE_METHOD_REFCOUNT(appcache::AppCacheUpdateJobTest); | 3496 DISABLE_RUNNABLE_METHOD_REFCOUNT(appcache::AppCacheUpdateJobTest); |
3497 DISABLE_RUNNABLE_METHOD_REFCOUNT( | 3497 DISABLE_RUNNABLE_METHOD_REFCOUNT( |
3498 appcache::AppCacheUpdateJobTest::MockAppCachePolicy); | 3498 appcache::AppCacheUpdateJobTest::MockAppCachePolicy); |
OLD | NEW |