summaryrefslogtreecommitdiffstats
path: root/chrome_frame/urlmon_upload_data_stream_unittest.cc
diff options
context:
space:
mode:
authorgrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-10 06:53:11 +0000
committergrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-10 06:53:11 +0000
commit9b6f946ffbb5271bd4e8a211ce45ec97175d14b7 (patch)
treec9460c6d6ca415c5069cb801b2bf9c07f5cbdc51 /chrome_frame/urlmon_upload_data_stream_unittest.cc
parenta9f74a6b78ecfb8f868d19d99e43a5679bb95ad4 (diff)
downloadchromium_src-9b6f946ffbb5271bd4e8a211ce45ec97175d14b7.zip
chromium_src-9b6f946ffbb5271bd4e8a211ce45ec97175d14b7.tar.gz
chromium_src-9b6f946ffbb5271bd4e8a211ce45ec97175d14b7.tar.bz2
Remove Chrome Frame code and resources.
BUG=316496 TBR=ben@chromium.org Review URL: https://codereview.chromium.org/126143005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244113 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/urlmon_upload_data_stream_unittest.cc')
-rw-r--r--chrome_frame/urlmon_upload_data_stream_unittest.cc162
1 files changed, 0 insertions, 162 deletions
diff --git a/chrome_frame/urlmon_upload_data_stream_unittest.cc b/chrome_frame/urlmon_upload_data_stream_unittest.cc
deleted file mode 100644
index 8bab45a..0000000
--- a/chrome_frame/urlmon_upload_data_stream_unittest.cc
+++ /dev/null
@@ -1,162 +0,0 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "gtest/gtest.h"
-
-#include "base/memory/ref_counted.h"
-#include "base/win/scoped_comptr.h"
-#include "chrome_frame/urlmon_upload_data_stream.h"
-
-TEST(UrlmonUploadDataStreamTest, TestBasicRead) {
- char random_string[] = "some random data, no really this totally random";
- int random_string_length = strlen(random_string);
- scoped_refptr<net::UploadData> upload_data = new net::UploadData();
- upload_data->AppendBytes(random_string, random_string_length);
-
- CComObject<UrlmonUploadDataStream>* upload_stream = NULL;
- HRESULT hr =
- CComObject<UrlmonUploadDataStream>::CreateInstance(&upload_stream);
- ASSERT_TRUE(SUCCEEDED(hr));
-
- upload_stream->Initialize(upload_data.get());
- base::win::ScopedComPtr<IStream> upload_istream(upload_stream);
-
- char buffer[500];
- memset(buffer, 0, 500);
- ULONG bytes_read = 0;
- hr = upload_istream->Read(buffer, 500, &bytes_read);
-
- EXPECT_TRUE(SUCCEEDED(hr));
- EXPECT_EQ(bytes_read, random_string_length);
- EXPECT_TRUE(strcmp(buffer, random_string) == 0);
-
- char buffer2[500];
- memset(buffer2, 0, 500);
- ULONG bytes_read2 = 0;
- hr = upload_istream->Read(buffer2, 500, &bytes_read2);
-
- EXPECT_EQ(S_FALSE, hr);
- EXPECT_EQ(bytes_read2, 0);
- EXPECT_FALSE(strcmp(buffer2, random_string) == 0);
-}
-
-TEST(UrlmonUploadDataStreamTest, TestBigRead) {
- const size_t kBigBufferLength = 100000;
- char big_buffer[kBigBufferLength];
- memset(big_buffer, 'a', kBigBufferLength);
-
- scoped_refptr<net::UploadData> upload_data = new net::UploadData();
- upload_data->AppendBytes(big_buffer, kBigBufferLength);
-
- CComObject<UrlmonUploadDataStream>* upload_stream = NULL;
- HRESULT hr =
- CComObject<UrlmonUploadDataStream>::CreateInstance(&upload_stream);
- ASSERT_TRUE(SUCCEEDED(hr));
-
- upload_stream->Initialize(upload_data.get());
- base::win::ScopedComPtr<IStream> upload_istream(upload_stream);
-
- char big_rcv_buffer[kBigBufferLength];
- int write_pos = 0;
- ULONG bytes_read = 0;
- hr = E_UNEXPECTED;
-
- while ((hr = upload_istream->Read(&big_rcv_buffer[write_pos],
- kBigBufferLength,
- &bytes_read)) != S_FALSE) {
- EXPECT_TRUE(SUCCEEDED(hr));
- EXPECT_GT(bytes_read, static_cast<ULONG>(0));
-
- write_pos += bytes_read;
- bytes_read = 0;
- }
-
- EXPECT_EQ(S_FALSE, hr);
- EXPECT_TRUE((write_pos + bytes_read) == kBigBufferLength);
- EXPECT_EQ(0, memcmp(big_buffer, big_rcv_buffer, kBigBufferLength));
-}
-
-TEST(UrlmonUploadDataStreamTest, TestStat) {
- char random_string[] = "some random data, no really this totally random";
- int random_string_length = strlen(random_string);
- scoped_refptr<net::UploadData> upload_data = new net::UploadData();
- upload_data->AppendBytes(random_string, random_string_length);
-
- CComObject<UrlmonUploadDataStream>* upload_stream = NULL;
- HRESULT hr =
- CComObject<UrlmonUploadDataStream>::CreateInstance(&upload_stream);
- ASSERT_TRUE(SUCCEEDED(hr));
-
- upload_stream->Initialize(upload_data.get());
- base::win::ScopedComPtr<IStream> upload_istream(upload_stream);
-
- STATSTG statstg;
- hr = upload_stream->Stat(&statstg, STATFLAG_NONAME);
- EXPECT_TRUE(SUCCEEDED(hr));
- EXPECT_EQ(static_cast<LONGLONG>(random_string_length),
- statstg.cbSize.QuadPart);
-}
-
-TEST(UrlmonUploadDataStreamTest, TestRepeatedRead) {
- char random_string[] = "some random data, no really this totally random";
- int random_string_length = strlen(random_string);
- scoped_refptr<net::UploadData> upload_data = new net::UploadData();
- upload_data->AppendBytes(random_string, random_string_length);
-
- CComObject<UrlmonUploadDataStream>* upload_stream = NULL;
- HRESULT hr =
- CComObject<UrlmonUploadDataStream>::CreateInstance(&upload_stream);
- ASSERT_TRUE(SUCCEEDED(hr));
-
- upload_stream->Initialize(upload_data.get());
- base::win::ScopedComPtr<IStream> upload_istream(upload_stream);
-
- char buffer[500];
- memset(buffer, 0, 500);
- ULONG bytes_read = 0;
- hr = upload_istream->Read(buffer, 500, &bytes_read);
-
- EXPECT_TRUE(SUCCEEDED(hr));
- EXPECT_EQ(bytes_read, random_string_length);
- EXPECT_EQ(0, strcmp(buffer, random_string));
-
- char buffer2[500];
- memset(buffer2, 0, 500);
- ULONG bytes_read2 = 0;
-
- for (int i = 0; i < 10; i++) {
- hr = upload_istream->Read(buffer2, 500, &bytes_read2);
- EXPECT_EQ(S_FALSE, hr);
- EXPECT_EQ(bytes_read2, 0);
- EXPECT_NE(0, strcmp(buffer2, random_string));
- }
-}
-
-TEST(UrlmonUploadDataStreamTest, TestZeroRead) {
- char random_string[] = "some random data, no really this totally random";
- int random_string_length = strlen(random_string);
- scoped_refptr<net::UploadData> upload_data = new net::UploadData();
- upload_data->AppendBytes(random_string, random_string_length);
-
- CComObject<UrlmonUploadDataStream>* upload_stream = NULL;
- HRESULT hr =
- CComObject<UrlmonUploadDataStream>::CreateInstance(&upload_stream);
- ASSERT_TRUE(SUCCEEDED(hr));
-
- upload_stream->Initialize(upload_data.get());
- base::win::ScopedComPtr<IStream> upload_istream(upload_stream);
-
- char buffer[500];
- memset(buffer, 0, 500);
- ULONG bytes_read = 42;
- hr = upload_istream->Read(&buffer[0], 0, &bytes_read);
-
- EXPECT_EQ(S_OK, hr);
- EXPECT_EQ(0, bytes_read);
-
- char buffer2[500];
- memset(&buffer2[0], 0, 500);
- EXPECT_EQ(0, memcmp(buffer, buffer2, 500));
-}
-