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