FBElementVisibilityTests.m 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 "FBTestMacros.h"
  13. #import "FBXCodeCompatibility.h"
  14. #import "XCUIElement+FBIsVisible.h"
  15. @interface FBElementVisibilityTests : FBIntegrationTestCase
  16. @end
  17. @implementation FBElementVisibilityTests
  18. - (void)testSpringBoardIcons
  19. {
  20. if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
  21. return;
  22. }
  23. [self launchApplication];
  24. [self goToSpringBoardFirstPage];
  25. // Check Icons on first screen
  26. // Note: Calender app exits 2 (an app icon + a widget) exist on the home screen
  27. // on iOS 15+. The firstMatch is for it.
  28. XCTAssertTrue(self.springboard.icons[@"Calendar"].firstMatch.fb_isVisible);
  29. XCTAssertTrue(self.springboard.icons[@"Reminders"].fb_isVisible);
  30. // Check Icons on second screen screen
  31. XCTAssertFalse(self.springboard.icons[@"IntegrationApp"].firstMatch.fb_isVisible);
  32. }
  33. - (void)testSpringBoardSubfolder
  34. {
  35. if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad
  36. || SYSTEM_VERSION_GREATER_THAN(@"12.0")) {
  37. return;
  38. }
  39. [self launchApplication];
  40. [self goToSpringBoardExtras];
  41. XCTAssertFalse(self.springboard.icons[@"Extras"].otherElements[@"Contacts"].fb_isVisible);
  42. }
  43. - (void)disabled_testIconsFromSearchDashboard
  44. {
  45. // This test causes:
  46. // Failure fetching attributes for element <XCAccessibilityElement: 0x60800044dd10> Device element: Error Domain=XCTDaemonErrorDomain Code=13 "Value for attribute 5017 is an error." UserInfo={NSLocalizedDescription=Value for attribute 5017 is an error.}
  47. [self launchApplication];
  48. [self goToSpringBoardDashboard];
  49. XCTAssertFalse(self.springboard.icons[@"Reminders"].fb_isVisible);
  50. XCTAssertFalse([[[self.springboard descendantsMatchingType:XCUIElementTypeIcon]
  51. matchingIdentifier:@"IntegrationApp"]
  52. firstMatch].fb_isVisible);
  53. }
  54. - (void)testTableViewCells
  55. {
  56. [self launchApplication];
  57. [self goToScrollPageWithCells:YES];
  58. for (int i = 0 ; i < 10 ; i++) {
  59. FBAssertWaitTillBecomesTrue(self.testedApplication.cells.allElementsBoundByIndex[i].fb_isVisible);
  60. FBAssertWaitTillBecomesTrue(self.testedApplication.staticTexts.allElementsBoundByIndex[i].fb_isVisible);
  61. }
  62. }
  63. @end