| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "content/browser/debugger/devtools_client_host.h" | 6 #include "content/browser/debugger/devtools_client_host.h" |
| 7 #include "content/browser/debugger/devtools_manager.h" | 7 #include "content/browser/debugger/devtools_manager.h" |
| 8 #include "content/browser/renderer_host/test_render_view_host.h" | 8 #include "content/browser/renderer_host/test_render_view_host.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 | 10 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } | 67 } |
| 68 | 68 |
| 69 protected: | 69 protected: |
| 70 virtual void SetUp() { | 70 virtual void SetUp() { |
| 71 RenderViewHostTestHarness::SetUp(); | 71 RenderViewHostTestHarness::SetUp(); |
| 72 TestDevToolsClientHost::ResetCounters(); | 72 TestDevToolsClientHost::ResetCounters(); |
| 73 } | 73 } |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 TEST_F(DevToolsManagerTest, OpenAndManuallyCloseDevToolsClientHost) { | 76 TEST_F(DevToolsManagerTest, OpenAndManuallyCloseDevToolsClientHost) { |
| 77 scoped_refptr<DevToolsManager> manager(new DevToolsManager()); | 77 DevToolsManager manager; |
| 78 | 78 |
| 79 DevToolsClientHost* host = manager->GetDevToolsClientHostFor(rvh()); | 79 DevToolsClientHost* host = manager.GetDevToolsClientHostFor(rvh()); |
| 80 EXPECT_TRUE(NULL == host); | 80 EXPECT_TRUE(NULL == host); |
| 81 | 81 |
| 82 TestDevToolsClientHost client_host; | 82 TestDevToolsClientHost client_host; |
| 83 manager->RegisterDevToolsClientHostFor(rvh(), &client_host); | 83 manager.RegisterDevToolsClientHostFor(rvh(), &client_host); |
| 84 // Test that just registered devtools host is returned. | 84 // Test that just registered devtools host is returned. |
| 85 host = manager->GetDevToolsClientHostFor(rvh()); | 85 host = manager.GetDevToolsClientHostFor(rvh()); |
| 86 EXPECT_TRUE(&client_host == host); | 86 EXPECT_TRUE(&client_host == host); |
| 87 EXPECT_EQ(0, TestDevToolsClientHost::close_counter); | 87 EXPECT_EQ(0, TestDevToolsClientHost::close_counter); |
| 88 | 88 |
| 89 // Test that the same devtools host is returned. | 89 // Test that the same devtools host is returned. |
| 90 host = manager->GetDevToolsClientHostFor(rvh()); | 90 host = manager.GetDevToolsClientHostFor(rvh()); |
| 91 EXPECT_TRUE(&client_host == host); | 91 EXPECT_TRUE(&client_host == host); |
| 92 EXPECT_EQ(0, TestDevToolsClientHost::close_counter); | 92 EXPECT_EQ(0, TestDevToolsClientHost::close_counter); |
| 93 | 93 |
| 94 client_host.Close(); | 94 client_host.Close(); |
| 95 EXPECT_EQ(1, TestDevToolsClientHost::close_counter); | 95 EXPECT_EQ(1, TestDevToolsClientHost::close_counter); |
| 96 host = manager->GetDevToolsClientHostFor(rvh()); | 96 host = manager.GetDevToolsClientHostFor(rvh()); |
| 97 EXPECT_TRUE(NULL == host); | 97 EXPECT_TRUE(NULL == host); |
| 98 } | 98 } |
| 99 | 99 |
| 100 TEST_F(DevToolsManagerTest, ForwardMessageToClient) { | 100 TEST_F(DevToolsManagerTest, ForwardMessageToClient) { |
| 101 scoped_refptr<DevToolsManager> manager(new DevToolsManager()); | 101 DevToolsManager manager; |
| 102 | 102 |
| 103 TestDevToolsClientHost client_host; | 103 TestDevToolsClientHost client_host; |
| 104 manager->RegisterDevToolsClientHostFor(rvh(), &client_host); | 104 manager.RegisterDevToolsClientHostFor(rvh(), &client_host); |
| 105 EXPECT_EQ(0, TestDevToolsClientHost::close_counter); | 105 EXPECT_EQ(0, TestDevToolsClientHost::close_counter); |
| 106 | 106 |
| 107 IPC::Message m; | 107 IPC::Message m; |
| 108 manager->ForwardToDevToolsClient(rvh(), m); | 108 manager.ForwardToDevToolsClient(rvh(), m); |
| 109 EXPECT_TRUE(&m == client_host.last_sent_message); | 109 EXPECT_TRUE(&m == client_host.last_sent_message); |
| 110 | 110 |
| 111 client_host.Close(); | 111 client_host.Close(); |
| 112 EXPECT_EQ(1, TestDevToolsClientHost::close_counter); | 112 EXPECT_EQ(1, TestDevToolsClientHost::close_counter); |
| 113 } | 113 } |
| OLD | NEW |