Chromium Code Reviews| Index: base/test/ios/wait_util.h |
| diff --git a/base/test/ios/wait_util.h b/base/test/ios/wait_util.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c96e50d55e1e297acd1154c4ec89e0ff283302b4 |
| --- /dev/null |
| +++ b/base/test/ios/wait_util.h |
| @@ -0,0 +1,50 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
|
Paweł Hajdan Jr.
2015/01/30 12:24:29
nit: 2015
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef BASE_TEST_IOS_WAIT_UTIL_H_ |
| +#define BASE_TEST_IOS_WAIT_UTIL_H_ |
| + |
| +#import <Foundation/Foundation.h> |
| + |
| +#include "base/ios/block_types.h" |
| +#include "base/time/time.h" |
| + |
| +namespace base { |
| + |
| +class MessageLoop; |
| + |
| +// Returns the time spent in running |action| plus waiting until |condition| is |
| +// met. |
| +// Performs |action| and then spins run loop and runs the |message_loop| until |
| +// |condition| block returns true. |
| +// |action| may be nil if no action needs to be performed before the wait loop. |
| +// |message_loop| can be null if there is no need to spin the message loop. |
| +// |condition| may be nil if there is no condition to wait for: the run loop |
| +// will spin until timeout is reached. |
| +// |timeout| parameter sets the maximum wait time. If |timeout| is not provided, |
| +// a reasonable default will be used. |
| +TimeDelta TimeUntilCondition(ProceduralBlock action, |
| + ConditionBlock condition, |
| + MessageLoop* message_loop, |
| + TimeDelta timeout); |
| +TimeDelta TimeUntilCondition(ProceduralBlock action, ConditionBlock condition); |
| + |
| +// Waits until |condition| is met. A |message_loop| to spin and a |timeout| can |
| +// be optionnally passed. |
| +void WaitUntilCondition(ConditionBlock condition, |
| + MessageLoop* message_loop, |
| + TimeDelta timeout); |
| +void WaitUntilCondition(ConditionBlock condition, MessageLoop* message_loop); |
| +void WaitUntilCondition(ConditionBlock condition); |
| + |
| +// Spins the run loop for |timeout|. |
| +void Wait(TimeDelta timeout); |
| + |
| +// Lets the run loop of the current thread process other messages |
| +// within the given maximum delay. |
| +void SpinRunLoopWithMaxDelay(TimeDelta max_delay); |
| + |
| +} // namespace base |
| + |
| +#endif // BASE_TEST_IOS_WAIT_UTIL_H_ |