| 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 | 6 |
| 7 #include "modules/websockets/DOMWebSocket.h" | 7 #include "modules/websockets/DOMWebSocket.h" |
| 8 | 8 |
| 9 #include "bindings/core/v8/ExceptionState.h" | 9 #include "bindings/core/v8/ExceptionState.h" |
| 10 #include "bindings/core/v8/V8Binding.h" | 10 #include "bindings/core/v8/V8Binding.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 namespace blink { | 32 namespace blink { |
| 33 | 33 |
| 34 namespace { | 34 namespace { |
| 35 | 35 |
| 36 typedef testing::StrictMock<testing::MockFunction<void(int)> > Checkpoint; // N
OLINT | 36 typedef testing::StrictMock<testing::MockFunction<void(int)> > Checkpoint; // N
OLINT |
| 37 | 37 |
| 38 class MockWebSocketChannel : public WebSocketChannel { | 38 class MockWebSocketChannel : public WebSocketChannel { |
| 39 public: | 39 public: |
| 40 static MockWebSocketChannel* create() | 40 static MockWebSocketChannel* create() |
| 41 { | 41 { |
| 42 return adoptRefCountedGarbageCollected(new testing::StrictMock<MockWebSo
cketChannel>()); | 42 return new testing::StrictMock<MockWebSocketChannel>(); |
| 43 } | 43 } |
| 44 | 44 |
| 45 virtual ~MockWebSocketChannel() | 45 virtual ~MockWebSocketChannel() |
| 46 { | 46 { |
| 47 } | 47 } |
| 48 | 48 |
| 49 MOCK_METHOD2(connect, bool(const KURL&, const String&)); | 49 MOCK_METHOD2(connect, bool(const KURL&, const String&)); |
| 50 MOCK_METHOD1(send, void(const String&)); | 50 MOCK_METHOD1(send, void(const String&)); |
| 51 MOCK_METHOD3(send, void(const ArrayBuffer&, unsigned, unsigned)); | 51 MOCK_METHOD3(send, void(const ArrayBuffer&, unsigned, unsigned)); |
| 52 MOCK_METHOD1(send, void(PassRefPtr<BlobDataHandle>)); | 52 MOCK_METHOD1(send, void(PassRefPtr<BlobDataHandle>)); |
| 53 MOCK_METHOD1(send, void(PassOwnPtr<Vector<char> >)); | 53 MOCK_METHOD1(send, void(PassOwnPtr<Vector<char> >)); |
| 54 MOCK_CONST_METHOD0(bufferedAmount, unsigned long()); | 54 MOCK_CONST_METHOD0(bufferedAmount, unsigned long()); |
| 55 MOCK_METHOD2(close, void(int, const String&)); | 55 MOCK_METHOD2(close, void(int, const String&)); |
| 56 MOCK_METHOD4(fail, void(const String&, MessageLevel, const String&, unsigned
)); | 56 MOCK_METHOD4(fail, void(const String&, MessageLevel, const String&, unsigned
)); |
| 57 MOCK_METHOD0(disconnect, void()); | 57 MOCK_METHOD0(disconnect, void()); |
| 58 MOCK_METHOD0(suspend, void()); | 58 MOCK_METHOD0(suspend, void()); |
| 59 MOCK_METHOD0(resume, void()); | 59 MOCK_METHOD0(resume, void()); |
| 60 | 60 |
| 61 MockWebSocketChannel() | 61 MockWebSocketChannel() |
| 62 { | 62 { |
| 63 } | 63 } |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 class DOMWebSocketWithMockChannel FINAL : public DOMWebSocket { | 66 class DOMWebSocketWithMockChannel FINAL : public DOMWebSocket { |
| 67 public: | 67 public: |
| 68 static DOMWebSocketWithMockChannel* create(ExecutionContext* context) | 68 static DOMWebSocketWithMockChannel* create(ExecutionContext* context) |
| 69 { | 69 { |
| 70 DOMWebSocketWithMockChannel* websocket = adoptRefCountedGarbageCollected
WillBeNoop(new DOMWebSocketWithMockChannel(context)); | 70 DOMWebSocketWithMockChannel* websocket = new DOMWebSocketWithMockChannel
(context); |
| 71 websocket->suspendIfNeeded(); | 71 websocket->suspendIfNeeded(); |
| 72 return websocket; | 72 return websocket; |
| 73 } | 73 } |
| 74 | 74 |
| 75 MockWebSocketChannel* channel() { return m_channel.get(); } | 75 MockWebSocketChannel* channel() { return m_channel.get(); } |
| 76 | 76 |
| 77 virtual WebSocketChannel* createChannel(ExecutionContext*, WebSocketChannelC
lient*) OVERRIDE | 77 virtual WebSocketChannel* createChannel(ExecutionContext*, WebSocketChannelC
lient*) OVERRIDE |
| 78 { | 78 { |
| 79 ASSERT(!m_hasCreatedChannel); | 79 ASSERT(!m_hasCreatedChannel); |
| 80 m_hasCreatedChannel = true; | 80 m_hasCreatedChannel = true; |
| (...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 EXPECT_EQ(InvalidAccessError, m_exceptionState.code()); | 703 EXPECT_EQ(InvalidAccessError, m_exceptionState.code()); |
| 704 EXPECT_EQ(String::format("The code must be either 1000, or between 3000 and
4999. %d is neither.", GetParam()), m_exceptionState.message()); | 704 EXPECT_EQ(String::format("The code must be either 1000, or between 3000 and
4999. %d is neither.", GetParam()), m_exceptionState.message()); |
| 705 EXPECT_EQ(DOMWebSocket::CONNECTING, m_websocket->readyState()); | 705 EXPECT_EQ(DOMWebSocket::CONNECTING, m_websocket->readyState()); |
| 706 } | 706 } |
| 707 | 707 |
| 708 INSTANTIATE_TEST_CASE_P(DOMWebSocketInvalidClosingCode, DOMWebSocketInvalidClosi
ngCodeTest, ::testing::Values(0, 1, 998, 999, 1001, 2999, 5000, 9999, 65535)); | 708 INSTANTIATE_TEST_CASE_P(DOMWebSocketInvalidClosingCode, DOMWebSocketInvalidClosi
ngCodeTest, ::testing::Values(0, 1, 998, 999, 1001, 2999, 5000, 9999, 65535)); |
| 709 | 709 |
| 710 } // namespace | 710 } // namespace |
| 711 | 711 |
| 712 } // namespace blink | 712 } // namespace blink |
| OLD | NEW |