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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 = adoptRefCountedGarbageCollected
WillBeNoop(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; |
81 return m_channel.get(); | 81 return m_channel.get(); |
82 } | 82 } |
83 | 83 |
84 virtual void trace(Visitor* visitor) OVERRIDE | 84 virtual void trace(Visitor* visitor) override |
85 { | 85 { |
86 visitor->trace(m_channel); | 86 visitor->trace(m_channel); |
87 DOMWebSocket::trace(visitor); | 87 DOMWebSocket::trace(visitor); |
88 } | 88 } |
89 | 89 |
90 private: | 90 private: |
91 DOMWebSocketWithMockChannel(ExecutionContext* context) | 91 DOMWebSocketWithMockChannel(ExecutionContext* context) |
92 : DOMWebSocket(context) | 92 : DOMWebSocket(context) |
93 , m_channel(MockWebSocketChannel::create()) | 93 , m_channel(MockWebSocketChannel::create()) |
94 , m_hasCreatedChannel(false) { } | 94 , m_hasCreatedChannel(false) { } |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
701 EXPECT_EQ(InvalidAccessError, m_exceptionState.code()); | 701 EXPECT_EQ(InvalidAccessError, m_exceptionState.code()); |
702 EXPECT_EQ(String::format("The code must be either 1000, or between 3000 and
4999. %d is neither.", GetParam()), m_exceptionState.message()); | 702 EXPECT_EQ(String::format("The code must be either 1000, or between 3000 and
4999. %d is neither.", GetParam()), m_exceptionState.message()); |
703 EXPECT_EQ(DOMWebSocket::CONNECTING, m_websocket->readyState()); | 703 EXPECT_EQ(DOMWebSocket::CONNECTING, m_websocket->readyState()); |
704 } | 704 } |
705 | 705 |
706 INSTANTIATE_TEST_CASE_P(DOMWebSocketInvalidClosingCode, DOMWebSocketInvalidClosi
ngCodeTest, ::testing::Values(0, 1, 998, 999, 1001, 2999, 5000, 9999, 65535)); | 706 INSTANTIATE_TEST_CASE_P(DOMWebSocketInvalidClosingCode, DOMWebSocketInvalidClosi
ngCodeTest, ::testing::Values(0, 1, 998, 999, 1001, 2999, 5000, 9999, 65535)); |
707 | 707 |
708 } // namespace | 708 } // namespace |
709 | 709 |
710 } // namespace blink | 710 } // namespace blink |
OLD | NEW |