FIRMessagingFakeConnection.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "Firebase/Messaging/FIRMessagingConnection.h"
  17. /**
  18. * A bunch of different fake connections are used to simulate various connection behaviours.
  19. * A fake connection that successfully conects to remote host.
  20. */
  21. // TODO: Split FIRMessagingConnection to make it more testable.
  22. @interface FIRMessagingFakeConnection : FIRMessagingConnection
  23. @property(nonatomic, readwrite, assign) BOOL shouldFakeSuccessLogin;
  24. // timeout caused by heartbeat failure (defaults to 0.5s)
  25. @property(nonatomic, readwrite, assign) NSTimeInterval fakeConnectionTimeout;
  26. /**
  27. * Should stub the socket disconnect to not fail when called
  28. */
  29. - (void)mockSocketDisconnect;
  30. /**
  31. * Calls disconnect on the socket(which should theoretically be mocked by the above method) and
  32. * let the socket delegate know that it has been disconnected.
  33. */
  34. - (void)disconnectNow;
  35. /**
  36. * The fake host to connect to.
  37. */
  38. + (NSString *)fakeHost;
  39. /**
  40. * The fake port used to connect.
  41. */
  42. + (int)fakePort;
  43. @end
  44. /**
  45. * A fake connection that simulates failure a certain number of times before success.
  46. */
  47. // TODO: Coalesce this with the FIRMessagingFakeConnection itself.
  48. @interface FIRMessagingFakeFailConnection : FIRMessagingFakeConnection
  49. @property(nonatomic, readwrite, assign) int failCount;
  50. @property(nonatomic, readwrite, assign) int signInRequests;
  51. @end