diff options
author | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-06 22:25:33 +0000 |
---|---|---|
committer | michaeln@chromium.org <michaeln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-06 22:25:33 +0000 |
commit | 0dfeec38d00d53b6751a937e43394d6036987698 (patch) | |
tree | b8641d3bd07cbe185deb9f1dba29acb551bb92a2 /webkit/appcache/appcache_response_unittest.cc | |
parent | f1002ee286ad56e2b80736661e89989b650aad6e (diff) | |
download | chromium_src-0dfeec38d00d53b6751a937e43394d6036987698.zip chromium_src-0dfeec38d00d53b6751a937e43394d6036987698.tar.gz chromium_src-0dfeec38d00d53b6751a937e43394d6036987698.tar.bz2 |
AppCache quota tracking groundwork, store response sizes in the SQL database.
TEST=updated existing unittests
BUG=none
Review URL: http://codereview.chromium.org/525060
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35654 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_response_unittest.cc')
-rw-r--r-- | webkit/appcache/appcache_response_unittest.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/webkit/appcache/appcache_response_unittest.cc b/webkit/appcache/appcache_response_unittest.cc index 824e73c..2989592 100644 --- a/webkit/appcache/appcache_response_unittest.cc +++ b/webkit/appcache/appcache_response_unittest.cc @@ -371,6 +371,37 @@ class AppCacheResponseTest : public testing::Test { TestFinished(); } + // AmountWritten ---------------------------------------------------- + + void AmountWritten() { + static const char kHttpHeaders[] = + "HTTP/1.0 200 OK\0\0"; + std::string raw_headers(kHttpHeaders, arraysize(kHttpHeaders)); + net::HttpResponseInfo* head = MakeHttpResponseInfo(raw_headers); + int expected_amount_written = + GetHttpResponseInfoSize(head) + kNumBlocks * kBlockSize; + + // Push tasks in reverse order. + PushNextTask(method_factory_.NewRunnableMethod( + &AppCacheResponseTest::Verify_AmountWritten, expected_amount_written)); + for (int i = 0; i < kNumBlocks; ++i) { + PushNextTask(method_factory_.NewRunnableMethod( + &AppCacheResponseTest::WriteOneBlock, kNumBlocks - i)); + } + PushNextTask(method_factory_.NewRunnableMethod( + &AppCacheResponseTest::WriteResponseHead, head)); + + writer_.reset(service_->storage()->CreateResponseWriter(GURL())); + written_response_id_ = writer_->response_id(); + ScheduleNextTask(); + } + + void Verify_AmountWritten(int expected_amount_written) { + EXPECT_EQ(expected_amount_written, writer_->amount_written()); + TestFinished(); + } + + // WriteThenVariouslyReadResponse ------------------------------------------- void WriteThenVariouslyReadResponse() { @@ -658,6 +689,10 @@ TEST_F(AppCacheResponseTest, LoadResponseInfo_Hit) { RunTestOnIOThread(&AppCacheResponseTest::LoadResponseInfo_Hit); } +TEST_F(AppCacheResponseTest, AmountWritten) { + RunTestOnIOThread(&AppCacheResponseTest::AmountWritten); +} + TEST_F(AppCacheResponseTest, WriteThenVariouslyReadResponse) { RunTestOnIOThread(&AppCacheResponseTest::WriteThenVariouslyReadResponse); } |