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

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

Issue 711763002: bindings: Transition from ArrayBuffer to DOMArrayBuffer, part 2 (2nd round) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixes Win x64 build. Created 6 years, 1 month 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 | Annotate | Revision Log
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 "config.h" 5 #include "config.h"
6 #include "modules/websockets/DOMWebSocket.h" 6 #include "modules/websockets/DOMWebSocket.h"
7 7
8 #include "bindings/core/v8/ExceptionState.h" 8 #include "bindings/core/v8/ExceptionState.h"
9 #include "bindings/core/v8/V8Binding.h" 9 #include "bindings/core/v8/V8Binding.h"
10 #include "core/dom/DOMTypedArray.h" 10 #include "core/dom/DOMTypedArray.h"
(...skipping 28 matching lines...) Expand all
39 { 39 {
40 return new testing::StrictMock<MockWebSocketChannel>(); 40 return new testing::StrictMock<MockWebSocketChannel>();
41 } 41 }
42 42
43 virtual ~MockWebSocketChannel() 43 virtual ~MockWebSocketChannel()
44 { 44 {
45 } 45 }
46 46
47 MOCK_METHOD2(connect, bool(const KURL&, const String&)); 47 MOCK_METHOD2(connect, bool(const KURL&, const String&));
48 MOCK_METHOD1(send, void(const String&)); 48 MOCK_METHOD1(send, void(const String&));
49 MOCK_METHOD3(send, void(const ArrayBuffer&, unsigned, unsigned)); 49 MOCK_METHOD3(send, void(const DOMArrayBuffer&, unsigned, unsigned));
50 MOCK_METHOD1(send, void(PassRefPtr<BlobDataHandle>)); 50 MOCK_METHOD1(send, void(PassRefPtr<BlobDataHandle>));
51 MOCK_METHOD1(send, void(PassOwnPtr<Vector<char> >)); 51 MOCK_METHOD1(send, void(PassOwnPtr<Vector<char> >));
52 MOCK_CONST_METHOD0(bufferedAmount, unsigned long()); 52 MOCK_CONST_METHOD0(bufferedAmount, unsigned long());
53 MOCK_METHOD2(close, void(int, const String&)); 53 MOCK_METHOD2(close, void(int, const String&));
54 MOCK_METHOD4(fail, void(const String&, MessageLevel, const String&, unsigned )); 54 MOCK_METHOD4(fail, void(const String&, MessageLevel, const String&, unsigned ));
55 MOCK_METHOD0(disconnect, void()); 55 MOCK_METHOD0(disconnect, void());
56 MOCK_METHOD0(suspend, void()); 56 MOCK_METHOD0(suspend, void());
57 MOCK_METHOD0(resume, void()); 57 MOCK_METHOD0(resume, void());
58 58
59 MockWebSocketChannel() 59 MockWebSocketChannel()
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
604 EXPECT_FALSE(m_exceptionState.hadException()); 604 EXPECT_FALSE(m_exceptionState.hadException());
605 EXPECT_EQ(DOMWebSocket::CLOSED, m_websocket->readyState()); 605 EXPECT_EQ(DOMWebSocket::CLOSED, m_websocket->readyState());
606 } 606 }
607 607
608 TEST_F(DOMWebSocketTest, sendArrayBufferSuccess) 608 TEST_F(DOMWebSocketTest, sendArrayBufferSuccess)
609 { 609 {
610 RefPtr<DOMArrayBufferView> view = DOMUint8Array::create(8); 610 RefPtr<DOMArrayBufferView> view = DOMUint8Array::create(8);
611 { 611 {
612 InSequence s; 612 InSequence s;
613 EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String ())).WillOnce(Return(true)); 613 EXPECT_CALL(channel(), connect(KURL(KURL(), "ws://example.com/"), String ())).WillOnce(Return(true));
614 EXPECT_CALL(channel(), send(Ref(*view->view()->buffer()), 0, 8)); 614 EXPECT_CALL(channel(), send(Ref(*view->buffer()), 0, 8));
615 } 615 }
616 m_websocket->connect("ws://example.com/", Vector<String>(), m_exceptionState ); 616 m_websocket->connect("ws://example.com/", Vector<String>(), m_exceptionState );
617 617
618 EXPECT_FALSE(m_exceptionState.hadException()); 618 EXPECT_FALSE(m_exceptionState.hadException());
619 619
620 m_websocket->didConnect("", ""); 620 m_websocket->didConnect("", "");
621 m_websocket->send(view->buffer().get(), m_exceptionState); 621 m_websocket->send(view->buffer().get(), m_exceptionState);
622 622
623 EXPECT_FALSE(m_exceptionState.hadException()); 623 EXPECT_FALSE(m_exceptionState.hadException());
624 EXPECT_EQ(DOMWebSocket::OPEN, m_websocket->readyState()); 624 EXPECT_EQ(DOMWebSocket::OPEN, m_websocket->readyState());
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 EXPECT_EQ(InvalidAccessError, m_exceptionState.code()); 699 EXPECT_EQ(InvalidAccessError, m_exceptionState.code());
700 EXPECT_EQ(String::format("The code must be either 1000, or between 3000 and 4999. %d is neither.", GetParam()), m_exceptionState.message()); 700 EXPECT_EQ(String::format("The code must be either 1000, or between 3000 and 4999. %d is neither.", GetParam()), m_exceptionState.message());
701 EXPECT_EQ(DOMWebSocket::CONNECTING, m_websocket->readyState()); 701 EXPECT_EQ(DOMWebSocket::CONNECTING, m_websocket->readyState());
702 } 702 }
703 703
704 INSTANTIATE_TEST_CASE_P(DOMWebSocketInvalidClosingCode, DOMWebSocketInvalidClosi ngCodeTest, ::testing::Values(0, 1, 998, 999, 1001, 2999, 5000, 9999, 65535)); 704 INSTANTIATE_TEST_CASE_P(DOMWebSocketInvalidClosingCode, DOMWebSocketInvalidClosi ngCodeTest, ::testing::Values(0, 1, 998, 999, 1001, 2999, 5000, 9999, 65535));
705 705
706 } // namespace 706 } // namespace
707 707
708 } // namespace blink 708 } // namespace blink
OLDNEW
« no previous file with comments | « Source/modules/websockets/DOMWebSocket.cpp ('k') | Source/modules/websockets/DocumentWebSocketChannel.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698