Chromium Code Reviews| 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/kill.h" | 10 #include "base/process/kill.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
| 28 #include "content/public/browser/web_contents_observer.h" | 28 #include "content/public/browser/web_contents_observer.h" |
| 29 #include "content/public/test/test_utils.h" | 29 #include "content/public/test/test_utils.h" |
| 30 #include "grit/webui_resources.h" | 30 #include "grit/webui_resources.h" |
| 31 #include "net/base/filename_util.h" | 31 #include "net/base/filename_util.h" |
| 32 #include "net/cookies/cookie_store.h" | 32 #include "net/cookies/cookie_store.h" |
| 33 #include "net/test/python_utils.h" | 33 #include "net/test/python_utils.h" |
| 34 #include "net/url_request/url_request_context.h" | 34 #include "net/url_request/url_request_context.h" |
| 35 #include "net/url_request/url_request_context_getter.h" | 35 #include "net/url_request/url_request_context_getter.h" |
| 36 #include "testing/gtest/include/gtest/gtest.h" | 36 #include "testing/gtest/include/gtest/gtest.h" |
| 37 #include "ui/aura/window.h" | |
|
jam
2014/06/19 16:25:31
this isn't going to compile on platforms where we
mfomitchev
2014/06/19 20:04:56
Done. Good point.
| |
| 38 #include "ui/aura/window_event_dispatcher.h" | |
| 39 #include "ui/aura/window_tree_host.h" | |
| 37 #include "ui/base/resource/resource_bundle.h" | 40 #include "ui/base/resource/resource_bundle.h" |
| 41 #include "ui/compositor/test/draw_waiter_for_test.h" | |
| 38 #include "ui/events/gestures/gesture_configuration.h" | 42 #include "ui/events/gestures/gesture_configuration.h" |
| 39 #include "ui/events/keycodes/dom4/keycode_converter.h" | 43 #include "ui/events/keycodes/dom4/keycode_converter.h" |
| 40 | 44 |
| 41 namespace content { | 45 namespace content { |
| 42 namespace { | 46 namespace { |
| 43 | 47 |
| 44 class DOMOperationObserver : public NotificationObserver, | 48 class DOMOperationObserver : public NotificationObserver, |
| 45 public WebContentsObserver { | 49 public WebContentsObserver { |
| 46 public: | 50 public: |
| 47 explicit DOMOperationObserver(RenderViewHost* rvh) | 51 explicit DOMOperationObserver(RenderViewHost* rvh) |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 GURL url = net::FilePathToFileURL(path); | 200 GURL url = net::FilePathToFileURL(path); |
| 197 if (!query_string.empty()) { | 201 if (!query_string.empty()) { |
| 198 GURL::Replacements replacements; | 202 GURL::Replacements replacements; |
| 199 replacements.SetQueryStr(query_string); | 203 replacements.SetQueryStr(query_string); |
| 200 return url.ReplaceComponents(replacements); | 204 return url.ReplaceComponents(replacements); |
| 201 } | 205 } |
| 202 return url; | 206 return url; |
| 203 } | 207 } |
| 204 | 208 |
| 205 void WaitForLoadStop(WebContents* web_contents) { | 209 void WaitForLoadStop(WebContents* web_contents) { |
| 206 WindowedNotificationObserver load_stop_observer( | |
| 207 NOTIFICATION_LOAD_STOP, | |
| 208 Source<NavigationController>(&web_contents->GetController())); | |
| 209 // In many cases, the load may have finished before we get here. Only wait if | 210 // In many cases, the load may have finished before we get here. Only wait if |
| 210 // the tab still has a pending navigation. | 211 // the tab still has a pending navigation. |
| 211 if (!web_contents->IsLoading()) | 212 if (web_contents->IsLoading()) { |
| 212 return; | 213 WindowedNotificationObserver load_stop_observer( |
| 213 load_stop_observer.Wait(); | 214 NOTIFICATION_LOAD_STOP, |
| 215 Source<NavigationController>(&web_contents->GetController())); | |
| 216 load_stop_observer.Wait(); | |
| 217 } | |
| 214 } | 218 } |
| 215 | 219 |
| 216 void CrashTab(WebContents* web_contents) { | 220 void CrashTab(WebContents* web_contents) { |
| 217 RenderProcessHost* rph = web_contents->GetRenderProcessHost(); | 221 RenderProcessHost* rph = web_contents->GetRenderProcessHost(); |
| 218 RenderProcessHostWatcher watcher( | 222 RenderProcessHostWatcher watcher( |
| 219 rph, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); | 223 rph, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); |
| 220 base::KillProcess(rph->GetHandle(), 0, false); | 224 base::KillProcess(rph->GetHandle(), 0, false); |
| 221 watcher.Wait(); | 225 watcher.Wait(); |
| 222 } | 226 } |
| 223 | 227 |
| 228 bool IsResizeComplete(aura::WindowEventDispatcher* dispatcher, | |
| 229 RenderWidgetHostImpl* widget_host) { | |
| 230 return !dispatcher->HoldingPointerMovesForTesting() && | |
| 231 !widget_host->IsResizeAckPendingForTesting(); | |
| 232 } | |
| 233 | |
| 234 void WaitForResizeComplete(WebContents* web_contents) { | |
| 235 aura::Window* content = web_contents->GetContentNativeView(); | |
| 236 if (content) { | |
| 237 aura::WindowTreeHost* window_host = content->GetHost(); | |
| 238 aura::WindowEventDispatcher* dispatcher = window_host->dispatcher(); | |
| 239 RenderWidgetHostImpl* widget_host = | |
| 240 RenderWidgetHostImpl::From(web_contents->GetRenderViewHost()); | |
| 241 if (!IsResizeComplete(dispatcher, widget_host)) { | |
| 242 WindowedNotificationObserver resize_observer( | |
| 243 NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE, | |
| 244 base::Bind(IsResizeComplete, dispatcher, widget_host)); | |
| 245 resize_observer.Wait(); | |
| 246 } | |
| 247 } | |
| 248 } | |
| 249 | |
| 224 void SimulateMouseClick(WebContents* web_contents, | 250 void SimulateMouseClick(WebContents* web_contents, |
| 225 int modifiers, | 251 int modifiers, |
| 226 blink::WebMouseEvent::Button button) { | 252 blink::WebMouseEvent::Button button) { |
| 227 int x = web_contents->GetContainerBounds().width() / 2; | 253 int x = web_contents->GetContainerBounds().width() / 2; |
| 228 int y = web_contents->GetContainerBounds().height() / 2; | 254 int y = web_contents->GetContainerBounds().height() / 2; |
| 229 SimulateMouseClickAt(web_contents, modifiers, button, gfx::Point(x, y)); | 255 SimulateMouseClickAt(web_contents, modifiers, button, gfx::Point(x, y)); |
| 230 } | 256 } |
| 231 | 257 |
| 232 void SimulateMouseClickAt(WebContents* web_contents, | 258 void SimulateMouseClickAt(WebContents* web_contents, |
| 233 int modifiers, | 259 int modifiers, |
| (...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 693 } | 719 } |
| 694 // The queue should not be empty, unless we were quit because of a timeout. | 720 // The queue should not be empty, unless we were quit because of a timeout. |
| 695 if (message_queue_.empty()) | 721 if (message_queue_.empty()) |
| 696 return false; | 722 return false; |
| 697 *message = message_queue_.front(); | 723 *message = message_queue_.front(); |
| 698 message_queue_.pop(); | 724 message_queue_.pop(); |
| 699 return true; | 725 return true; |
| 700 } | 726 } |
| 701 | 727 |
| 702 } // namespace content | 728 } // namespace content |
| OLD | NEW |