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

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: 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 16 matching lines...) Expand all
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"
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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
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( 210 WindowedNotificationObserver load_stop_observer(
207 NOTIFICATION_LOAD_STOP, 211 NOTIFICATION_LOAD_STOP,
208 Source<NavigationController>(&web_contents->GetController())); 212 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 load_stop_observer.Wait();
213 load_stop_observer.Wait(); 217 WaitForResizeComplete(web_contents);
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 void WaitForResizeComplete(WebContents* web_contents) {
229 LOG(ERROR) << "WaitForResizeToComplete";
230 LOG(ERROR) << "web_contents=" << web_contents;
231 aura::Window* content = web_contents->GetContentNativeView();
232 LOG(ERROR) << 1;
233 LOG(ERROR) << "content=" << content;
234 if (content) {
235 aura::WindowTreeHost* host = content->GetHost();
236 LOG(ERROR) << 2;
237 aura::WindowEventDispatcher* dispatcher = host->dispatcher();
238 LOG(ERROR) << 3;
239 while (dispatcher->HoldingPointerMovesForTest()) {
240 LOG(ERROR) << "HoldingPointerMovesForTest";
241 ui::DrawWaiterForTest::WaitForCommit(host->compositor());
242 LOG(ERROR) << "WaitForCommit done";
243 LOG(ERROR) << "dispatcher->HoldingPointerMovesForTest()="
244 << dispatcher->HoldingPointerMovesForTest();
245 }
246 }
247 }
248
sadrul 2014/06/12 23:25:51 Could this work with RenderWidgetHostImpl::resize_
mfomitchev 2014/06/13 15:20:57 Done.
224 void SimulateMouseClick(WebContents* web_contents, 249 void SimulateMouseClick(WebContents* web_contents,
225 int modifiers, 250 int modifiers,
226 blink::WebMouseEvent::Button button) { 251 blink::WebMouseEvent::Button button) {
227 int x = web_contents->GetContainerBounds().width() / 2; 252 int x = web_contents->GetContainerBounds().width() / 2;
228 int y = web_contents->GetContainerBounds().height() / 2; 253 int y = web_contents->GetContainerBounds().height() / 2;
229 SimulateMouseClickAt(web_contents, modifiers, button, gfx::Point(x, y)); 254 SimulateMouseClickAt(web_contents, modifiers, button, gfx::Point(x, y));
230 } 255 }
231 256
232 void SimulateMouseClickAt(WebContents* web_contents, 257 void SimulateMouseClickAt(WebContents* web_contents,
233 int modifiers, 258 int modifiers,
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
693 } 718 }
694 // The queue should not be empty, unless we were quit because of a timeout. 719 // The queue should not be empty, unless we were quit because of a timeout.
695 if (message_queue_.empty()) 720 if (message_queue_.empty())
696 return false; 721 return false;
697 *message = message_queue_.front(); 722 *message = message_queue_.front();
698 message_queue_.pop(); 723 message_queue_.pop();
699 return true; 724 return true;
700 } 725 }
701 726
702 } // namespace content 727 } // namespace content
OLDNEW
« no previous file with comments | « content/public/test/browser_test_utils.h ('k') | content/public/test/test_navigation_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698