FBTestMacros.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. /**
  2. * Copyright (c) 2015-present, Facebook, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. */
  9. #import <WebDriverAgentLib/FBRunLoopSpinner.h>
  10. /**
  11. Macro used to wait till certain condition is true.
  12. If condition will not become true within default timeout (1m) it will fail running test
  13. */
  14. #define FBAssertWaitTillBecomesTrue(condition) \
  15. ({ \
  16. NSError *__error; \
  17. XCTAssertTrue([[[FBRunLoopSpinner new] \
  18. interval:1.0] \
  19. spinUntilTrue:^BOOL{ \
  20. return (condition); \
  21. }]); \
  22. XCTAssertNil(__error); \
  23. })
  24. #define FBWaitExact(timeoutSeconds) \
  25. ({ \
  26. [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:(timeoutSeconds)]]; \
  27. })
  28. #define FBCellElementWithLabel(label) ([self.testedApplication descendantsMatchingType:XCUIElementTypeAny][label])
  29. #define FBAssertVisibleCell(label) FBAssertWaitTillBecomesTrue(FBCellElementWithLabel(label).fb_isVisible)
  30. #define FBAssertInvisibleCell(label) FBAssertWaitTillBecomesTrue(!FBCellElementWithLabel(label).fb_isVisible)