Chromium Code Reviews| Index: content/public/test/browser_test_utils.cc |
| diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc |
| index 5beaa363675cf20374b662621f684746ce971859..a738d3876c5d00e78db6860e84ac89306f4e3023 100644 |
| --- a/content/public/test/browser_test_utils.cc |
| +++ b/content/public/test/browser_test_utils.cc |
| @@ -34,7 +34,11 @@ |
| #include "net/url_request/url_request_context.h" |
| #include "net/url_request/url_request_context_getter.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| +#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.
|
| +#include "ui/aura/window_event_dispatcher.h" |
| +#include "ui/aura/window_tree_host.h" |
| #include "ui/base/resource/resource_bundle.h" |
| +#include "ui/compositor/test/draw_waiter_for_test.h" |
| #include "ui/events/gestures/gesture_configuration.h" |
| #include "ui/events/keycodes/dom4/keycode_converter.h" |
| @@ -203,14 +207,14 @@ GURL GetFileUrlWithQuery(const base::FilePath& path, |
| } |
| void WaitForLoadStop(WebContents* web_contents) { |
| - WindowedNotificationObserver load_stop_observer( |
| - NOTIFICATION_LOAD_STOP, |
| - Source<NavigationController>(&web_contents->GetController())); |
| // In many cases, the load may have finished before we get here. Only wait if |
| // the tab still has a pending navigation. |
| - if (!web_contents->IsLoading()) |
| - return; |
| - load_stop_observer.Wait(); |
| + if (web_contents->IsLoading()) { |
| + WindowedNotificationObserver load_stop_observer( |
| + NOTIFICATION_LOAD_STOP, |
| + Source<NavigationController>(&web_contents->GetController())); |
| + load_stop_observer.Wait(); |
| + } |
| } |
| void CrashTab(WebContents* web_contents) { |
| @@ -221,6 +225,28 @@ void CrashTab(WebContents* web_contents) { |
| watcher.Wait(); |
| } |
| +bool IsResizeComplete(aura::WindowEventDispatcher* dispatcher, |
| + RenderWidgetHostImpl* widget_host) { |
| + return !dispatcher->HoldingPointerMovesForTesting() && |
| + !widget_host->IsResizeAckPendingForTesting(); |
| +} |
| + |
| +void WaitForResizeComplete(WebContents* web_contents) { |
| + aura::Window* content = web_contents->GetContentNativeView(); |
| + if (content) { |
| + aura::WindowTreeHost* window_host = content->GetHost(); |
| + aura::WindowEventDispatcher* dispatcher = window_host->dispatcher(); |
| + RenderWidgetHostImpl* widget_host = |
| + RenderWidgetHostImpl::From(web_contents->GetRenderViewHost()); |
| + if (!IsResizeComplete(dispatcher, widget_host)) { |
| + WindowedNotificationObserver resize_observer( |
| + NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE, |
| + base::Bind(IsResizeComplete, dispatcher, widget_host)); |
| + resize_observer.Wait(); |
| + } |
| + } |
| +} |
| + |
| void SimulateMouseClick(WebContents* web_contents, |
| int modifiers, |
| blink::WebMouseEvent::Button button) { |