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

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

Issue 310453002: Do not use V8TestingScope::create in WebSocketTest.cpp (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 6
7 #include "modules/websockets/WebSocket.h" 7 #include "modules/websockets/WebSocket.h"
8 8
9 #include "bindings/v8/ExceptionState.h" 9 #include "bindings/v8/ExceptionState.h"
10 #include "bindings/v8/V8Binding.h" 10 #include "bindings/v8/V8Binding.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 RefPtrWillBeMember<MockWebSocketChannel> m_channel; 95 RefPtrWillBeMember<MockWebSocketChannel> m_channel;
96 bool m_hasCreatedChannel; 96 bool m_hasCreatedChannel;
97 }; 97 };
98 98
99 class WebSocketTestBase { 99 class WebSocketTestBase {
100 public: 100 public:
101 WebSocketTestBase() 101 WebSocketTestBase()
102 : m_pageHolder(DummyPageHolder::create()) 102 : m_pageHolder(DummyPageHolder::create())
103 , m_websocket(WebSocketWithMockChannel::create(&m_pageHolder->document() )) 103 , m_websocket(WebSocketWithMockChannel::create(&m_pageHolder->document() ))
104 , m_channel(m_websocket->channel()) 104 , m_channel(m_websocket->channel())
105 , m_executionScope(V8TestingScope::create(v8::Isolate::GetCurrent())) 105 , m_executionScope(v8::Isolate::GetCurrent())
106 , m_exceptionState(ExceptionState::ConstructionContext, "property", "int erface", m_executionScope->scriptState()->context()->Global(), m_executionScope- >isolate()) 106 , m_exceptionState(ExceptionState::ConstructionContext, "property", "int erface", m_executionScope.scriptState()->context()->Global(), m_executionScope.i solate())
107 { 107 {
108 } 108 }
109 109
110 virtual ~WebSocketTestBase() 110 virtual ~WebSocketTestBase()
111 { 111 {
112 if (!m_websocket) 112 if (!m_websocket)
113 return; 113 return;
114 // These statements are needed to clear WebSocket::m_channel to 114 // These statements are needed to clear WebSocket::m_channel to
115 // avoid ASSERTION failure on ~WebSocket. 115 // avoid ASSERTION failure on ~WebSocket.
116 ASSERT(m_channel); 116 ASSERT(m_channel);
117 ::testing::Mock::VerifyAndClear(m_channel.get()); 117 ::testing::Mock::VerifyAndClear(m_channel.get());
118 EXPECT_CALL(*m_channel, disconnect()).Times(AnyNumber()); 118 EXPECT_CALL(*m_channel, disconnect()).Times(AnyNumber());
119 119
120 m_websocket->didClose(0, WebSocketChannelClient::ClosingHandshakeIncompl ete, 1006, ""); 120 m_websocket->didClose(0, WebSocketChannelClient::ClosingHandshakeIncompl ete, 1006, "");
121 } 121 }
122 122
123 OwnPtr<DummyPageHolder> m_pageHolder; 123 OwnPtr<DummyPageHolder> m_pageHolder;
124 RefPtrWillBePersistent<WebSocketWithMockChannel> m_websocket; 124 RefPtrWillBePersistent<WebSocketWithMockChannel> m_websocket;
125 RefPtrWillBePersistent<MockWebSocketChannel> m_channel; 125 RefPtrWillBePersistent<MockWebSocketChannel> m_channel;
126 OwnPtr<V8TestingScope> m_executionScope; 126 V8TestingScope m_executionScope;
127 ExceptionState m_exceptionState; 127 ExceptionState m_exceptionState;
128 }; 128 };
129 129
130 class WebSocketTest : public WebSocketTestBase, public ::testing::Test { 130 class WebSocketTest : public WebSocketTestBase, public ::testing::Test {
131 public: 131 public:
132 }; 132 };
133 133
134 TEST_F(WebSocketTest, connectToBadURL) 134 TEST_F(WebSocketTest, connectToBadURL)
135 { 135 {
136 m_websocket->connect("xxx", Vector<String>(), m_exceptionState); 136 m_websocket->connect("xxx", Vector<String>(), m_exceptionState);
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 EXPECT_EQ(InvalidAccessError, m_exceptionState.code()); 807 EXPECT_EQ(InvalidAccessError, m_exceptionState.code());
808 EXPECT_EQ(String::format("The code must be either 1000, or between 3000 and 4999. %d is neither.", GetParam()), m_exceptionState.message()); 808 EXPECT_EQ(String::format("The code must be either 1000, or between 3000 and 4999. %d is neither.", GetParam()), m_exceptionState.message());
809 EXPECT_EQ(WebSocket::CONNECTING, m_websocket->readyState()); 809 EXPECT_EQ(WebSocket::CONNECTING, m_websocket->readyState());
810 } 810 }
811 811
812 INSTANTIATE_TEST_CASE_P(WebSocketInvalidClosingCode, WebSocketInvalidClosingCode Test, ::testing::Values(0, 1, 998, 999, 1001, 2999, 5000, 9999, 65535)); 812 INSTANTIATE_TEST_CASE_P(WebSocketInvalidClosingCode, WebSocketInvalidClosingCode Test, ::testing::Values(0, 1, 998, 999, 1001, 2999, 5000, 9999, 65535));
813 813
814 } // namespace 814 } // namespace
815 815
816 } // namespace WebCore 816 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698