Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1141)

Unified Diff: content/public/test/browser_test_utils.cc

Issue 330113002: Fixing flaky overscroll and touch exploration mode browser tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8c050ac9c9e25e2f15b3e8d6a2392e85b26c4cf3 100644
--- a/content/public/test/browser_test_utils.cc
+++ b/content/public/test/browser_test_utils.cc
@@ -34,7 +34,9 @@
#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"
#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 +205,22 @@ 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();
+ }
+ // If this is the very first navigation, the RenderView for WebContents
+ // will be created as a result. The creation involves sending a resize
+ // message to the renderer process. Here we wait for the resize ack to be
+ // received, since tests may not expect to end up in a "waiting for resize"
+ // state after the first navigation.
+ // E.g. currently WindowEventDispatcher has code to hold touch and mouse
+ // move events until resize is complete (crbug.com/384342)
+ WaitForResizeComplete(web_contents);
mfomitchev 2014/06/13 15:56:21 I wonder if we should make it so that this is done
}
void CrashTab(WebContents* web_contents) {
@@ -221,6 +231,24 @@ void CrashTab(WebContents* web_contents) {
watcher.Wait();
}
+bool IsResizeComplete(RenderWidgetHostImpl* widget_host) {
+ return !widget_host->IsResizeAckPendingForTesting();
+}
+
+void WaitForResizeComplete(WebContents* web_contents) {
+ aura::Window* content = web_contents->GetContentNativeView();
+ if (content) {
+ RenderWidgetHostImpl* widget_host =
+ RenderWidgetHostImpl::From(web_contents->GetRenderViewHost());
+ if (!IsResizeComplete(widget_host)) {
+ WindowedNotificationObserver resize_observer(
+ NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE,
+ base::Bind(IsResizeComplete, widget_host));
+ resize_observer.Wait();
+ }
+ }
+}
+
void SimulateMouseClick(WebContents* web_contents,
int modifiers,
blink::WebMouseEvent::Button button) {

Powered by Google App Engine
This is Rietveld 408576698