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 "content/public/test/browser_test_utils.h" | 5 #include "content/public/test/browser_test_utils.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/process_util.h" | 10 #include "base/process_util.h" |
11 #include "base/rand_util.h" | 11 #include "base/rand_util.h" |
12 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
13 #include "base/test/test_timeouts.h" | 13 #include "base/test/test_timeouts.h" |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "net/base/net_util.h" | 15 #include "net/base/net_util.h" |
16 #include "content/public/browser/dom_operation_notification_details.h" | 16 #include "content/public/browser/dom_operation_notification_details.h" |
17 #include "content/public/browser/notification_types.h" | 17 #include "content/public/browser/notification_types.h" |
| 18 #include "content/public/browser/render_process_host.h" |
18 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
19 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
20 #include "content/public/browser/web_contents_observer.h" | 21 #include "content/public/browser/web_contents_observer.h" |
21 #include "content/public/browser/web_contents_view.h" | 22 #include "content/public/browser/web_contents_view.h" |
22 #include "content/public/test/test_utils.h" | 23 #include "content/public/test/test_utils.h" |
23 #include "net/test/python_utils.h" | 24 #include "net/test/python_utils.h" |
24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
25 | 26 |
26 static const int kDefaultWsPort = 8880; | 27 static const int kDefaultWsPort = 8880; |
27 | 28 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 WindowedNotificationObserver load_stop_observer( | 164 WindowedNotificationObserver load_stop_observer( |
164 NOTIFICATION_LOAD_STOP, | 165 NOTIFICATION_LOAD_STOP, |
165 Source<NavigationController>(&web_contents->GetController())); | 166 Source<NavigationController>(&web_contents->GetController())); |
166 // In many cases, the load may have finished before we get here. Only wait if | 167 // In many cases, the load may have finished before we get here. Only wait if |
167 // the tab still has a pending navigation. | 168 // the tab still has a pending navigation. |
168 if (!web_contents->IsLoading()) | 169 if (!web_contents->IsLoading()) |
169 return; | 170 return; |
170 load_stop_observer.Wait(); | 171 load_stop_observer.Wait(); |
171 } | 172 } |
172 | 173 |
| 174 void CrashTab(WebContents* web_contents) { |
| 175 RenderProcessHost* rph = web_contents->GetRenderProcessHost(); |
| 176 WindowedNotificationObserver observer( |
| 177 NOTIFICATION_RENDERER_PROCESS_CLOSED, |
| 178 Source<RenderProcessHost>(rph)); |
| 179 base::KillProcess(rph->GetHandle(), 0, false); |
| 180 observer.Wait(); |
| 181 } |
173 | 182 |
174 void SimulateMouseClick(WebContents* web_contents) { | 183 void SimulateMouseClick(WebContents* web_contents) { |
175 int x = web_contents->GetView()->GetContainerSize().width() / 2; | 184 int x = web_contents->GetView()->GetContainerSize().width() / 2; |
176 int y = web_contents->GetView()->GetContainerSize().height() / 2; | 185 int y = web_contents->GetView()->GetContainerSize().height() / 2; |
177 WebKit::WebMouseEvent mouse_event; | 186 WebKit::WebMouseEvent mouse_event; |
178 mouse_event.type = WebKit::WebInputEvent::MouseDown; | 187 mouse_event.type = WebKit::WebInputEvent::MouseDown; |
179 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; | 188 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; |
180 mouse_event.x = x; | 189 mouse_event.x = x; |
181 mouse_event.y = y; | 190 mouse_event.y = y; |
182 // Mac needs globalX/globalY for events to plugins. | 191 // Mac needs globalX/globalY for events to plugins. |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 base::LaunchProcess(*cmd_line.get(), options, NULL); | 488 base::LaunchProcess(*cmd_line.get(), options, NULL); |
480 | 489 |
481 #if defined(OS_POSIX) | 490 #if defined(OS_POSIX) |
482 // Just to make sure that the server process terminates certainly. | 491 // Just to make sure that the server process terminates certainly. |
483 if (process_group_id_ != base::kNullProcessHandle) | 492 if (process_group_id_ != base::kNullProcessHandle) |
484 base::KillProcessGroup(process_group_id_); | 493 base::KillProcessGroup(process_group_id_); |
485 #endif | 494 #endif |
486 } | 495 } |
487 | 496 |
488 } // namespace content | 497 } // namespace content |
OLD | NEW |