FBScreen.m 1.1 KB

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