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

Side by Side Diff: chrome/test/base/ui_test_utils.h

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: more test fixes 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 #ifndef CHROME_TEST_BASE_UI_TEST_UTILS_H_ 5 #ifndef CHROME_TEST_BASE_UI_TEST_UTILS_H_
6 #define CHROME_TEST_BASE_UI_TEST_UTILS_H_ 6 #define CHROME_TEST_BASE_UI_TEST_UTILS_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <queue> 10 #include <queue>
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 int state) WARN_UNUSED_RESULT; 307 int state) WARN_UNUSED_RESULT;
308 308
309 // Run a message loop only for the specified amount of time. 309 // Run a message loop only for the specified amount of time.
310 class TimedMessageLoopRunner { 310 class TimedMessageLoopRunner {
311 public: 311 public:
312 // Create new MessageLoopForUI and attach to it. 312 // Create new MessageLoopForUI and attach to it.
313 TimedMessageLoopRunner(); 313 TimedMessageLoopRunner();
314 314
315 // Attach to an existing message loop. 315 // Attach to an existing message loop.
316 explicit TimedMessageLoopRunner(MessageLoop* loop) 316 explicit TimedMessageLoopRunner(MessageLoop* loop)
317 : loop_(loop), owned_(false), quit_loop_invoked_(false) {} 317 : loop_(loop), owned_(false) {}
jar (doing other things) 2012/06/08 01:05:37 nit: one constructor init per line (even if the ol
jbates 2012/06/13 22:11:20 Done.
318 318
319 ~TimedMessageLoopRunner(); 319 ~TimedMessageLoopRunner();
320 320
321 // Run the message loop for ms milliseconds. 321 // Run the message loop for ms milliseconds.
322 void RunFor(int ms); 322 void RunFor(int ms);
323 323
324 // Post Quit task to the message loop.
325 void Quit();
326
327 // Post delayed Quit task to the message loop.
328 void QuitAfter(int ms);
329
330 bool WasTimedOut() const {
331 return !quit_loop_invoked_;
332 }
333
334 private: 324 private:
335 MessageLoop* loop_; 325 MessageLoop* loop_;
336 bool owned_; 326 bool owned_;
337 bool quit_loop_invoked_;
338 327
339 DISALLOW_COPY_AND_ASSIGN(TimedMessageLoopRunner); 328 DISALLOW_COPY_AND_ASSIGN(TimedMessageLoopRunner);
340 }; 329 };
341 330
342 // This is a utility class for running a python websocket server 331 // This is a utility class for running a python websocket server
343 // during tests. The server is started during the construction of the 332 // during tests. The server is started during the construction of the
344 // object, and is stopped when the destructor is called. Note that 333 // object, and is stopped when the destructor is called. Note that
345 // because of the underlying script that is used: 334 // because of the underlying script that is used:
346 // 335 //
347 // third_paty/WebKit/Tools/Scripts/new-run-webkit-websocketserver 336 // third_paty/WebKit/Tools/Scripts/new-run-webkit-websocketserver
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 // ui_controls_linux.cc and ui_controls_mac.cc 683 // ui_controls_linux.cc and ui_controls_mac.cc
695 void ClickTask(ui_controls::MouseButton button, 684 void ClickTask(ui_controls::MouseButton button,
696 int state, 685 int state,
697 const base::Closure& followup); 686 const base::Closure& followup);
698 687
699 } // namespace internal 688 } // namespace internal
700 689
701 } // namespace ui_test_utils 690 } // namespace ui_test_utils
702 691
703 #endif // CHROME_TEST_BASE_UI_TEST_UTILS_H_ 692 #endif // CHROME_TEST_BASE_UI_TEST_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698