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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/time.h" | 6 #include "base/time.h" |
7 #include "content/browser/debugger/devtools_manager_impl.h" | 7 #include "content/browser/debugger/devtools_manager_impl.h" |
8 #include "content/browser/debugger/render_view_devtools_agent_host.h" | 8 #include "content/browser/debugger/render_view_devtools_agent_host.h" |
9 #include "content/browser/mock_content_browser_client.h" | 9 #include "content/browser/mock_content_browser_client.h" |
10 #include "content/browser/renderer_host/test_render_view_host.h" | 10 #include "content/browser/renderer_host/test_render_view_host.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 virtual ~TestDevToolsClientHost() { | 37 virtual ~TestDevToolsClientHost() { |
38 EXPECT_TRUE(closed_); | 38 EXPECT_TRUE(closed_); |
39 } | 39 } |
40 | 40 |
41 virtual void Close(DevToolsManager* manager) { | 41 virtual void Close(DevToolsManager* manager) { |
42 EXPECT_FALSE(closed_); | 42 EXPECT_FALSE(closed_); |
43 close_counter++; | 43 close_counter++; |
44 manager->ClientHostClosing(this); | 44 manager->ClientHostClosing(this); |
45 closed_ = true; | 45 closed_ = true; |
46 } | 46 } |
47 virtual void InspectedTabClosing() { | 47 virtual void InspectedContentsClosing() { |
48 FAIL(); | 48 FAIL(); |
49 } | 49 } |
50 | 50 |
51 virtual void SetInspectedTabUrl(const std::string& url) { | |
52 } | |
53 | |
54 virtual void DispatchOnInspectorFrontend(const std::string& message) { | 51 virtual void DispatchOnInspectorFrontend(const std::string& message) { |
55 last_sent_message = &message; | 52 last_sent_message = &message; |
56 } | 53 } |
57 | 54 |
58 virtual void TabReplaced(WebContents* new_tab) { | 55 virtual void ContentsReplaced(WebContents* new_contents) { |
59 } | 56 } |
60 | 57 |
61 static void ResetCounters() { | 58 static void ResetCounters() { |
62 close_counter = 0; | 59 close_counter = 0; |
63 } | 60 } |
64 | 61 |
65 static int close_counter; | 62 static int close_counter; |
66 | 63 |
67 const std::string* last_sent_message; | 64 const std::string* last_sent_message; |
68 | 65 |
69 private: | 66 private: |
70 bool closed_; | 67 bool closed_; |
71 | 68 |
72 virtual void FrameNavigating(const std::string& url) {} | 69 virtual void FrameNavigating(const std::string& url) {} |
73 | 70 |
74 DISALLOW_COPY_AND_ASSIGN(TestDevToolsClientHost); | 71 DISALLOW_COPY_AND_ASSIGN(TestDevToolsClientHost); |
75 }; | 72 }; |
76 | 73 |
77 int TestDevToolsClientHost::close_counter = 0; | 74 int TestDevToolsClientHost::close_counter = 0; |
78 | 75 |
79 | 76 |
80 class TestWebContentsDelegate : public content::WebContentsDelegate { | 77 class TestWebContentsDelegate : public content::WebContentsDelegate { |
81 public: | 78 public: |
82 TestWebContentsDelegate() : renderer_unresponsive_received_(false) {} | 79 TestWebContentsDelegate() : renderer_unresponsive_received_(false) {} |
83 | 80 |
84 // Notification that the tab is hung. | 81 // Notification that the contents is hung. |
85 virtual void RendererUnresponsive(WebContents* source) { | 82 virtual void RendererUnresponsive(WebContents* source) { |
86 renderer_unresponsive_received_ = true; | 83 renderer_unresponsive_received_ = true; |
87 } | 84 } |
88 | 85 |
89 bool renderer_unresponsive_received() const { | 86 bool renderer_unresponsive_received() const { |
90 return renderer_unresponsive_received_; | 87 return renderer_unresponsive_received_; |
91 } | 88 } |
92 | 89 |
93 private: | 90 private: |
94 bool renderer_unresponsive_received_; | 91 bool renderer_unresponsive_received_; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 170 |
174 std::string m = "test message"; | 171 std::string m = "test message"; |
175 agent_host = DevToolsAgentHostRegistry::GetDevToolsAgentHost(rvh()); | 172 agent_host = DevToolsAgentHostRegistry::GetDevToolsAgentHost(rvh()); |
176 manager.DispatchOnInspectorFrontend(agent_host, m); | 173 manager.DispatchOnInspectorFrontend(agent_host, m); |
177 EXPECT_TRUE(&m == client_host.last_sent_message); | 174 EXPECT_TRUE(&m == client_host.last_sent_message); |
178 | 175 |
179 client_host.Close(&manager); | 176 client_host.Close(&manager); |
180 EXPECT_EQ(1, TestDevToolsClientHost::close_counter); | 177 EXPECT_EQ(1, TestDevToolsClientHost::close_counter); |
181 } | 178 } |
182 | 179 |
183 TEST_F(DevToolsManagerTest, NoUnresponsiveDialogInInspectedTab) { | 180 TEST_F(DevToolsManagerTest, NoUnresponsiveDialogInInspectedContents) { |
184 content::TestRenderViewHost* inspected_rvh = test_rvh(); | 181 content::TestRenderViewHost* inspected_rvh = test_rvh(); |
185 inspected_rvh->set_render_view_created(true); | 182 inspected_rvh->set_render_view_created(true); |
186 EXPECT_FALSE(contents()->GetDelegate()); | 183 EXPECT_FALSE(contents()->GetDelegate()); |
187 TestWebContentsDelegate delegate; | 184 TestWebContentsDelegate delegate; |
188 contents()->SetDelegate(&delegate); | 185 contents()->SetDelegate(&delegate); |
189 | 186 |
190 TestDevToolsClientHost client_host; | 187 TestDevToolsClientHost client_host; |
191 DevToolsAgentHost* agent_host = | 188 DevToolsAgentHost* agent_host = |
192 DevToolsAgentHostRegistry::GetDevToolsAgentHost(inspected_rvh); | 189 DevToolsAgentHostRegistry::GetDevToolsAgentHost(inspected_rvh); |
193 DevToolsManager::GetInstance()-> | 190 DevToolsManager::GetInstance()-> |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 | 236 |
240 // Interrupt pending navigation and navigate back to the original site. | 237 // Interrupt pending navigation and navigate back to the original site. |
241 controller().LoadURL( | 238 controller().LoadURL( |
242 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); | 239 url, content::Referrer(), content::PAGE_TRANSITION_TYPED, std::string()); |
243 contents()->TestDidNavigate(rvh(), 1, url, content::PAGE_TRANSITION_TYPED); | 240 contents()->TestDidNavigate(rvh(), 1, url, content::PAGE_TRANSITION_TYPED); |
244 EXPECT_FALSE(contents()->cross_navigation_pending()); | 241 EXPECT_FALSE(contents()->cross_navigation_pending()); |
245 EXPECT_EQ(&client_host, devtools_manager->GetDevToolsClientHostFor( | 242 EXPECT_EQ(&client_host, devtools_manager->GetDevToolsClientHostFor( |
246 DevToolsAgentHostRegistry::GetDevToolsAgentHost(rvh()))); | 243 DevToolsAgentHostRegistry::GetDevToolsAgentHost(rvh()))); |
247 client_host.Close(DevToolsManager::GetInstance()); | 244 client_host.Close(DevToolsManager::GetInstance()); |
248 } | 245 } |
OLD | NEW |