FBForceTouchTests.m 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 <XCTest/XCTest.h>
  10. #import "FBIntegrationTestCase.h"
  11. #import "FBMacros.h"
  12. #import "FBElementCache.h"
  13. #import "FBTestMacros.h"
  14. #import "XCUIDevice.h"
  15. #import "XCUIDevice+FBRotation.h"
  16. #import "XCUIElement+FBForceTouch.h"
  17. #import "XCUIElement+FBIsVisible.h"
  18. @interface FBForceTouchTests : FBIntegrationTestCase
  19. @end
  20. // It is recommnded to verify these tests with different iOS versions
  21. @implementation FBForceTouchTests
  22. - (void)verifyForceTapWithOrientation:(UIDeviceOrientation)orientation
  23. {
  24. [[XCUIDevice sharedDevice] fb_setDeviceInterfaceOrientation:orientation];
  25. NSError *error;
  26. XCTAssertTrue(self.testedApplication.alerts.count == 0);
  27. [self.testedApplication.buttons[FBShowAlertForceTouchButtonName] fb_forceTouchCoordinate:nil
  28. pressure:nil
  29. duration:nil
  30. error:&error];
  31. FBAssertWaitTillBecomesTrue(self.testedApplication.alerts.count > 0);
  32. }
  33. - (void)setUp
  34. {
  35. [super setUp];
  36. static dispatch_once_t onceToken;
  37. dispatch_once(&onceToken, ^{
  38. [self launchApplication];
  39. [self goToAlertsPage];
  40. });
  41. [self clearAlert];
  42. }
  43. - (void)tearDown
  44. {
  45. [self clearAlert];
  46. [self resetOrientation];
  47. [super tearDown];
  48. }
  49. - (void)testForceTap
  50. {
  51. if (![XCUIDevice sharedDevice].supportsPressureInteraction) {
  52. return;
  53. }
  54. [self verifyForceTapWithOrientation:UIDeviceOrientationPortrait];
  55. }
  56. - (void)testForceTapInLandscapeLeft
  57. {
  58. if (![XCUIDevice sharedDevice].supportsPressureInteraction) {
  59. return;
  60. }
  61. [self verifyForceTapWithOrientation:UIDeviceOrientationLandscapeLeft];
  62. }
  63. - (void)testForceTapInLandscapeRight
  64. {
  65. if (![XCUIDevice sharedDevice].supportsPressureInteraction) {
  66. return;
  67. }
  68. [self verifyForceTapWithOrientation:UIDeviceOrientationLandscapeRight];
  69. }
  70. @end