diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-08 00:04:20 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-08 00:04:20 +0000 |
commit | 5405a00a742c1a556d66701d4030a53775364cd3 (patch) | |
tree | 5b108758a2018bd5762f33292055681aefcd59b8 /webkit/glue/webplugin_impl_unittest.cc | |
parent | a6879a7486c9a3c9b619f9dded1d535e734c7fcd (diff) | |
download | chromium_src-5405a00a742c1a556d66701d4030a53775364cd3.zip chromium_src-5405a00a742c1a556d66701d4030a53775364cd3.tar.gz chromium_src-5405a00a742c1a556d66701d4030a53775364cd3.tar.bz2 |
Port webplugin_impl test shell test to linux.
Review URL: http://codereview.chromium.org/9714
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5044 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/webplugin_impl_unittest.cc')
-rw-r--r-- | webkit/glue/webplugin_impl_unittest.cc | 105 |
1 files changed, 54 insertions, 51 deletions
diff --git a/webkit/glue/webplugin_impl_unittest.cc b/webkit/glue/webplugin_impl_unittest.cc index 1b34e45..b10103a 100644 --- a/webkit/glue/webplugin_impl_unittest.cc +++ b/webkit/glue/webplugin_impl_unittest.cc @@ -17,8 +17,10 @@ MSVC_POP_WARNING(); #include "webkit/glue/webplugin_impl.h" namespace { - class WebPluginImplTest : public testing::Test { - }; + +class WebPluginImplTest : public testing::Test { +}; + } // These exist only to support the gTest assertion macros, and @@ -34,33 +36,33 @@ std::ostream& operator<<(std::ostream& out, const WebCore::String& str) TEST(WebPluginImplTest, PostParserSimple) { // Test a simple case with headers & data - char *ex1 = "foo: bar\nContent-length: 10\n\nabcdefghij"; + const char *ex1 = "foo: bar\nContent-length: 10\n\nabcdefghij"; WebCore::ResourceRequest request; - bool rv= WebPluginImpl::SetPostData(&request, ex1, - static_cast<uint32>(strlen(ex1))); + bool rv = WebPluginImpl::SetPostData(&request, ex1, + static_cast<uint32>(strlen(ex1))); EXPECT_EQ(true, rv); EXPECT_EQ("bar", request.httpHeaderField("foo").stripWhiteSpace()); - EXPECT_EQ(0, request.httpHeaderField("bar").length()); - EXPECT_EQ(0, request.httpHeaderField("Content-length").length()); + EXPECT_EQ(0U, request.httpHeaderField("bar").length()); + EXPECT_EQ(0U, request.httpHeaderField("Content-length").length()); EXPECT_EQ("abcdefghij", request.httpBody()->flattenToString()); } TEST(WebPluginImplTest, PostParserLongHeader) { // Test a simple case with long headers - char *ex1 = "foo: 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n\nabcdefghij"; + const char *ex1 = "foo: 0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789\n\nabcdefghij"; WebCore::ResourceRequest request; - bool rv= WebPluginImpl::SetPostData(&request, ex1, - static_cast<uint32>(strlen(ex1))); + bool rv = WebPluginImpl::SetPostData(&request, ex1, + static_cast<uint32>(strlen(ex1))); EXPECT_EQ(true, rv); - EXPECT_EQ(100, request.httpHeaderField("foo").stripWhiteSpace().length()); + EXPECT_EQ(100U, request.httpHeaderField("foo").stripWhiteSpace().length()); } TEST(WebPluginImplTest, PostParserManyHeaders) { // Test a simple case with long headers - char *ex1 = "h1:h1\nh2:h2\nh3:h3\nh4:h4\nh5:h5\nh6:h6\nh7:h7\nh8:h8\nh9:h9\nh10:h10\n\nbody"; + const char *ex1 = "h1:h1\nh2:h2\nh3:h3\nh4:h4\nh5:h5\nh6:h6\nh7:h7\nh8:h8\nh9:h9\nh10:h10\n\nbody"; WebCore::ResourceRequest request; - bool rv= WebPluginImpl::SetPostData(&request, ex1, - static_cast<uint32>(strlen(ex1))); + bool rv = WebPluginImpl::SetPostData(&request, ex1, + static_cast<uint32>(strlen(ex1))); EXPECT_EQ(true, rv); EXPECT_EQ("h1", request.httpHeaderField("h1").stripWhiteSpace()); EXPECT_EQ("h2", request.httpHeaderField("h2").stripWhiteSpace()); @@ -81,73 +83,73 @@ TEST(WebPluginImplTest, PostParserDuplicateHeaders) { // Test a simple case with long headers // What value gets returned doesn't really matter. It shouldn't error // out. - char *ex1 = "h1:h1\nh1:h2\n\nbody"; + const char *ex1 = "h1:h1\nh1:h2\n\nbody"; WebCore::ResourceRequest request; - bool rv= WebPluginImpl::SetPostData(&request, ex1, - static_cast<uint32>(strlen(ex1))); + bool rv = WebPluginImpl::SetPostData(&request, ex1, + static_cast<uint32>(strlen(ex1))); EXPECT_EQ(true, rv); } TEST(WebPluginImplTest, PostParserNoHeaders) { // Test a simple case with no headers but with data - char *ex1 = "\nabcdefghij"; + const char *ex1 = "\nabcdefghij"; WebCore::ResourceRequest request; - bool rv= WebPluginImpl::SetPostData(&request, ex1, - static_cast<uint32>(strlen(ex1))); + bool rv = WebPluginImpl::SetPostData(&request, ex1, + static_cast<uint32>(strlen(ex1))); EXPECT_EQ(true, rv); - EXPECT_EQ(0, request.httpHeaderField("foo").length()); - EXPECT_EQ(0, request.httpHeaderField("bar").length()); - EXPECT_EQ(0, request.httpHeaderField("Content-length").length()); + EXPECT_EQ(0U, request.httpHeaderField("foo").length()); + EXPECT_EQ(0U, request.httpHeaderField("bar").length()); + EXPECT_EQ(0U, request.httpHeaderField("Content-length").length()); EXPECT_EQ("abcdefghij", request.httpBody()->flattenToString()); } TEST(WebPluginImplTest, PostParserNoBody) { // Test a simple case with headers and no body - char *ex1 = "Foo:bar\n\n"; + const char *ex1 = "Foo:bar\n\n"; WebCore::ResourceRequest request; - bool rv= WebPluginImpl::SetPostData(&request, ex1, - static_cast<uint32>(strlen(ex1))); + bool rv = WebPluginImpl::SetPostData(&request, ex1, + static_cast<uint32>(strlen(ex1))); EXPECT_EQ(true, rv); EXPECT_EQ("bar", request.httpHeaderField("foo").stripWhiteSpace()); - EXPECT_EQ(0, request.httpHeaderField("bar").length()); - EXPECT_EQ(0, request.httpHeaderField("Content-length").length()); - EXPECT_EQ(0, request.httpBody()->flattenToString().length()); + EXPECT_EQ(0U, request.httpHeaderField("bar").length()); + EXPECT_EQ(0U, request.httpHeaderField("Content-length").length()); + EXPECT_EQ(0U, request.httpBody()->flattenToString().length()); } TEST(WebPluginImplTest, PostParserBodyWithNewLines) { // Test a simple case with headers and no body - char *ex1 = "Foo:bar\n\n\n\nabcdefg\n\nabcdefg"; + const char *ex1 = "Foo:bar\n\n\n\nabcdefg\n\nabcdefg"; WebCore::ResourceRequest request; - bool rv= WebPluginImpl::SetPostData(&request, ex1, - static_cast<uint32>(strlen(ex1))); + bool rv = WebPluginImpl::SetPostData(&request, ex1, + static_cast<uint32>(strlen(ex1))); EXPECT_EQ(true, rv); EXPECT_EQ(request.httpBody()->flattenToString(), "\n\nabcdefg\n\nabcdefg"); } TEST(WebPluginImplTest, PostParserErrorNoBody) { // Test with headers and no body - char *ex1 = "Foo:bar\n"; + const char *ex1 = "Foo:bar\n"; WebCore::ResourceRequest request; - bool rv= WebPluginImpl::SetPostData(&request, ex1, - static_cast<uint32>(strlen(ex1))); + bool rv = WebPluginImpl::SetPostData(&request, ex1, + static_cast<uint32>(strlen(ex1))); EXPECT_EQ(true, rv); } TEST(WebPluginImplTest, PostParserErrorEmpty) { // Test with an empty string - char *ex1 = ""; + const char *ex1 = ""; WebCore::ResourceRequest request; - bool rv= WebPluginImpl::SetPostData(&request, ex1, - static_cast<uint32>(strlen(ex1))); + bool rv = WebPluginImpl::SetPostData(&request, ex1, + static_cast<uint32>(strlen(ex1))); EXPECT_EQ(true, rv); } TEST(WebPluginImplTest, PostParserEmptyName) { // Test an error case with an empty header name field - char *ex1 = "foo:bar\n:blat\n\nbody"; + const char *ex1 = "foo:bar\n:blat\n\nbody"; WebCore::ResourceRequest request; - bool rv= WebPluginImpl::SetPostData(&request, ex1, - static_cast<uint32>(strlen(ex1))); + bool rv = WebPluginImpl::SetPostData(&request, ex1, + static_cast<uint32>(strlen(ex1))); EXPECT_EQ(true, rv); EXPECT_EQ("bar", request.httpHeaderField("foo").stripWhiteSpace()); EXPECT_EQ("body", request.httpBody()->flattenToString()); @@ -155,25 +157,25 @@ TEST(WebPluginImplTest, PostParserEmptyName) { TEST(WebPluginImplTest, PostParserEmptyValue) { // Test an error case with an empty value field - char *ex1 = "foo:bar\nbar:\n\nbody"; + const char *ex1 = "foo:bar\nbar:\n\nbody"; WebCore::ResourceRequest request; - bool rv= WebPluginImpl::SetPostData(&request, ex1, - static_cast<uint32>(strlen(ex1))); + bool rv = WebPluginImpl::SetPostData(&request, ex1, + static_cast<uint32>(strlen(ex1))); EXPECT_EQ(true, rv); EXPECT_EQ("bar", request.httpHeaderField("foo").stripWhiteSpace()); - EXPECT_EQ(0, request.httpHeaderField("bar").length()); + EXPECT_EQ(0U, request.httpHeaderField("bar").length()); EXPECT_EQ("body", request.httpBody()->flattenToString()); } TEST(WebPluginImplTest, PostParserCRLF) { // Test an error case with an empty value field - char *ex1 = "foo: bar\r\nbar:\r\n\r\nbody\r\n\r\nbody2"; + const char *ex1 = "foo: bar\r\nbar:\r\n\r\nbody\r\n\r\nbody2"; WebCore::ResourceRequest request; - bool rv= WebPluginImpl::SetPostData(&request, ex1, - static_cast<uint32>(strlen(ex1))); + bool rv = WebPluginImpl::SetPostData(&request, ex1, + static_cast<uint32>(strlen(ex1))); EXPECT_EQ(true, rv); EXPECT_EQ("bar", request.httpHeaderField("foo").stripWhiteSpace()); - EXPECT_EQ(0, request.httpHeaderField("bar").length()); + EXPECT_EQ(0U, request.httpHeaderField("bar").length()); EXPECT_EQ("body\r\n\r\nbody2", request.httpBody()->flattenToString()); } @@ -189,8 +191,8 @@ TEST(WebPluginImplTest, PostParserBodyWithBinaryData) { sizeof(ex1)/sizeof(ex1[0])); EXPECT_EQ(true, rv); EXPECT_EQ("bar", request.httpHeaderField("foo").stripWhiteSpace()); - EXPECT_EQ(0, request.httpHeaderField("bar").length()); - EXPECT_EQ(0, request.httpHeaderField("Content-length").length()); + EXPECT_EQ(0U, request.httpHeaderField("bar").length()); + EXPECT_EQ(0U, request.httpHeaderField("Content-length").length()); Vector<char> expected_data; request.httpBody()->flatten(expected_data); @@ -200,3 +202,4 @@ TEST(WebPluginImplTest, PostParserBodyWithBinaryData) { EXPECT_EQ(0xFF, (unsigned char)expected_data[2]); EXPECT_EQ(0xFF, (unsigned char)expected_data[3]); } + |