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

Unified Diff: content/browser/renderer_host/websocket_dispatcher_host_unittest.cc

Issue 416333004: Revert of [WebSocket] Send a close frame when the renderer process is gone. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/websocket_dispatcher_host_unittest.cc
diff --git a/content/browser/renderer_host/websocket_dispatcher_host_unittest.cc b/content/browser/renderer_host/websocket_dispatcher_host_unittest.cc
index 8504d8f770d5f0a700ca6fa0fed561566cac2fa4..e1506d99dd123136367a124b55897f31e0c4bf16 100644
--- a/content/browser/renderer_host/websocket_dispatcher_host_unittest.cc
+++ b/content/browser/renderer_host/websocket_dispatcher_host_unittest.cc
@@ -4,7 +4,6 @@
#include "content/browser/renderer_host/websocket_dispatcher_host.h"
-#include <algorithm>
#include <vector>
#include "base/bind.h"
@@ -24,30 +23,23 @@
// This number is unlikely to occur by chance.
static const int kMagicRenderProcessId = 506116062;
-class WebSocketDispatcherHostTest;
-
// A mock of WebsocketHost which records received messages.
class MockWebSocketHost : public WebSocketHost {
public:
MockWebSocketHost(int routing_id,
WebSocketDispatcherHost* dispatcher,
- net::URLRequestContext* url_request_context,
- WebSocketDispatcherHostTest* owner)
- : WebSocketHost(routing_id, dispatcher, url_request_context),
- owner_(owner) {
+ net::URLRequestContext* url_request_context)
+ : WebSocketHost(routing_id, dispatcher, url_request_context) {
}
virtual ~MockWebSocketHost() {}
- virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE {
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE{
received_messages_.push_back(message);
return true;
}
- virtual void GoAway() OVERRIDE;
-
std::vector<IPC::Message> received_messages_;
- WebSocketDispatcherHostTest* owner_;
};
class WebSocketDispatcherHostTest : public ::testing::Test {
@@ -63,17 +55,12 @@
virtual ~WebSocketDispatcherHostTest() {}
- void GoAway(int routing_id) {
- gone_hosts_.push_back(routing_id);
- }
-
protected:
scoped_refptr<WebSocketDispatcherHost> dispatcher_host_;
// Stores allocated MockWebSocketHost instances. Doesn't take ownership of
// them.
std::vector<MockWebSocketHost*> mock_hosts_;
- std::vector<int> gone_hosts_;
private:
net::URLRequestContext* OnGetRequestContext() {
@@ -82,15 +69,11 @@
WebSocketHost* CreateWebSocketHost(int routing_id) {
MockWebSocketHost* host =
- new MockWebSocketHost(routing_id, dispatcher_host_.get(), NULL, this);
+ new MockWebSocketHost(routing_id, dispatcher_host_.get(), NULL);
mock_hosts_.push_back(host);
return host;
}
};
-
-void MockWebSocketHost::GoAway() {
- owner_->GoAway(routing_id());
-}
TEST_F(WebSocketDispatcherHostTest, Construct) {
// Do nothing.
@@ -173,29 +156,5 @@
}
}
-TEST_F(WebSocketDispatcherHostTest, Destruct) {
- WebSocketHostMsg_AddChannelRequest message1(
- 123, GURL("ws://example.com/test"), std::vector<std::string>(),
- url::Origin("http://example.com"), -1);
- WebSocketHostMsg_AddChannelRequest message2(
- 456, GURL("ws://example.com/test2"), std::vector<std::string>(),
- url::Origin("http://example.com"), -1);
-
- ASSERT_TRUE(dispatcher_host_->OnMessageReceived(message1));
- ASSERT_TRUE(dispatcher_host_->OnMessageReceived(message2));
-
- ASSERT_EQ(2u, mock_hosts_.size());
-
- mock_hosts_.clear();
- dispatcher_host_ = NULL;
-
- ASSERT_EQ(2u, gone_hosts_.size());
- // The gone_hosts_ ordering is not predictable because it depends on the
- // hash_map ordering.
- std::sort(gone_hosts_.begin(), gone_hosts_.end());
- EXPECT_EQ(123, gone_hosts_[0]);
- EXPECT_EQ(456, gone_hosts_[1]);
-}
-
} // namespace
} // namespace content
« no previous file with comments | « content/browser/renderer_host/websocket_dispatcher_host.cc ('k') | content/browser/renderer_host/websocket_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698