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

Side by Side Diff: third_party/WebKit/Source/modules/websockets/DOMWebSocketTest.cpp

Issue 1878463002: Move DOMArrayBuffer, DOMArrayBufferViews and DataView to the heap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tidy Created 4 years, 8 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "modules/websockets/DOMWebSocket.h" 5 #include "modules/websockets/DOMWebSocket.h"
6 6
7 #include "bindings/core/v8/ExceptionState.h" 7 #include "bindings/core/v8/ExceptionState.h"
8 #include "bindings/core/v8/V8Binding.h" 8 #include "bindings/core/v8/V8Binding.h"
9 #include "bindings/core/v8/V8BindingForTesting.h" 9 #include "bindings/core/v8/V8BindingForTesting.h"
10 #include "core/dom/DOMTypedArray.h" 10 #include "core/dom/DOMTypedArray.h"
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 0x0000 591 0x0000
592 }; 592 };
593 m_websocket->send(nonLatin1String, m_exceptionState); 593 m_websocket->send(nonLatin1String, m_exceptionState);
594 594
595 EXPECT_FALSE(m_exceptionState.hadException()); 595 EXPECT_FALSE(m_exceptionState.hadException());
596 EXPECT_EQ(DOMWebSocket::OPEN, m_websocket->readyState()); 596 EXPECT_EQ(DOMWebSocket::OPEN, m_websocket->readyState());
597 } 597 }
598 598
599 TEST_F(DOMWebSocketTest, sendArrayBufferWhenConnecting) 599 TEST_F(DOMWebSocketTest, sendArrayBufferWhenConnecting)
600 { 600 {
601 RefPtr<DOMArrayBufferView> view = DOMUint8Array::create(8); 601 DOMArrayBufferView* view = DOMUint8Array::create(8);
602 { 602 {
603 InSequence s; 603 InSequence s;
604 EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String ())).WillOnce(Return(true)); 604 EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String ())).WillOnce(Return(true));
605 } 605 }
606 m_websocket->connect("ws://example.com/", Vector<String>(), m_exceptionState ); 606 m_websocket->connect("ws://example.com/", Vector<String>(), m_exceptionState );
607 607
608 EXPECT_FALSE(m_exceptionState.hadException()); 608 EXPECT_FALSE(m_exceptionState.hadException());
609 609
610 m_websocket->send(view->buffer().get(), m_exceptionState); 610 m_websocket->send(view->buffer(), m_exceptionState);
611 611
612 EXPECT_TRUE(m_exceptionState.hadException()); 612 EXPECT_TRUE(m_exceptionState.hadException());
613 EXPECT_EQ(InvalidStateError, m_exceptionState.code()); 613 EXPECT_EQ(InvalidStateError, m_exceptionState.code());
614 EXPECT_EQ("Still in CONNECTING state.", m_exceptionState.message()); 614 EXPECT_EQ("Still in CONNECTING state.", m_exceptionState.message());
615 EXPECT_EQ(DOMWebSocket::CONNECTING, m_websocket->readyState()); 615 EXPECT_EQ(DOMWebSocket::CONNECTING, m_websocket->readyState());
616 } 616 }
617 617
618 TEST_F(DOMWebSocketTest, sendArrayBufferWhenClosing) 618 TEST_F(DOMWebSocketTest, sendArrayBufferWhenClosing)
619 { 619 {
620 RefPtr<DOMArrayBufferView> view = DOMUint8Array::create(8); 620 DOMArrayBufferView* view = DOMUint8Array::create(8);
621 { 621 {
622 InSequence s; 622 InSequence s;
623 EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String ())).WillOnce(Return(true)); 623 EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String ())).WillOnce(Return(true));
624 EXPECT_CALL(channel(), fail(_, _, _, _)); 624 EXPECT_CALL(channel(), fail(_, _, _, _));
625 } 625 }
626 m_websocket->connect("ws://example.com/", Vector<String>(), m_exceptionState ); 626 m_websocket->connect("ws://example.com/", Vector<String>(), m_exceptionState );
627 627
628 EXPECT_FALSE(m_exceptionState.hadException()); 628 EXPECT_FALSE(m_exceptionState.hadException());
629 629
630 m_websocket->close(m_exceptionState); 630 m_websocket->close(m_exceptionState);
631 EXPECT_FALSE(m_exceptionState.hadException()); 631 EXPECT_FALSE(m_exceptionState.hadException());
632 632
633 m_websocket->send(view->buffer().get(), m_exceptionState); 633 m_websocket->send(view->buffer(), m_exceptionState);
634 634
635 EXPECT_FALSE(m_exceptionState.hadException()); 635 EXPECT_FALSE(m_exceptionState.hadException());
636 EXPECT_EQ(DOMWebSocket::CLOSING, m_websocket->readyState()); 636 EXPECT_EQ(DOMWebSocket::CLOSING, m_websocket->readyState());
637 } 637 }
638 638
639 TEST_F(DOMWebSocketTest, sendArrayBufferWhenClosed) 639 TEST_F(DOMWebSocketTest, sendArrayBufferWhenClosed)
640 { 640 {
641 Checkpoint checkpoint; 641 Checkpoint checkpoint;
642 RefPtr<DOMArrayBufferView> view = DOMUint8Array::create(8); 642 DOMArrayBufferView* view = DOMUint8Array::create(8);
643 { 643 {
644 InSequence s; 644 InSequence s;
645 EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String ())).WillOnce(Return(true)); 645 EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String ())).WillOnce(Return(true));
646 EXPECT_CALL(channel(), disconnect()); 646 EXPECT_CALL(channel(), disconnect());
647 EXPECT_CALL(checkpoint, Call(1)); 647 EXPECT_CALL(checkpoint, Call(1));
648 } 648 }
649 m_websocket->connect("ws://example.com/", Vector<String>(), m_exceptionState ); 649 m_websocket->connect("ws://example.com/", Vector<String>(), m_exceptionState );
650 650
651 EXPECT_FALSE(m_exceptionState.hadException()); 651 EXPECT_FALSE(m_exceptionState.hadException());
652 652
653 m_websocket->didClose(WebSocketChannelClient::ClosingHandshakeIncomplete, 10 06, ""); 653 m_websocket->didClose(WebSocketChannelClient::ClosingHandshakeIncomplete, 10 06, "");
654 checkpoint.Call(1); 654 checkpoint.Call(1);
655 655
656 m_websocket->send(view->buffer().get(), m_exceptionState); 656 m_websocket->send(view->buffer(), m_exceptionState);
657 657
658 EXPECT_FALSE(m_exceptionState.hadException()); 658 EXPECT_FALSE(m_exceptionState.hadException());
659 EXPECT_EQ(DOMWebSocket::CLOSED, m_websocket->readyState()); 659 EXPECT_EQ(DOMWebSocket::CLOSED, m_websocket->readyState());
660 } 660 }
661 661
662 TEST_F(DOMWebSocketTest, sendArrayBufferSuccess) 662 TEST_F(DOMWebSocketTest, sendArrayBufferSuccess)
663 { 663 {
664 RefPtr<DOMArrayBufferView> view = DOMUint8Array::create(8); 664 DOMArrayBufferView* view = DOMUint8Array::create(8);
665 { 665 {
666 InSequence s; 666 InSequence s;
667 EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String ())).WillOnce(Return(true)); 667 EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String ())).WillOnce(Return(true));
668 EXPECT_CALL(channel(), send(Ref(*view->buffer()), 0, 8)); 668 EXPECT_CALL(channel(), send(Ref(*view->buffer()), 0, 8));
669 } 669 }
670 m_websocket->connect("ws://example.com/", Vector<String>(), m_exceptionState ); 670 m_websocket->connect("ws://example.com/", Vector<String>(), m_exceptionState );
671 671
672 EXPECT_FALSE(m_exceptionState.hadException()); 672 EXPECT_FALSE(m_exceptionState.hadException());
673 673
674 m_websocket->didConnect("", ""); 674 m_websocket->didConnect("", "");
675 m_websocket->send(view->buffer().get(), m_exceptionState); 675 m_websocket->send(view->buffer(), m_exceptionState);
676 676
677 EXPECT_FALSE(m_exceptionState.hadException()); 677 EXPECT_FALSE(m_exceptionState.hadException());
678 EXPECT_EQ(DOMWebSocket::OPEN, m_websocket->readyState()); 678 EXPECT_EQ(DOMWebSocket::OPEN, m_websocket->readyState());
679 } 679 }
680 680
681 // FIXME: We should have Blob tests here. 681 // FIXME: We should have Blob tests here.
682 // We can't create a Blob because the blob registration cannot be mocked yet. 682 // We can't create a Blob because the blob registration cannot be mocked yet.
683 683
684 // FIXME: We should add tests for bufferedAmount. 684 // FIXME: We should add tests for bufferedAmount.
685 685
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
745 EXPECT_EQ(InvalidAccessError, m_exceptionState.code()); 745 EXPECT_EQ(InvalidAccessError, m_exceptionState.code());
746 EXPECT_EQ(String::format("The code must be either 1000, or between 3000 and 4999. %d is neither.", GetParam()), m_exceptionState.message()); 746 EXPECT_EQ(String::format("The code must be either 1000, or between 3000 and 4999. %d is neither.", GetParam()), m_exceptionState.message());
747 EXPECT_EQ(DOMWebSocket::CONNECTING, m_websocket->readyState()); 747 EXPECT_EQ(DOMWebSocket::CONNECTING, m_websocket->readyState());
748 } 748 }
749 749
750 INSTANTIATE_TEST_CASE_P(DOMWebSocketInvalidClosingCode, DOMWebSocketInvalidClosi ngCodeTest, ::testing::Values(0, 1, 998, 999, 1001, 2999, 5000, 9999, 65535)); 750 INSTANTIATE_TEST_CASE_P(DOMWebSocketInvalidClosingCode, DOMWebSocketInvalidClosi ngCodeTest, ::testing::Values(0, 1, 998, 999, 1001, 2999, 5000, 9999, 65535));
751 751
752 } // namespace 752 } // namespace
753 753
754 } // namespace blink 754 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698