1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef BASE_TEST_IOS_WAIT_UTIL_H_
6 #define BASE_TEST_IOS_WAIT_UTIL_H_
8 #include "base/ios/block_types.h"
9 #include "base/time/time.h"
18 // Returns the time spent in running |action| plus waiting until |condition| is
20 // Performs |action| and then spins run loop and runs the |message_loop| until
21 // |condition| block returns true.
22 // |action| may be nil if no action needs to be performed before the wait loop.
23 // |message_loop| can be null if there is no need to spin the message loop.
24 // |condition| may be nil if there is no condition to wait for: the run loop
25 // will spin until timeout is reached.
26 // |timeout| parameter sets the maximum wait time. If |timeout| is zero,
27 // a reasonable default will be used.
28 TimeDelta
TimeUntilCondition(ProceduralBlock action
,
29 ConditionBlock condition
,
30 MessageLoop
* message_loop
,
33 // Waits until |condition| is met. A |message_loop| to spin and a |timeout| can
34 // be optionally passed; if |timeout| is zero, a reasonable default will be
36 void WaitUntilCondition(ConditionBlock condition
,
37 MessageLoop
* message_loop
,
39 void WaitUntilCondition(ConditionBlock condition
);
41 // Lets the run loop of the current thread process other messages
42 // within the given maximum delay.
43 void SpinRunLoopWithMaxDelay(TimeDelta max_delay
);
49 #endif // BASE_TEST_IOS_WAIT_UTIL_H_