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

Side by Side Diff: content/browser/presentation/presentation_service_impl_unittest.cc

Issue 1549113002: Switch to standard integer types in content/browser/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 12 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stddef.h>
6 #include <stdint.h>
7
5 #include <string> 8 #include <string>
6 #include <vector> 9 #include <vector>
7 10
8 #include "base/location.h" 11 #include "base/location.h"
9 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
10 #include "base/run_loop.h" 13 #include "base/run_loop.h"
11 #include "base/single_thread_task_runner.h" 14 #include "base/single_thread_task_runner.h"
12 #include "base/test/test_timeouts.h" 15 #include "base/test/test_timeouts.h"
13 #include "base/thread_task_runner_handle.h" 16 #include "base/thread_task_runner_handle.h"
14 #include "content/browser/presentation/presentation_service_impl.h" 17 #include "content/browser/presentation/presentation_service_impl.h"
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
654 EXPECT_FALSE(test_message->is_binary()); 657 EXPECT_FALSE(test_message->is_binary());
655 EXPECT_LE(test_message->message.size(), kMaxPresentationSessionMessageSize); 658 EXPECT_LE(test_message->message.size(), kMaxPresentationSessionMessageSize);
656 EXPECT_EQ(message, test_message->message); 659 EXPECT_EQ(message, test_message->message);
657 ASSERT_FALSE(test_message->data); 660 ASSERT_FALSE(test_message->data);
658 send_message_cb.Run(true); 661 send_message_cb.Run(true);
659 SaveQuitClosureAndRunLoop(); 662 SaveQuitClosureAndRunLoop();
660 } 663 }
661 664
662 TEST_F(PresentationServiceImplTest, SendArrayBuffer) { 665 TEST_F(PresentationServiceImplTest, SendArrayBuffer) {
663 // Test Array buffer data. 666 // Test Array buffer data.
664 const uint8 buffer[] = {0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48}; 667 const uint8_t buffer[] = {0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48};
665 std::vector<uint8> data; 668 std::vector<uint8_t> data;
666 data.assign(buffer, buffer + sizeof(buffer)); 669 data.assign(buffer, buffer + sizeof(buffer));
667 670
668 presentation::PresentationSessionInfoPtr session( 671 presentation::PresentationSessionInfoPtr session(
669 presentation::PresentationSessionInfo::New()); 672 presentation::PresentationSessionInfo::New());
670 session->url = kPresentationUrl; 673 session->url = kPresentationUrl;
671 session->id = kPresentationId; 674 session->id = kPresentationId;
672 presentation::SessionMessagePtr message_request( 675 presentation::SessionMessagePtr message_request(
673 presentation::SessionMessage::New()); 676 presentation::SessionMessage::New());
674 message_request->type = presentation::PresentationMessageType:: 677 message_request->type = presentation::PresentationMessageType::
675 PRESENTATION_MESSAGE_TYPE_ARRAY_BUFFER; 678 PRESENTATION_MESSAGE_TYPE_ARRAY_BUFFER;
676 message_request->data = mojo::Array<uint8>::From(data); 679 message_request->data = mojo::Array<uint8_t>::From(data);
677 service_ptr_->SendSessionMessage( 680 service_ptr_->SendSessionMessage(
678 session.Pass(), message_request.Pass(), 681 session.Pass(), message_request.Pass(),
679 base::Bind(&PresentationServiceImplTest::ExpectSendMessageMojoCallback, 682 base::Bind(&PresentationServiceImplTest::ExpectSendMessageMojoCallback,
680 base::Unretained(this))); 683 base::Unretained(this)));
681 684
682 base::RunLoop run_loop; 685 base::RunLoop run_loop;
683 base::Callback<void(bool)> send_message_cb; 686 base::Callback<void(bool)> send_message_cb;
684 PresentationSessionMessage* test_message = nullptr; 687 PresentationSessionMessage* test_message = nullptr;
685 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _)) 688 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _))
686 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), 689 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
(...skipping 11 matching lines...) Expand all
698 EXPECT_LE(test_message->data->size(), kMaxPresentationSessionMessageSize); 701 EXPECT_LE(test_message->data->size(), kMaxPresentationSessionMessageSize);
699 EXPECT_EQ(0, memcmp(buffer, &(*test_message->data)[0], sizeof(buffer))); 702 EXPECT_EQ(0, memcmp(buffer, &(*test_message->data)[0], sizeof(buffer)));
700 send_message_cb.Run(true); 703 send_message_cb.Run(true);
701 SaveQuitClosureAndRunLoop(); 704 SaveQuitClosureAndRunLoop();
702 } 705 }
703 706
704 TEST_F(PresentationServiceImplTest, SendArrayBufferWithExceedingLimit) { 707 TEST_F(PresentationServiceImplTest, SendArrayBufferWithExceedingLimit) {
705 // Create buffer with size exceeding the limit. 708 // Create buffer with size exceeding the limit.
706 // Use same size as in content::kMaxPresentationSessionMessageSize. 709 // Use same size as in content::kMaxPresentationSessionMessageSize.
707 const size_t kMaxBufferSizeInBytes = 64 * 1024; // 64 KB. 710 const size_t kMaxBufferSizeInBytes = 64 * 1024; // 64 KB.
708 uint8 buffer[kMaxBufferSizeInBytes+1]; 711 uint8_t buffer[kMaxBufferSizeInBytes + 1];
709 memset(buffer, 0, kMaxBufferSizeInBytes+1); 712 memset(buffer, 0, kMaxBufferSizeInBytes+1);
710 std::vector<uint8> data; 713 std::vector<uint8_t> data;
711 data.assign(buffer, buffer + sizeof(buffer)); 714 data.assign(buffer, buffer + sizeof(buffer));
712 715
713 presentation::PresentationSessionInfoPtr session( 716 presentation::PresentationSessionInfoPtr session(
714 presentation::PresentationSessionInfo::New()); 717 presentation::PresentationSessionInfo::New());
715 session->url = kPresentationUrl; 718 session->url = kPresentationUrl;
716 session->id = kPresentationId; 719 session->id = kPresentationId;
717 presentation::SessionMessagePtr message_request( 720 presentation::SessionMessagePtr message_request(
718 presentation::SessionMessage::New()); 721 presentation::SessionMessage::New());
719 message_request->type = presentation::PresentationMessageType:: 722 message_request->type = presentation::PresentationMessageType::
720 PRESENTATION_MESSAGE_TYPE_ARRAY_BUFFER; 723 PRESENTATION_MESSAGE_TYPE_ARRAY_BUFFER;
721 message_request->data = mojo::Array<uint8>::From(data); 724 message_request->data = mojo::Array<uint8_t>::From(data);
722 service_ptr_->SendSessionMessage( 725 service_ptr_->SendSessionMessage(
723 session.Pass(), message_request.Pass(), 726 session.Pass(), message_request.Pass(),
724 base::Bind(&PresentationServiceImplTest::ExpectSendMessageMojoCallback, 727 base::Bind(&PresentationServiceImplTest::ExpectSendMessageMojoCallback,
725 base::Unretained(this))); 728 base::Unretained(this)));
726 729
727 base::RunLoop run_loop; 730 base::RunLoop run_loop;
728 base::Callback<void(bool)> send_message_cb; 731 base::Callback<void(bool)> send_message_cb;
729 PresentationSessionMessage* test_message = nullptr; 732 PresentationSessionMessage* test_message = nullptr;
730 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _)) 733 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _))
731 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), 734 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
732 SaveArg<3>(&test_message), SaveArg<4>(&send_message_cb))); 735 SaveArg<3>(&test_message), SaveArg<4>(&send_message_cb)));
733 run_loop.Run(); 736 run_loop.Run();
734 737
735 EXPECT_FALSE(test_message); 738 EXPECT_FALSE(test_message);
736 send_message_cb.Run(true); 739 send_message_cb.Run(true);
737 SaveQuitClosureAndRunLoop(); 740 SaveQuitClosureAndRunLoop();
738 } 741 }
739 742
740 TEST_F(PresentationServiceImplTest, SendBlobData) { 743 TEST_F(PresentationServiceImplTest, SendBlobData) {
741 const uint8 buffer[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07}; 744 const uint8_t buffer[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
742 std::vector<uint8> data; 745 std::vector<uint8_t> data;
743 data.assign(buffer, buffer + sizeof(buffer)); 746 data.assign(buffer, buffer + sizeof(buffer));
744 747
745 presentation::PresentationSessionInfoPtr session( 748 presentation::PresentationSessionInfoPtr session(
746 presentation::PresentationSessionInfo::New()); 749 presentation::PresentationSessionInfo::New());
747 session->url = kPresentationUrl; 750 session->url = kPresentationUrl;
748 session->id = kPresentationId; 751 session->id = kPresentationId;
749 presentation::SessionMessagePtr message_request( 752 presentation::SessionMessagePtr message_request(
750 presentation::SessionMessage::New()); 753 presentation::SessionMessage::New());
751 message_request->type = 754 message_request->type =
752 presentation::PresentationMessageType::PRESENTATION_MESSAGE_TYPE_BLOB; 755 presentation::PresentationMessageType::PRESENTATION_MESSAGE_TYPE_BLOB;
753 message_request->data = mojo::Array<uint8>::From(data); 756 message_request->data = mojo::Array<uint8_t>::From(data);
754 service_ptr_->SendSessionMessage( 757 service_ptr_->SendSessionMessage(
755 session.Pass(), message_request.Pass(), 758 session.Pass(), message_request.Pass(),
756 base::Bind(&PresentationServiceImplTest::ExpectSendMessageMojoCallback, 759 base::Bind(&PresentationServiceImplTest::ExpectSendMessageMojoCallback,
757 base::Unretained(this))); 760 base::Unretained(this)));
758 761
759 base::RunLoop run_loop; 762 base::RunLoop run_loop;
760 base::Callback<void(bool)> send_message_cb; 763 base::Callback<void(bool)> send_message_cb;
761 PresentationSessionMessage* test_message = nullptr; 764 PresentationSessionMessage* test_message = nullptr;
762 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _)) 765 EXPECT_CALL(mock_delegate_, SendMessageRawPtr(_, _, _, _, _))
763 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit), 766 .WillOnce(DoAll(InvokeWithoutArgs(&run_loop, &base::RunLoop::Quit),
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 807
805 TEST_F(PresentationServiceImplTest, ScreenAvailabilityNotSupported) { 808 TEST_F(PresentationServiceImplTest, ScreenAvailabilityNotSupported) {
806 mock_delegate_.set_screen_availability_listening_supported(false); 809 mock_delegate_.set_screen_availability_listening_supported(false);
807 EXPECT_CALL(mock_client_, 810 EXPECT_CALL(mock_client_,
808 OnScreenAvailabilityNotSupported(Eq(kPresentationUrl))); 811 OnScreenAvailabilityNotSupported(Eq(kPresentationUrl)));
809 812
810 ListenForScreenAvailabilityAndWait(kPresentationUrl, false); 813 ListenForScreenAvailabilityAndWait(kPresentationUrl, false);
811 } 814 }
812 815
813 } // namespace content 816 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/presentation/presentation_service_impl.cc ('k') | content/browser/profiler_controller_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698