| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <string> | 5 #include <string> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 run_loop_ = NULL; | 72 run_loop_ = NULL; |
| 73 } | 73 } |
| 74 | 74 |
| 75 private: | 75 private: |
| 76 base::RunLoop* run_loop_; | 76 base::RunLoop* run_loop_; |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 class WebSocketTest : public testing::Test { | 79 class WebSocketTest : public testing::Test { |
| 80 public: | 80 public: |
| 81 WebSocketTest() {} | 81 WebSocketTest() {} |
| 82 virtual ~WebSocketTest() {} | 82 ~WebSocketTest() override {} |
| 83 | 83 |
| 84 virtual void SetUp() override { | 84 void SetUp() override { ASSERT_TRUE(server_.Start()); } |
| 85 ASSERT_TRUE(server_.Start()); | |
| 86 } | |
| 87 | 85 |
| 88 virtual void TearDown() override { | 86 void TearDown() override { server_.Stop(); } |
| 89 server_.Stop(); | |
| 90 } | |
| 91 | 87 |
| 92 protected: | 88 protected: |
| 93 scoped_ptr<WebSocket> CreateWebSocket(const GURL& url, | 89 scoped_ptr<WebSocket> CreateWebSocket(const GURL& url, |
| 94 WebSocketListener* listener) { | 90 WebSocketListener* listener) { |
| 95 int error; | 91 int error; |
| 96 scoped_ptr<WebSocket> sock(new WebSocket(url, listener)); | 92 scoped_ptr<WebSocket> sock(new WebSocket(url, listener)); |
| 97 base::RunLoop run_loop; | 93 base::RunLoop run_loop; |
| 98 sock->Connect(base::Bind(&OnConnectFinished, &run_loop, &error)); | 94 sock->Connect(base::Bind(&OnConnectFinished, &run_loop, &error)); |
| 99 loop_.PostDelayedTask( | 95 loop_.PostDelayedTask( |
| 100 FROM_HERE, run_loop.QuitClosure(), | 96 FROM_HERE, run_loop.QuitClosure(), |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 SendReceive(messages); | 196 SendReceive(messages); |
| 201 } | 197 } |
| 202 | 198 |
| 203 TEST_F(WebSocketTest, SendReceiveMultiple) { | 199 TEST_F(WebSocketTest, SendReceiveMultiple) { |
| 204 std::vector<std::string> messages; | 200 std::vector<std::string> messages; |
| 205 messages.push_back("1"); | 201 messages.push_back("1"); |
| 206 messages.push_back("2"); | 202 messages.push_back("2"); |
| 207 messages.push_back("3"); | 203 messages.push_back("3"); |
| 208 SendReceive(messages); | 204 SendReceive(messages); |
| 209 } | 205 } |
| OLD | NEW |