FBScreen.m 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  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 "FBScreen.h"
  10. #import "FBApplication.h"
  11. #import "XCUIElement+FBIsVisible.h"
  12. #import "FBXCodeCompatibility.h"
  13. #import "XCUIScreen.h"
  14. @implementation FBScreen
  15. + (double)scale
  16. {
  17. return [XCUIScreen.mainScreen scale];
  18. }
  19. + (CGSize)statusBarSizeForApplication:(XCUIApplication *)application
  20. {
  21. XCUIApplication *app = FBApplication.fb_systemApplication;
  22. // Since iOS 13 the status bar is no longer part of the application, it’s part of the SpringBoard
  23. XCUIElement *mainStatusBar = app.statusBars.allElementsBoundByIndex.firstObject;
  24. if (nil == mainStatusBar) {
  25. return CGSizeZero;
  26. }
  27. CGSize result = mainStatusBar.frame.size;
  28. // Workaround for https://github.com/appium/appium/issues/15961
  29. return CGSizeMake(MAX(result.width, result.height), MIN(result.width, result.height));
  30. }
  31. @end