OLD | NEW |
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 "bindings/core/v8/V8BindingForTesting.h" | 10 #include "bindings/core/v8/V8BindingForTesting.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 typedef testing::StrictMock<testing::MockFunction<void(int)>> Checkpoint; // NO
LINT | 38 typedef testing::StrictMock<testing::MockFunction<void(int)>> Checkpoint; // NO
LINT |
39 | 39 |
40 class MockWebSocketChannel : public WebSocketChannel { | 40 class MockWebSocketChannel : public WebSocketChannel { |
41 public: | 41 public: |
42 static MockWebSocketChannel* create() | 42 static MockWebSocketChannel* create() |
43 { | 43 { |
44 return new testing::StrictMock<MockWebSocketChannel>(); | 44 return new testing::StrictMock<MockWebSocketChannel>(); |
45 } | 45 } |
46 | 46 |
47 virtual ~MockWebSocketChannel() | 47 ~MockWebSocketChannel() override |
48 { | 48 { |
49 } | 49 } |
50 | 50 |
51 MOCK_METHOD2(connect, bool(const KURL&, const String&)); | 51 MOCK_METHOD2(connect, bool(const KURL&, const String&)); |
52 MOCK_METHOD1(send, void(const CString&)); | 52 MOCK_METHOD1(send, void(const CString&)); |
53 MOCK_METHOD3(send, void(const DOMArrayBuffer&, unsigned, unsigned)); | 53 MOCK_METHOD3(send, void(const DOMArrayBuffer&, unsigned, unsigned)); |
54 MOCK_METHOD1(send, void(PassRefPtr<BlobDataHandle>)); | 54 MOCK_METHOD1(send, void(PassRefPtr<BlobDataHandle>)); |
55 MOCK_METHOD1(sendTextAsCharVector, void(PassOwnPtr<Vector<char>>)); | 55 MOCK_METHOD1(sendTextAsCharVector, void(PassOwnPtr<Vector<char>>)); |
56 MOCK_METHOD1(sendBinaryAsCharVector, void(PassOwnPtr<Vector<char>>)); | 56 MOCK_METHOD1(sendBinaryAsCharVector, void(PassOwnPtr<Vector<char>>)); |
57 MOCK_CONST_METHOD0(bufferedAmount, unsigned()); | 57 MOCK_CONST_METHOD0(bufferedAmount, unsigned()); |
(...skipping 10 matching lines...) Expand all Loading... |
68 public: | 68 public: |
69 static DOMWebSocketWithMockChannel* create(ExecutionContext* context) | 69 static DOMWebSocketWithMockChannel* create(ExecutionContext* context) |
70 { | 70 { |
71 DOMWebSocketWithMockChannel* websocket = new DOMWebSocketWithMockChannel
(context); | 71 DOMWebSocketWithMockChannel* websocket = new DOMWebSocketWithMockChannel
(context); |
72 websocket->suspendIfNeeded(); | 72 websocket->suspendIfNeeded(); |
73 return websocket; | 73 return websocket; |
74 } | 74 } |
75 | 75 |
76 MockWebSocketChannel* channel() { return m_channel.get(); } | 76 MockWebSocketChannel* channel() { return m_channel.get(); } |
77 | 77 |
78 virtual WebSocketChannel* createChannel(ExecutionContext*, WebSocketChannelC
lient*) override | 78 WebSocketChannel* createChannel(ExecutionContext*, WebSocketChannelClient*)
override |
79 { | 79 { |
80 ASSERT(!m_hasCreatedChannel); | 80 ASSERT(!m_hasCreatedChannel); |
81 m_hasCreatedChannel = true; | 81 m_hasCreatedChannel = true; |
82 return m_channel.get(); | 82 return m_channel.get(); |
83 } | 83 } |
84 | 84 |
85 DEFINE_INLINE_VIRTUAL_TRACE() | 85 DEFINE_INLINE_VIRTUAL_TRACE() |
86 { | 86 { |
87 visitor->trace(m_channel); | 87 visitor->trace(m_channel); |
88 DOMWebSocket::trace(visitor); | 88 DOMWebSocket::trace(visitor); |
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
747 EXPECT_EQ(InvalidAccessError, m_exceptionState.code()); | 747 EXPECT_EQ(InvalidAccessError, m_exceptionState.code()); |
748 EXPECT_EQ(String::format("The code must be either 1000, or between 3000 and
4999. %d is neither.", GetParam()), m_exceptionState.message()); | 748 EXPECT_EQ(String::format("The code must be either 1000, or between 3000 and
4999. %d is neither.", GetParam()), m_exceptionState.message()); |
749 EXPECT_EQ(DOMWebSocket::CONNECTING, m_websocket->readyState()); | 749 EXPECT_EQ(DOMWebSocket::CONNECTING, m_websocket->readyState()); |
750 } | 750 } |
751 | 751 |
752 INSTANTIATE_TEST_CASE_P(DOMWebSocketInvalidClosingCode, DOMWebSocketInvalidClosi
ngCodeTest, ::testing::Values(0, 1, 998, 999, 1001, 2999, 5000, 9999, 65535)); | 752 INSTANTIATE_TEST_CASE_P(DOMWebSocketInvalidClosingCode, DOMWebSocketInvalidClosi
ngCodeTest, ::testing::Values(0, 1, 998, 999, 1001, 2999, 5000, 9999, 65535)); |
753 | 753 |
754 } // namespace | 754 } // namespace |
755 | 755 |
756 } // namespace blink | 756 } // namespace blink |
OLD | NEW |