OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 #ifndef BASE_TEST_IOS_WAIT_UTIL_H_ |
| 6 #define BASE_TEST_IOS_WAIT_UTIL_H_ |
| 7 |
| 8 #include "base/ios/block_types.h" |
| 9 #include "base/time/time.h" |
| 10 |
| 11 namespace base { |
| 12 |
| 13 class MessageLoop; |
| 14 |
| 15 namespace test { |
| 16 namespace ios { |
| 17 |
| 18 // Returns the time spent in running |action| plus waiting until |condition| is |
| 19 // met. |
| 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, |
| 31 TimeDelta timeout); |
| 32 |
| 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 |
| 35 // used. |
| 36 void WaitUntilCondition(ConditionBlock condition, |
| 37 MessageLoop* message_loop, |
| 38 TimeDelta timeout); |
| 39 void WaitUntilCondition(ConditionBlock condition); |
| 40 |
| 41 // Lets the run loop of the current thread process other messages |
| 42 // within the given maximum delay. |
| 43 void SpinRunLoopWithMaxDelay(TimeDelta max_delay); |
| 44 |
| 45 } // namespace ios |
| 46 } // namespace test |
| 47 } // namespace base |
| 48 |
| 49 #endif // BASE_TEST_IOS_WAIT_UTIL_H_ |
OLD | NEW |