Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/strings/string_split.h" | 6 #include "base/strings/string_split.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "net/base/mime_util.h" | 8 #include "net/base/mime_util.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 289 #else | 289 #else |
| 290 EXPECT_EQ(CERTIFICATE_MIME_TYPE_UNKNOWN, | 290 EXPECT_EQ(CERTIFICATE_MIME_TYPE_UNKNOWN, |
| 291 GetCertificateMimeTypeForMimeType("application/x-x509-ca-cert")); | 291 GetCertificateMimeTypeForMimeType("application/x-x509-ca-cert")); |
| 292 EXPECT_EQ(CERTIFICATE_MIME_TYPE_UNKNOWN, | 292 EXPECT_EQ(CERTIFICATE_MIME_TYPE_UNKNOWN, |
| 293 GetCertificateMimeTypeForMimeType("application/x-pkcs12")); | 293 GetCertificateMimeTypeForMimeType("application/x-pkcs12")); |
| 294 #endif | 294 #endif |
| 295 EXPECT_EQ(CERTIFICATE_MIME_TYPE_UNKNOWN, | 295 EXPECT_EQ(CERTIFICATE_MIME_TYPE_UNKNOWN, |
| 296 GetCertificateMimeTypeForMimeType("text/plain")); | 296 GetCertificateMimeTypeForMimeType("text/plain")); |
| 297 } | 297 } |
| 298 | 298 |
| 299 TEST(MimeUtilTest, TestAddMultipartValueForUpload) { | |
| 300 const char* ref_output = "--boundary\r\nContent-Disposition: form-data;" | |
| 301 " name=\"value name\"\r\nContent-Type: content type" | |
| 302 "\r\n\r\nvalue\r\n"; | |
| 303 std::string post_data; | |
| 304 AddMultipartValueForUpload("value name", "value", "boundary", | |
| 305 "content type", &post_data); | |
| 306 EXPECT_STREQ(ref_output, post_data.c_str()); | |
| 307 | |
| 308 const char* ref_output_no_content_type = | |
| 309 "--boundary\r\nContent-Disposition: form-data;" | |
| 310 " name=\"value name\"\r\n\r\nvalue\r\n"; | |
| 311 post_data.clear(); | |
|
wtc
2013/05/16 18:24:22
Nit: it would be better to test two AddMultipartVa
Henrik Grunell
2013/05/17 07:49:12
Done.
| |
| 312 AddMultipartValueForUpload("value name", "value", "boundary", | |
| 313 "", &post_data); | |
| 314 EXPECT_STREQ(ref_output_no_content_type, post_data.c_str()); | |
| 315 } | |
| 316 | |
| 317 TEST(MimeUtilTest, TestAddMultipartFinalDelimiterForUpload) { | |
| 318 const char* ref_output = "--boundary--\r\n"; | |
| 319 std::string post_data; | |
| 320 AddMultipartFinalDelimiterForUpload("boundary", &post_data); | |
| 321 EXPECT_STREQ(ref_output, post_data.c_str()); | |
| 322 } | |
| 323 | |
| 299 } // namespace net | 324 } // namespace net |
| OLD | NEW |