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

Side by Side Diff: content/test/test_navigation_observer.cc

Issue 10479018: Add base::RunLoop and update ui_test_utils to use it to reduce flakiness (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: added printfs to debug timeout which doesn't happen locally Created 8 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 | Annotate | Revision Log
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/test_navigation_observer.h" 5 #include "content/public/test/test_navigation_observer.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "content/public/browser/notification_service.h" 9 #include "content/public/browser/notification_service.h"
10 #include "content/public/browser/notification_types.h" 10 #include "content/public/browser/notification_types.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 return; 77 return;
78 78
79 EXPECT_FALSE(running_); 79 EXPECT_FALSE(running_);
80 running_ = true; 80 running_ = true;
81 done_callback_ = done_callback; 81 done_callback_ = done_callback;
82 wait_loop_callback.Run(); 82 wait_loop_callback.Run();
83 EXPECT_TRUE(done_); 83 EXPECT_TRUE(done_);
84 } 84 }
85 85
86 void TestNavigationObserver::Wait() { 86 void TestNavigationObserver::Wait() {
87 int message_loop_run_id = MessageLoop::current()->next_run_id();
jar (doing other things) 2012/06/14 04:50:29 re: discussion of changing API from next_run_id().
jbates 2012/06/15 02:20:38 Done.
87 WaitForObservation( 88 WaitForObservation(
88 base::Bind(&MessageLoop::Run, 89 base::Bind(&MessageLoop::Run,
89 base::Unretained(MessageLoop::current())), 90 base::Unretained(MessageLoop::current())),
90 base::Bind(&MessageLoop::Quit, 91 base::Bind(&MessageLoop::PostTask,
91 base::Unretained(MessageLoop::current()))); 92 base::Unretained(MessageLoop::current()),
93 FROM_HERE,
94 MessageLoop::QuitNowByIDClosure(message_loop_run_id)));
92 } 95 }
93 96
94 TestNavigationObserver::TestNavigationObserver( 97 TestNavigationObserver::TestNavigationObserver(
95 JsInjectionReadyObserver* js_injection_ready_observer, 98 JsInjectionReadyObserver* js_injection_ready_observer,
96 int number_of_navigations) 99 int number_of_navigations)
97 : navigation_started_(false), 100 : navigation_started_(false),
98 navigations_completed_(0), 101 navigations_completed_(0),
99 number_of_navigations_(number_of_navigations), 102 number_of_navigations_(number_of_navigations),
100 js_injection_ready_observer_(js_injection_ready_observer), 103 js_injection_ready_observer_(js_injection_ready_observer),
101 done_(false), 104 done_(false),
(...skipping 22 matching lines...) Expand all
124 switch (type) { 127 switch (type) {
125 case NOTIFICATION_NAV_ENTRY_COMMITTED: 128 case NOTIFICATION_NAV_ENTRY_COMMITTED:
126 case NOTIFICATION_LOAD_START: 129 case NOTIFICATION_LOAD_START:
127 navigation_started_ = true; 130 navigation_started_ = true;
128 break; 131 break;
129 case NOTIFICATION_LOAD_STOP: 132 case NOTIFICATION_LOAD_STOP:
130 if (navigation_started_ && 133 if (navigation_started_ &&
131 ++navigations_completed_ == number_of_navigations_) { 134 ++navigations_completed_ == number_of_navigations_) {
132 navigation_started_ = false; 135 navigation_started_ = false;
133 done_ = true; 136 done_ = true;
134 if (running_) 137 if (running_) {
138 running_ = false;
135 done_callback_.Run(); 139 done_callback_.Run();
140 }
136 } 141 }
137 break; 142 break;
138 case NOTIFICATION_RENDER_VIEW_HOST_CREATED: 143 case NOTIFICATION_RENDER_VIEW_HOST_CREATED:
139 rvho_send_js_.reset(new RVHOSendJS( 144 rvho_send_js_.reset(new RVHOSendJS(
140 Source<RenderViewHost>(source).ptr(), 145 Source<RenderViewHost>(source).ptr(),
141 js_injection_ready_observer_)); 146 js_injection_ready_observer_));
142 break; 147 break;
143 default: 148 default:
144 NOTREACHED(); 149 NOTREACHED();
145 } 150 }
146 } 151 }
147 152
148 } // namespace content 153 } // namespace content
OLDNEW
« chrome/test/base/ui_test_utils.cc ('K') | « chrome/test/perf/rendering/throughput_tests.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698