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

Side by Side 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: Forgot to update .h 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 unified diff | Download patch
OLDNEW
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 17 matching lines...) Expand all
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/base/resource/resource_bundle.h" 37 #include "ui/base/resource/resource_bundle.h"
38 #include "ui/compositor/test/draw_waiter_for_test.h"
38 #include "ui/events/gestures/gesture_configuration.h" 39 #include "ui/events/gestures/gesture_configuration.h"
39 #include "ui/events/keycodes/dom4/keycode_converter.h" 40 #include "ui/events/keycodes/dom4/keycode_converter.h"
40 41
42 #if defined(USE_AURA)
43 #include "ui/aura/window.h"
44 #include "ui/aura/window_event_dispatcher.h"
45 #include "ui/aura/window_tree_host.h"
46 #endif // USE_AURA
47
41 namespace content { 48 namespace content {
42 namespace { 49 namespace {
43 50
44 class DOMOperationObserver : public NotificationObserver, 51 class DOMOperationObserver : public NotificationObserver,
45 public WebContentsObserver { 52 public WebContentsObserver {
46 public: 53 public:
47 explicit DOMOperationObserver(RenderViewHost* rvh) 54 explicit DOMOperationObserver(RenderViewHost* rvh)
48 : WebContentsObserver(WebContents::FromRenderViewHost(rvh)), 55 : WebContentsObserver(WebContents::FromRenderViewHost(rvh)),
49 did_respond_(false) { 56 did_respond_(false) {
50 registrar_.Add(this, NOTIFICATION_DOM_OPERATION_RESPONSE, 57 registrar_.Add(this, NOTIFICATION_DOM_OPERATION_RESPONSE,
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 GURL url = net::FilePathToFileURL(path); 203 GURL url = net::FilePathToFileURL(path);
197 if (!query_string.empty()) { 204 if (!query_string.empty()) {
198 GURL::Replacements replacements; 205 GURL::Replacements replacements;
199 replacements.SetQueryStr(query_string); 206 replacements.SetQueryStr(query_string);
200 return url.ReplaceComponents(replacements); 207 return url.ReplaceComponents(replacements);
201 } 208 }
202 return url; 209 return url;
203 } 210 }
204 211
205 void WaitForLoadStop(WebContents* web_contents) { 212 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 213 // In many cases, the load may have finished before we get here. Only wait if
210 // the tab still has a pending navigation. 214 // the tab still has a pending navigation.
211 if (!web_contents->IsLoading()) 215 if (web_contents->IsLoading()) {
212 return; 216 WindowedNotificationObserver load_stop_observer(
213 load_stop_observer.Wait(); 217 NOTIFICATION_LOAD_STOP,
218 Source<NavigationController>(&web_contents->GetController()));
219 load_stop_observer.Wait();
220 }
214 } 221 }
215 222
216 void CrashTab(WebContents* web_contents) { 223 void CrashTab(WebContents* web_contents) {
217 RenderProcessHost* rph = web_contents->GetRenderProcessHost(); 224 RenderProcessHost* rph = web_contents->GetRenderProcessHost();
218 RenderProcessHostWatcher watcher( 225 RenderProcessHostWatcher watcher(
219 rph, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT); 226 rph, RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT);
220 base::KillProcess(rph->GetHandle(), 0, false); 227 base::KillProcess(rph->GetHandle(), 0, false);
221 watcher.Wait(); 228 watcher.Wait();
222 } 229 }
223 230
231 #if defined(USE_AURA)
232 bool IsResizeComplete(aura::WindowEventDispatcher* dispatcher,
233 RenderWidgetHostImpl* widget_host) {
234 return !dispatcher->HoldingPointerMovesForTesting() &&
235 !widget_host->resize_ack_pending_for_testing();
236 }
237
238 void WaitForResizeComplete(WebContents* web_contents) {
239 aura::Window* content = web_contents->GetContentNativeView();
240 if (content) {
jam 2014/06/23 07:12:05 nit: in general, early return if possible to reduc
mfomitchev 2014/06/24 19:54:25 Done.
241 aura::WindowTreeHost* window_host = content->GetHost();
242 aura::WindowEventDispatcher* dispatcher = window_host->dispatcher();
243 RenderWidgetHostImpl* widget_host =
244 RenderWidgetHostImpl::From(web_contents->GetRenderViewHost());
245 if (!IsResizeComplete(dispatcher, widget_host)) {
246 WindowedNotificationObserver resize_observer(
247 NOTIFICATION_RENDER_WIDGET_HOST_DID_UPDATE_BACKING_STORE,
248 base::Bind(IsResizeComplete, dispatcher, widget_host));
249 resize_observer.Wait();
250 }
251 }
252 }
253 #endif // USE_AURA
254
224 void SimulateMouseClick(WebContents* web_contents, 255 void SimulateMouseClick(WebContents* web_contents,
225 int modifiers, 256 int modifiers,
226 blink::WebMouseEvent::Button button) { 257 blink::WebMouseEvent::Button button) {
227 int x = web_contents->GetContainerBounds().width() / 2; 258 int x = web_contents->GetContainerBounds().width() / 2;
228 int y = web_contents->GetContainerBounds().height() / 2; 259 int y = web_contents->GetContainerBounds().height() / 2;
229 SimulateMouseClickAt(web_contents, modifiers, button, gfx::Point(x, y)); 260 SimulateMouseClickAt(web_contents, modifiers, button, gfx::Point(x, y));
230 } 261 }
231 262
232 void SimulateMouseClickAt(WebContents* web_contents, 263 void SimulateMouseClickAt(WebContents* web_contents,
233 int modifiers, 264 int modifiers,
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 } 724 }
694 // The queue should not be empty, unless we were quit because of a timeout. 725 // The queue should not be empty, unless we were quit because of a timeout.
695 if (message_queue_.empty()) 726 if (message_queue_.empty())
696 return false; 727 return false;
697 *message = message_queue_.front(); 728 *message = message_queue_.front();
698 message_queue_.pop(); 729 message_queue_.pop();
699 return true; 730 return true;
700 } 731 }
701 732
702 } // namespace content 733 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698