Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(409)

Side by Side Diff: webrtc/base/sslstreamadapter_unittest.cc

Issue 2718663005: Replace NULL with nullptr or null in webrtc/base/. (Closed)
Patch Set: Fixing Windows and formatting issues. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/base/sslstreamadapter.h ('k') | webrtc/base/stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2011 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2011 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 SSLStreamAdapterTestBase( 218 SSLStreamAdapterTestBase(
219 const std::string& client_cert_pem, 219 const std::string& client_cert_pem,
220 const std::string& client_private_key_pem, 220 const std::string& client_private_key_pem,
221 bool dtls, 221 bool dtls,
222 rtc::KeyParams client_key_type = rtc::KeyParams(rtc::KT_DEFAULT), 222 rtc::KeyParams client_key_type = rtc::KeyParams(rtc::KT_DEFAULT),
223 rtc::KeyParams server_key_type = rtc::KeyParams(rtc::KT_DEFAULT)) 223 rtc::KeyParams server_key_type = rtc::KeyParams(rtc::KT_DEFAULT))
224 : client_cert_pem_(client_cert_pem), 224 : client_cert_pem_(client_cert_pem),
225 client_private_key_pem_(client_private_key_pem), 225 client_private_key_pem_(client_private_key_pem),
226 client_key_type_(client_key_type), 226 client_key_type_(client_key_type),
227 server_key_type_(server_key_type), 227 server_key_type_(server_key_type),
228 client_stream_(NULL), 228 client_stream_(nullptr),
229 server_stream_(NULL), 229 server_stream_(nullptr),
230 client_identity_(NULL), 230 client_identity_(nullptr),
231 server_identity_(NULL), 231 server_identity_(nullptr),
232 delay_(0), 232 delay_(0),
233 mtu_(1460), 233 mtu_(1460),
234 loss_(0), 234 loss_(0),
235 lose_first_packet_(false), 235 lose_first_packet_(false),
236 damage_(false), 236 damage_(false),
237 dtls_(dtls), 237 dtls_(dtls),
238 handshake_wait_(5000), 238 handshake_wait_(5000),
239 identities_set_(false) { 239 identities_set_(false) {
240 // Set use of the test RNG to get predictable loss patterns. 240 // Set use of the test RNG to get predictable loss patterns.
241 rtc::SetRandomTestMode(true); 241 rtc::SetRandomTestMode(true);
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
620 620
621 // Test data transfer for TLS 621 // Test data transfer for TLS
622 void TestTransfer(int size) override { 622 void TestTransfer(int size) override {
623 LOG(LS_INFO) << "Starting transfer test with " << size << " bytes"; 623 LOG(LS_INFO) << "Starting transfer test with " << size << " bytes";
624 // Create some dummy data to send. 624 // Create some dummy data to send.
625 size_t received; 625 size_t received;
626 626
627 send_stream_.ReserveSize(size); 627 send_stream_.ReserveSize(size);
628 for (int i = 0; i < size; ++i) { 628 for (int i = 0; i < size; ++i) {
629 char ch = static_cast<char>(i); 629 char ch = static_cast<char>(i);
630 send_stream_.Write(&ch, 1, NULL, NULL); 630 send_stream_.Write(&ch, 1, nullptr, nullptr);
631 } 631 }
632 send_stream_.Rewind(); 632 send_stream_.Rewind();
633 633
634 // Prepare the receive stream. 634 // Prepare the receive stream.
635 recv_stream_.ReserveSize(size); 635 recv_stream_.ReserveSize(size);
636 636
637 // Start sending 637 // Start sending
638 WriteData(); 638 WriteData();
639 639
640 // Wait for the client to close 640 // Wait for the client to close
(...skipping 12 matching lines...) Expand all
653 rtc::StreamResult rv; 653 rtc::StreamResult rv;
654 size_t sent; 654 size_t sent;
655 char block[kBlockSize]; 655 char block[kBlockSize];
656 656
657 send_stream_.GetSize(&size); 657 send_stream_.GetSize(&size);
658 if (!size) 658 if (!size)
659 return; 659 return;
660 660
661 for (;;) { 661 for (;;) {
662 send_stream_.GetPosition(&position); 662 send_stream_.GetPosition(&position);
663 if (send_stream_.Read(block, sizeof(block), &tosend, NULL) != 663 if (send_stream_.Read(block, sizeof(block), &tosend, nullptr) !=
664 rtc::SR_EOS) { 664 rtc::SR_EOS) {
665 rv = client_ssl_->Write(block, tosend, &sent, 0); 665 rv = client_ssl_->Write(block, tosend, &sent, 0);
666 666
667 if (rv == rtc::SR_SUCCESS) { 667 if (rv == rtc::SR_SUCCESS) {
668 send_stream_.SetPosition(position + sent); 668 send_stream_.SetPosition(position + sent);
669 LOG(LS_VERBOSE) << "Sent: " << position + sent; 669 LOG(LS_VERBOSE) << "Sent: " << position + sent;
670 } else if (rv == rtc::SR_BLOCK) { 670 } else if (rv == rtc::SR_BLOCK) {
671 LOG(LS_VERBOSE) << "Blocked..."; 671 LOG(LS_VERBOSE) << "Blocked...";
672 send_stream_.SetPosition(position); 672 send_stream_.SetPosition(position);
673 break; 673 break;
(...skipping 25 matching lines...) Expand all
699 stream->Close(); 699 stream->Close();
700 return; 700 return;
701 } 701 }
702 702
703 if (r == rtc::SR_BLOCK) 703 if (r == rtc::SR_BLOCK)
704 break; 704 break;
705 705
706 ASSERT_EQ(rtc::SR_SUCCESS, r); 706 ASSERT_EQ(rtc::SR_SUCCESS, r);
707 LOG(LS_VERBOSE) << "Read " << bread; 707 LOG(LS_VERBOSE) << "Read " << bread;
708 708
709 recv_stream_.Write(buffer, bread, NULL, NULL); 709 recv_stream_.Write(buffer, bread, nullptr, nullptr);
710 } 710 }
711 } 711 }
712 712
713 private: 713 private:
714 rtc::FifoBuffer client_buffer_; 714 rtc::FifoBuffer client_buffer_;
715 rtc::FifoBuffer server_buffer_; 715 rtc::FifoBuffer server_buffer_;
716 rtc::MemoryStream send_stream_; 716 rtc::MemoryStream send_stream_;
717 rtc::MemoryStream recv_stream_; 717 rtc::MemoryStream recv_stream_;
718 }; 718 };
719 719
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 TEST_P(SSLStreamAdapterTestTLS, ReadWriteAfterClose) { 889 TEST_P(SSLStreamAdapterTestTLS, ReadWriteAfterClose) {
890 TestHandshake(); 890 TestHandshake();
891 TestTransfer(100000); 891 TestTransfer(100000);
892 client_ssl_->Close(); 892 client_ssl_->Close();
893 893
894 rtc::StreamResult rv; 894 rtc::StreamResult rv;
895 char block[kBlockSize]; 895 char block[kBlockSize];
896 size_t dummy; 896 size_t dummy;
897 897
898 // It's an error to write after closed. 898 // It's an error to write after closed.
899 rv = client_ssl_->Write(block, sizeof(block), &dummy, NULL); 899 rv = client_ssl_->Write(block, sizeof(block), &dummy, nullptr);
900 ASSERT_EQ(rtc::SR_ERROR, rv); 900 ASSERT_EQ(rtc::SR_ERROR, rv);
901 901
902 // But after closed read gives you EOS. 902 // But after closed read gives you EOS.
903 rv = client_ssl_->Read(block, sizeof(block), &dummy, NULL); 903 rv = client_ssl_->Read(block, sizeof(block), &dummy, nullptr);
904 ASSERT_EQ(rtc::SR_EOS, rv); 904 ASSERT_EQ(rtc::SR_EOS, rv);
905 }; 905 };
906 906
907 // Test a handshake with a bogus peer digest 907 // Test a handshake with a bogus peer digest
908 TEST_P(SSLStreamAdapterTestTLS, TestTLSBogusDigest) { 908 TEST_P(SSLStreamAdapterTestTLS, TestTLSBogusDigest) {
909 SetPeerIdentitiesByDigest(false, true); 909 SetPeerIdentitiesByDigest(false, true);
910 TestHandshake(false); 910 TestHandshake(false);
911 }; 911 };
912 912
913 TEST_P(SSLStreamAdapterTestTLS, TestTLSDelayedIdentity) { 913 TEST_P(SSLStreamAdapterTestTLS, TestTLSDelayedIdentity) {
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after
1343 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)))); 1343 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256))));
1344 INSTANTIATE_TEST_CASE_P( 1344 INSTANTIATE_TEST_CASE_P(
1345 SSLStreamAdapterTestsDTLS, 1345 SSLStreamAdapterTestsDTLS,
1346 SSLStreamAdapterTestDTLS, 1346 SSLStreamAdapterTestDTLS,
1347 Combine(Values(rtc::KeyParams::RSA(1024, 65537), 1347 Combine(Values(rtc::KeyParams::RSA(1024, 65537),
1348 rtc::KeyParams::RSA(1152, 65537), 1348 rtc::KeyParams::RSA(1152, 65537),
1349 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)), 1349 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)),
1350 Values(rtc::KeyParams::RSA(1024, 65537), 1350 Values(rtc::KeyParams::RSA(1024, 65537),
1351 rtc::KeyParams::RSA(1152, 65537), 1351 rtc::KeyParams::RSA(1152, 65537),
1352 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)))); 1352 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256))));
OLDNEW
« no previous file with comments | « webrtc/base/sslstreamadapter.h ('k') | webrtc/base/stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698