NSPredicate+FBFormat.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 <Foundation/Foundation.h>
  10. NS_ASSUME_NONNULL_BEGIN
  11. @interface NSPredicate (FBFormat)
  12. /**
  13. Method used to normalize/verify NSPredicate expressions before passing them to WDA.
  14. Only expressions of NSKeyPathExpressionType are going to be verified.
  15. Allowed property names are only these declared in FBElement protocol (property names are received in runtime)
  16. and their shortcuts (without 'wd' prefix). All other property names are considered as unknown.
  17. @param input predicate object received from user input
  18. @return formatted predicate
  19. @throw FBUnknownPredicateKeyException in case the given property name is not declared in FBElement protocol
  20. */
  21. + (instancetype)fb_formatSearchPredicate:(NSPredicate *)input;
  22. /**
  23. Creates a block predicate expression, which properly evalluates the given raw predicate agains
  24. xctest hierarchy. Vanilla string predicates don't work on this hierachy because "raw" snapshots
  25. don't have any of the custom properties declared in FBElement protocol.
  26. `fb_formatSearchPredicate` is called automtically on the original predicate before
  27. making it to a block.
  28. @param input predicate object received from user input
  29. @return formatted predicate
  30. @throw FBUnknownPredicateKeyException in case the given property name is not declared in FBElement protocol
  31. */
  32. + (instancetype)fb_snapshotBlockPredicateWithPredicate:(NSPredicate *)input;
  33. @end
  34. NS_ASSUME_NONNULL_END