summaryrefslogtreecommitdiffstats
path: root/chrome_frame/test/url_request_test.cc
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-04 02:23:49 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-04 02:23:49 +0000
commit57c844d89cade2225ed684c6d8897c56fbd149ef (patch)
treefab5d164b2215595eca89916ab0cc096db48844c /chrome_frame/test/url_request_test.cc
parentfd99fb81a58f730eafef94c869af107d830a8ef7 (diff)
downloadchromium_src-57c844d89cade2225ed684c6d8897c56fbd149ef.zip
chromium_src-57c844d89cade2225ed684c6d8897c56fbd149ef.tar.gz
chromium_src-57c844d89cade2225ed684c6d8897c56fbd149ef.tar.bz2
Reverting to fix the IE6 builder redness. Please continue debugging this and resubmit.
Revert 46188 - Not using an intermediate cache between urlmon and chrome reads. Instead we hang on to stream objects from urlmon and read from them when chrome asks for data. TEST=Run all tests verify that sites like wave and vimeo work correctly etc. BUG=none Review URL: http://codereview.chromium.org/1718025 TBR=tommi@chromium.org Review URL: http://codereview.chromium.org/1928001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46324 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/test/url_request_test.cc')
-rw-r--r--chrome_frame/test/url_request_test.cc57
1 files changed, 57 insertions, 0 deletions
diff --git a/chrome_frame/test/url_request_test.cc b/chrome_frame/test/url_request_test.cc
index 106f717b..35f0f81 100644
--- a/chrome_frame/test/url_request_test.cc
+++ b/chrome_frame/test/url_request_test.cc
@@ -31,6 +31,63 @@ static void AppendToStream(IStream* s, void* buffer, ULONG cb) {
ASSERT_HRESULT_SUCCEEDED(s->Seek(current_pos, STREAM_SEEK_SET, NULL));
}
+TEST(UrlmonUrlRequestCache, ReadWrite) {
+ UrlmonUrlRequest::Cache cache;
+ ScopedComPtr<IStream> stream;
+ ASSERT_HRESULT_SUCCEEDED(::CreateStreamOnHGlobal(0, TRUE, stream.Receive()));
+ cache.Append(stream);
+ ASSERT_EQ(0, cache.size());
+ size_t bytes_read;
+ const size_t BUF_SIZE = UrlmonUrlRequest::Cache::BUF_SIZE;
+ scoped_array<uint8> buffer(new uint8[BUF_SIZE * 2]);
+
+ AppendToStream(stream, "hello", 5u);
+ ASSERT_TRUE(cache.Append(stream));
+ ASSERT_HRESULT_SUCCEEDED(cache.Read(buffer.get(), 2u, &bytes_read));
+ ASSERT_EQ(2, bytes_read);
+ ASSERT_EQ('h', buffer[0]);
+ ASSERT_EQ('e', buffer[1]);
+
+ AppendToStream(stream, "world\0", 6u);
+ ASSERT_TRUE(cache.Append(stream));
+ ASSERT_HRESULT_SUCCEEDED(cache.Read(buffer.get(), 1u, &bytes_read));
+ ASSERT_EQ(1, bytes_read);
+ ASSERT_EQ('l', buffer[0]);
+ ASSERT_HRESULT_SUCCEEDED(cache.Read(buffer.get(), 100u, &bytes_read));
+ ASSERT_EQ(8, bytes_read);
+ ASSERT_STREQ("loworld", (const char*)buffer.get());
+
+ memset(buffer.get(), '1', BUF_SIZE / 2);
+ AppendToStream(stream, buffer.get(), BUF_SIZE / 2);
+ cache.Append(stream);
+ memset(buffer.get(), '2', BUF_SIZE);
+ AppendToStream(stream, buffer.get(), BUF_SIZE);
+ memset(buffer.get(), '3', BUF_SIZE * 3 / 4);
+ AppendToStream(stream, buffer.get(), BUF_SIZE * 3 / 4);
+ cache.Append(stream);
+
+ cache.Read(buffer.get(), BUF_SIZE / 2, &bytes_read);
+ ASSERT_EQ(BUF_SIZE / 2, bytes_read);
+ ASSERT_EQ('1', buffer[0]);
+ ASSERT_EQ('1', buffer[BUF_SIZE / 4]);
+ ASSERT_EQ('1', buffer[BUF_SIZE /2 - 1]);
+
+ cache.Read(buffer.get(), BUF_SIZE, &bytes_read);
+ ASSERT_EQ(BUF_SIZE, bytes_read);
+ ASSERT_EQ('2', buffer[0]);
+ ASSERT_EQ('2', buffer[BUF_SIZE /2]);
+ ASSERT_EQ('2', buffer[BUF_SIZE - 1]);
+
+ cache.Read(buffer.get(), BUF_SIZE * 3 / 4, &bytes_read);
+ ASSERT_EQ(BUF_SIZE * 3 / 4, bytes_read);
+ ASSERT_EQ('3', buffer[0]);
+ ASSERT_EQ('3', buffer[BUF_SIZE / 2]);
+ ASSERT_EQ('3', buffer[BUF_SIZE * 3 / 4 - 1]);
+ cache.Read(buffer.get(), 11, &bytes_read);
+ ASSERT_EQ(0, bytes_read);
+}
+
+
class MockUrlDelegate : public PluginUrlRequestDelegate {
public:
MOCK_METHOD7(OnResponseStarted, void(int request_id, const char* mime_type,