FBKeyboardTests.m 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 "FBMacros.h"
  11. #import "FBIntegrationTestCase.h"
  12. #import "FBKeyboard.h"
  13. #import "FBRunLoopSpinner.h"
  14. #import "XCUIApplication+FBHelpers.h"
  15. @interface FBKeyboardTests : FBIntegrationTestCase
  16. @end
  17. @implementation FBKeyboardTests
  18. - (void)setUp
  19. {
  20. [super setUp];
  21. [self launchApplication];
  22. [self goToAttributesPage];
  23. }
  24. - (void)testKeyboardDismissal
  25. {
  26. XCUIElement *textField = self.testedApplication.textFields[@"aIdentifier"];
  27. [textField tap];
  28. if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"15.0")) {
  29. // A workaround until find out to clear tutorial on iOS 15
  30. XCUIElement *textField = self.testedApplication.staticTexts[@"Continue"];
  31. if (textField.hittable) {
  32. [textField tap];
  33. }
  34. }
  35. NSError *error;
  36. XCTAssertTrue([FBKeyboard waitUntilVisibleForApplication:self.testedApplication timeout:1 error:&error]);
  37. XCTAssertNil(error);
  38. if ([UIDevice.currentDevice userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
  39. XCTAssertTrue([self.testedApplication fb_dismissKeyboardWithKeyNames:nil error:&error]);
  40. XCTAssertNil(error);
  41. } else {
  42. XCTAssertFalse([self.testedApplication fb_dismissKeyboardWithKeyNames:@[@"return"] error:&error]);
  43. XCTAssertNotNil(error);
  44. }
  45. }
  46. - (void)testKeyboardPresenceVerification
  47. {
  48. NSError *error;
  49. XCTAssertFalse([FBKeyboard waitUntilVisibleForApplication:self.testedApplication timeout:1 error:&error]);
  50. XCTAssertNotNil(error);
  51. }
  52. @end