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

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

Issue 1921653002: Enable -Winconsistent-missing-override flag. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase. Created 4 years, 7 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/rtccertificategenerator_unittest.cc ('k') | webrtc/build/common.gypi » ('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 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 } 555 }
556 556
557 void CreateStreams() override { 557 void CreateStreams() override {
558 client_stream_ = 558 client_stream_ =
559 new SSLDummyStreamTLS(this, "c2s", &client_buffer_, &server_buffer_); 559 new SSLDummyStreamTLS(this, "c2s", &client_buffer_, &server_buffer_);
560 server_stream_ = 560 server_stream_ =
561 new SSLDummyStreamTLS(this, "s2c", &server_buffer_, &client_buffer_); 561 new SSLDummyStreamTLS(this, "s2c", &server_buffer_, &client_buffer_);
562 } 562 }
563 563
564 // Test data transfer for TLS 564 // Test data transfer for TLS
565 virtual void TestTransfer(int size) { 565 void TestTransfer(int size) override {
566 LOG(LS_INFO) << "Starting transfer test with " << size << " bytes"; 566 LOG(LS_INFO) << "Starting transfer test with " << size << " bytes";
567 // Create some dummy data to send. 567 // Create some dummy data to send.
568 size_t received; 568 size_t received;
569 569
570 send_stream_.ReserveSize(size); 570 send_stream_.ReserveSize(size);
571 for (int i = 0; i < size; ++i) { 571 for (int i = 0; i < size; ++i) {
572 char ch = static_cast<char>(i); 572 char ch = static_cast<char>(i);
573 send_stream_.Write(&ch, 1, NULL, NULL); 573 send_stream_.Write(&ch, 1, NULL, NULL);
574 } 574 }
575 send_stream_.Rewind(); 575 send_stream_.Rewind();
576 576
577 // Prepare the receive stream. 577 // Prepare the receive stream.
578 recv_stream_.ReserveSize(size); 578 recv_stream_.ReserveSize(size);
579 579
580 // Start sending 580 // Start sending
581 WriteData(); 581 WriteData();
582 582
583 // Wait for the client to close 583 // Wait for the client to close
584 EXPECT_TRUE_WAIT(server_ssl_->GetState() == rtc::SS_CLOSED, 10000); 584 EXPECT_TRUE_WAIT(server_ssl_->GetState() == rtc::SS_CLOSED, 10000);
585 585
586 // Now check the data 586 // Now check the data
587 recv_stream_.GetSize(&received); 587 recv_stream_.GetSize(&received);
588 588
589 EXPECT_EQ(static_cast<size_t>(size), received); 589 EXPECT_EQ(static_cast<size_t>(size), received);
590 EXPECT_EQ(0, memcmp(send_stream_.GetBuffer(), 590 EXPECT_EQ(0, memcmp(send_stream_.GetBuffer(),
591 recv_stream_.GetBuffer(), size)); 591 recv_stream_.GetBuffer(), size));
592 } 592 }
593 593
594 void WriteData() { 594 void WriteData() override {
595 size_t position, tosend, size; 595 size_t position, tosend, size;
596 rtc::StreamResult rv; 596 rtc::StreamResult rv;
597 size_t sent; 597 size_t sent;
598 char block[kBlockSize]; 598 char block[kBlockSize];
599 599
600 send_stream_.GetSize(&size); 600 send_stream_.GetSize(&size);
601 if (!size) 601 if (!size)
602 return; 602 return;
603 603
604 for (;;) { 604 for (;;) {
(...skipping 15 matching lines...) Expand all
620 } 620 }
621 } else { 621 } else {
622 // Now close 622 // Now close
623 LOG(LS_INFO) << "Wrote " << position << " bytes. Closing"; 623 LOG(LS_INFO) << "Wrote " << position << " bytes. Closing";
624 client_ssl_->Close(); 624 client_ssl_->Close();
625 break; 625 break;
626 } 626 }
627 } 627 }
628 }; 628 };
629 629
630 virtual void ReadData(rtc::StreamInterface *stream) { 630 void ReadData(rtc::StreamInterface *stream) override {
631 char buffer[1600]; 631 char buffer[1600];
632 size_t bread; 632 size_t bread;
633 int err2; 633 int err2;
634 rtc::StreamResult r; 634 rtc::StreamResult r;
635 635
636 for (;;) { 636 for (;;) {
637 r = stream->Read(buffer, sizeof(buffer), &bread, &err2); 637 r = stream->Read(buffer, sizeof(buffer), &bread, &err2);
638 638
639 if (r == rtc::SR_ERROR || r == rtc::SR_EOS) { 639 if (r == rtc::SR_ERROR || r == rtc::SR_EOS) {
640 // Unfortunately, errors are the way that the stream adapter 640 // Unfortunately, errors are the way that the stream adapter
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 packet_size_(1000), count_(0), sent_(0) { 684 packet_size_(1000), count_(0), sent_(0) {
685 } 685 }
686 686
687 void CreateStreams() override { 687 void CreateStreams() override {
688 client_stream_ = 688 client_stream_ =
689 new SSLDummyStreamDTLS(this, "c2s", &client_buffer_, &server_buffer_); 689 new SSLDummyStreamDTLS(this, "c2s", &client_buffer_, &server_buffer_);
690 server_stream_ = 690 server_stream_ =
691 new SSLDummyStreamDTLS(this, "s2c", &server_buffer_, &client_buffer_); 691 new SSLDummyStreamDTLS(this, "s2c", &server_buffer_, &client_buffer_);
692 } 692 }
693 693
694 virtual void WriteData() { 694 void WriteData() override {
695 unsigned char *packet = new unsigned char[1600]; 695 unsigned char *packet = new unsigned char[1600];
696 696
697 while (sent_ < count_) { 697 while (sent_ < count_) {
698 unsigned int rand_state = sent_; 698 unsigned int rand_state = sent_;
699 packet[0] = sent_; 699 packet[0] = sent_;
700 for (size_t i = 1; i < packet_size_; i++) { 700 for (size_t i = 1; i < packet_size_; i++) {
701 // This is a simple LC PRNG. Keep in synch with identical code below. 701 // This is a simple LC PRNG. Keep in synch with identical code below.
702 rand_state = (rand_state * 251 + 19937) >> 7; 702 rand_state = (rand_state * 251 + 19937) >> 7;
703 packet[i] = rand_state & 0xff; 703 packet[i] = rand_state & 0xff;
704 } 704 }
705 705
706 size_t sent; 706 size_t sent;
707 rtc::StreamResult rv = client_ssl_->Write(packet, packet_size_, &sent, 0); 707 rtc::StreamResult rv = client_ssl_->Write(packet, packet_size_, &sent, 0);
708 if (rv == rtc::SR_SUCCESS) { 708 if (rv == rtc::SR_SUCCESS) {
709 LOG(LS_VERBOSE) << "Sent: " << sent_; 709 LOG(LS_VERBOSE) << "Sent: " << sent_;
710 sent_++; 710 sent_++;
711 } else if (rv == rtc::SR_BLOCK) { 711 } else if (rv == rtc::SR_BLOCK) {
712 LOG(LS_VERBOSE) << "Blocked..."; 712 LOG(LS_VERBOSE) << "Blocked...";
713 break; 713 break;
714 } else { 714 } else {
715 ADD_FAILURE(); 715 ADD_FAILURE();
716 break; 716 break;
717 } 717 }
718 } 718 }
719 719
720 delete [] packet; 720 delete [] packet;
721 } 721 }
722 722
723 virtual void ReadData(rtc::StreamInterface *stream) { 723 void ReadData(rtc::StreamInterface *stream) override {
724 unsigned char buffer[2000]; 724 unsigned char buffer[2000];
725 size_t bread; 725 size_t bread;
726 int err2; 726 int err2;
727 rtc::StreamResult r; 727 rtc::StreamResult r;
728 728
729 for (;;) { 729 for (;;) {
730 r = stream->Read(buffer, 2000, &bread, &err2); 730 r = stream->Read(buffer, 2000, &bread, &err2);
731 731
732 if (r == rtc::SR_ERROR) { 732 if (r == rtc::SR_ERROR) {
733 // Unfortunately, errors are the way that the stream adapter 733 // Unfortunately, errors are the way that the stream adapter
(...skipping 15 matching lines...) Expand all
749 unsigned int rand_state = packet_num; 749 unsigned int rand_state = packet_num;
750 for (size_t i = 1; i < packet_size_; i++) { 750 for (size_t i = 1; i < packet_size_; i++) {
751 // This is a simple LC PRNG. Keep in synch with identical code above. 751 // This is a simple LC PRNG. Keep in synch with identical code above.
752 rand_state = (rand_state * 251 + 19937) >> 7; 752 rand_state = (rand_state * 251 + 19937) >> 7;
753 ASSERT_EQ(rand_state & 0xff, buffer[i]); 753 ASSERT_EQ(rand_state & 0xff, buffer[i]);
754 } 754 }
755 received_.insert(packet_num); 755 received_.insert(packet_num);
756 } 756 }
757 } 757 }
758 758
759 virtual void TestTransfer(int count) { 759 void TestTransfer(int count) override {
760 count_ = count; 760 count_ = count;
761 761
762 WriteData(); 762 WriteData();
763 763
764 EXPECT_TRUE_WAIT(sent_ == count_, 10000); 764 EXPECT_TRUE_WAIT(sent_ == count_, 10000);
765 LOG(LS_INFO) << "sent_ == " << sent_; 765 LOG(LS_INFO) << "sent_ == " << sent_;
766 766
767 if (damage_) { 767 if (damage_) {
768 WAIT(false, 2000); 768 WAIT(false, 2000);
769 EXPECT_EQ(0U, received_.size()); 769 EXPECT_EQ(0U, received_.size());
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1158 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)))); 1158 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256))));
1159 INSTANTIATE_TEST_CASE_P( 1159 INSTANTIATE_TEST_CASE_P(
1160 SSLStreamAdapterTestsDTLS, 1160 SSLStreamAdapterTestsDTLS,
1161 SSLStreamAdapterTestDTLS, 1161 SSLStreamAdapterTestDTLS,
1162 Combine(Values(rtc::KeyParams::RSA(1024, 65537), 1162 Combine(Values(rtc::KeyParams::RSA(1024, 65537),
1163 rtc::KeyParams::RSA(1152, 65537), 1163 rtc::KeyParams::RSA(1152, 65537),
1164 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)), 1164 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)),
1165 Values(rtc::KeyParams::RSA(1024, 65537), 1165 Values(rtc::KeyParams::RSA(1024, 65537),
1166 rtc::KeyParams::RSA(1152, 65537), 1166 rtc::KeyParams::RSA(1152, 65537),
1167 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256)))); 1167 rtc::KeyParams::ECDSA(rtc::EC_NIST_P256))));
OLDNEW
« no previous file with comments | « webrtc/base/rtccertificategenerator_unittest.cc ('k') | webrtc/build/common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698