| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "net/websockets/websocket_channel.h" | 5 #include "net/websockets/websocket_channel.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include <iostream> | 10 #include <iostream> |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 }; | 415 }; |
| 416 | 416 |
| 417 // The definition of EqualsFrames GoogleMock matcher. Unlike the ReturnFrames | 417 // The definition of EqualsFrames GoogleMock matcher. Unlike the ReturnFrames |
| 418 // action, this can take the array by reference. | 418 // action, this can take the array by reference. |
| 419 template <size_t N> | 419 template <size_t N> |
| 420 ::testing::Matcher<ScopedVector<WebSocketFrame>*> EqualsFrames( | 420 ::testing::Matcher<ScopedVector<WebSocketFrame>*> EqualsFrames( |
| 421 const InitFrame (&frames)[N]) { | 421 const InitFrame (&frames)[N]) { |
| 422 return ::testing::MakeMatcher(new EqualsFramesMatcher<N>(&frames)); | 422 return ::testing::MakeMatcher(new EqualsFramesMatcher<N>(&frames)); |
| 423 } | 423 } |
| 424 | 424 |
| 425 // TestClosure works like TestCompletionCallback, but doesn't take an argument. | |
| 426 class TestClosure { | |
| 427 public: | |
| 428 base::Closure closure() { return base::Bind(callback_.callback(), OK); } | |
| 429 | |
| 430 void WaitForResult() { callback_.WaitForResult(); } | |
| 431 | |
| 432 private: | |
| 433 // Delegate to TestCompletionCallback for the implementation. | |
| 434 TestCompletionCallback callback_; | |
| 435 }; | |
| 436 | |
| 437 // A GoogleMock action to run a Closure. | 425 // A GoogleMock action to run a Closure. |
| 438 ACTION_P(InvokeClosure, closure) { closure.Run(); } | 426 ACTION_P(InvokeClosure, closure) { closure.Run(); } |
| 439 | 427 |
| 440 // A GoogleMock action to run a Closure and return CHANNEL_DELETED. | 428 // A GoogleMock action to run a Closure and return CHANNEL_DELETED. |
| 441 ACTION_P(InvokeClosureReturnDeleted, closure) { | 429 ACTION_P(InvokeClosureReturnDeleted, closure) { |
| 442 closure.Run(); | 430 closure.Run(); |
| 443 return WebSocketEventInterface::CHANNEL_DELETED; | 431 return WebSocketEventInterface::CHANNEL_DELETED; |
| 444 } | 432 } |
| 445 | 433 |
| 446 // A FakeWebSocketStream whose ReadFrames() function returns data. | 434 // A FakeWebSocketStream whose ReadFrames() function returns data. |
| (...skipping 2974 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3421 channel_->StartClosingHandshake(kWebSocketNormalClosure, "OK"); | 3409 channel_->StartClosingHandshake(kWebSocketNormalClosure, "OK"); |
| 3422 ASSERT_TRUE(read_frames); | 3410 ASSERT_TRUE(read_frames); |
| 3423 // Provide the "Close" message from the server. | 3411 // Provide the "Close" message from the server. |
| 3424 *read_frames = CreateFrameVector(frames); | 3412 *read_frames = CreateFrameVector(frames); |
| 3425 read_callback.Run(OK); | 3413 read_callback.Run(OK); |
| 3426 completion.WaitForResult(); | 3414 completion.WaitForResult(); |
| 3427 } | 3415 } |
| 3428 | 3416 |
| 3429 } // namespace | 3417 } // namespace |
| 3430 } // namespace net | 3418 } // namespace net |
| OLD | NEW |