appium-espresso-driver 1.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (311) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/LICENSE +201 -0
  3. package/README.md +864 -0
  4. package/build/index.js +48 -0
  5. package/build/lib/commands/execute.js +67 -0
  6. package/build/lib/commands/general.js +337 -0
  7. package/build/lib/commands/idling-resources.js +31 -0
  8. package/build/lib/commands/index.js +26 -0
  9. package/build/lib/commands/services.js +27 -0
  10. package/build/lib/desired-caps.js +65 -0
  11. package/build/lib/driver.js +475 -0
  12. package/build/lib/espresso-runner.js +381 -0
  13. package/build/lib/logger.js +18 -0
  14. package/build/lib/server-builder.js +213 -0
  15. package/build/lib/server.js +39 -0
  16. package/build/lib/utils.js +85 -0
  17. package/espresso-server/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk +0 -0
  18. package/espresso-server/app/build/outputs/apk/androidTest/debug/output-metadata.json +18 -0
  19. package/espresso-server/app/build.gradle.kts +153 -0
  20. package/espresso-server/app/proguard-rules.pro +25 -0
  21. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/EspressoServerRunnerTest.kt +93 -0
  22. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/drivers/AppDriver.kt +29 -0
  23. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/drivers/ComposeDriver.kt +73 -0
  24. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/drivers/DriverContext.kt +35 -0
  25. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/drivers/EspressoDriver.kt +70 -0
  26. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/AcceptAlert.kt +32 -0
  27. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/Back.kt +31 -0
  28. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/Clear.kt +40 -0
  29. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/Click.kt +27 -0
  30. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/CreateSession.kt +58 -0
  31. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/DeleteSession.kt +33 -0
  32. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/DismissAlert.kt +32 -0
  33. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/DrawerActionHandler.kt +45 -0
  34. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/ElementEquals.kt +19 -0
  35. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/ElementScreenshot.kt +31 -0
  36. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/ElementValue.kt +85 -0
  37. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/FindActive.kt +32 -0
  38. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/FindElement.kt +29 -0
  39. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/FindElements.kt +43 -0
  40. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetAlertText.kt +31 -0
  41. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetAttribute.kt +101 -0
  42. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetClipboard.kt +65 -0
  43. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetDeviceInfo.kt +44 -0
  44. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetDisplayed.kt +28 -0
  45. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetEnabled.kt +30 -0
  46. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetLocation.kt +32 -0
  47. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetLocationInView.kt +33 -0
  48. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetName.kt +31 -0
  49. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetOrientation.kt +44 -0
  50. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetRect.kt +38 -0
  51. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetRotation.kt +33 -0
  52. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetSelected.kt +30 -0
  53. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetSession.kt +34 -0
  54. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetSessions.kt +41 -0
  55. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetSettings.kt +25 -0
  56. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetSize.kt +32 -0
  57. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetToastVisibility.kt +34 -0
  58. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetWindowRect.kt +43 -0
  59. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetWindowSize.kt +42 -0
  60. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/HideKeyboard.kt +29 -0
  61. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/Keys.kt +82 -0
  62. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/ListIdlingResources.kt +30 -0
  63. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/MobileBackdoor.kt +42 -0
  64. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/MobileClickAction.kt +49 -0
  65. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/MobileSwipe.kt +71 -0
  66. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/MobileViewFlash.kt +50 -0
  67. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/MoveTo.kt +50 -0
  68. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/MultiTouchAction.kt +50 -0
  69. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/NavigateTo.kt +42 -0
  70. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/NoSessionCommandHandler.kt +4 -0
  71. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/NotYetImplemented.kt +28 -0
  72. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/OpenNotifications.kt +28 -0
  73. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/PerformAction.kt +42 -0
  74. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/PerformAutofillDismissal.kt +31 -0
  75. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/PerformEditorAction.kt +30 -0
  76. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/PointerEventHandler.kt +281 -0
  77. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/PressKeyCode.kt +90 -0
  78. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/RegisterIdlingResources.kt +33 -0
  79. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/ReleaseActions.kt +41 -0
  80. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/RequestHandler.kt +43 -0
  81. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/ScreenshotHandler.kt +29 -0
  82. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/ScrollToPage.kt +60 -0
  83. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/SetClipboard.kt +64 -0
  84. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/SetDate.kt +41 -0
  85. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/SetOrientation.kt +61 -0
  86. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/SetRotation.kt +46 -0
  87. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/SetTime.kt +41 -0
  88. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/Source.kt +29 -0
  89. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/StartActivity.kt +30 -0
  90. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/StartService.kt +40 -0
  91. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/Status.kt +26 -0
  92. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/StopService.kt +37 -0
  93. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/Text.kt +28 -0
  94. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/TouchAction.kt +49 -0
  95. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/Uiautomator.kt +68 -0
  96. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/UiautomatorPageSource.kt +35 -0
  97. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/UnregisterIdlingResources.kt +33 -0
  98. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/UpdateSettings.kt +35 -0
  99. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/WebAtoms.kt +69 -0
  100. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/AppiumException.kt +40 -0
  101. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/DuplicateRouteException.kt +22 -0
  102. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/ElementNotVisibleException.kt +30 -0
  103. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/InvalidArgumentException.kt +35 -0
  104. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/InvalidElementStateException.kt +41 -0
  105. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/InvalidSelectorException.kt +35 -0
  106. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/MoveTargetOutOfBoundsException.kt +39 -0
  107. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/NoAlertOpenException.kt +33 -0
  108. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/NoSuchDriverException.kt +31 -0
  109. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/NoSuchElementException.kt +34 -0
  110. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/NotYetImplementedException.kt +33 -0
  111. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/ScreenCaptureException.kt +30 -0
  112. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/SessionNotCreatedException.kt +34 -0
  113. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/StaleElementException.kt +30 -0
  114. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/XPathLookupException.kt +31 -0
  115. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/AccessibilityServiceState.kt +15 -0
  116. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/ActivityHelpers.kt +125 -0
  117. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/ActivityOptionsHelpers.kt +60 -0
  118. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/AlertHelpers.kt +170 -0
  119. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/AndroidLogger.kt +45 -0
  120. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/AssertHelpers.kt +17 -0
  121. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/AutofillHelpers.kt +44 -0
  122. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/BackdoorUtils.java +49 -0
  123. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/ClipboardHelper.kt +51 -0
  124. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/ComposeNodeFinder.kt +59 -0
  125. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/DeviceInfoHelper.kt +148 -0
  126. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/EspressoViewsCache.kt +57 -0
  127. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/GsonParserHelpers.kt +72 -0
  128. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/IMEHelpers.kt +88 -0
  129. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/IntentHelpers.kt +336 -0
  130. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/InteractionHelper.kt +40 -0
  131. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/InvocationOperation.java +80 -0
  132. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/LocaleHelpers.kt +46 -0
  133. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/Logger.kt +25 -0
  134. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/NotificationListener.kt +87 -0
  135. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/Rect.kt +22 -0
  136. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/ReflectionUtils.kt +64 -0
  137. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/ScreenshotsHelper.kt +59 -0
  138. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/StringHelpers.kt +42 -0
  139. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/ThreadHelpers.kt +15 -0
  140. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/UiAutomationWrapper.kt +48 -0
  141. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/ViewFinder.kt +316 -0
  142. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/XMLHelpers.kt +56 -0
  143. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/extensions/Semaphore.kt +22 -0
  144. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/reflection/ArrayUtils.java +110 -0
  145. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/reflection/ClassUtils.java +180 -0
  146. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/reflection/MethodUtils.java +155 -0
  147. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/reflection/Validate.java +34 -0
  148. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/adapter/BaseW3CActionAdapter.kt +71 -0
  149. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/adapter/DummyW3CActionAdapter.kt +133 -0
  150. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/adapter/W3CActionAdapter.kt +71 -0
  151. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/adapter/espresso/AndroidKeyEvent.kt +271 -0
  152. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/adapter/espresso/AndroidMotionEvent.kt +90 -0
  153. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/adapter/espresso/EspressoW3CActionAdapter.kt +147 -0
  154. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/adapter/espresso/Helpers.kt +71 -0
  155. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/adapter/espresso/MotionEventBuilder.kt +153 -0
  156. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/adapter/espresso/MultiTouchState.kt +132 -0
  157. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/adapter/espresso/TouchState.kt +7 -0
  158. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/caps/CapsUtils.kt +96 -0
  159. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/dispatcher/BaseDispatchResult.kt +14 -0
  160. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/dispatcher/DispatchPointerMoveResult.kt +22 -0
  161. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/dispatcher/KeyDispatch.kt +151 -0
  162. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/dispatcher/PointerDispatch.kt +286 -0
  163. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/dispatcher/W3CKeyEvent.kt +21 -0
  164. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/dispatcher/constants/KeyCodeMapper.kt +169 -0
  165. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/dispatcher/constants/KeyLocationMapper.kt +50 -0
  166. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/dispatcher/constants/KeyNormalizer.kt +84 -0
  167. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/dispatcher/constants/NormalizedKeys.kt +60 -0
  168. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/models/ActionObject.kt +138 -0
  169. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/models/ActionSequence.kt +112 -0
  170. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/models/Actions.kt +89 -0
  171. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/models/InputSource.kt +173 -0
  172. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/models/Origin.kt +24 -0
  173. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/models/OriginDeserializer.kt +25 -0
  174. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/models/Tick.kt +62 -0
  175. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/processor/ActionsProcessor.kt +93 -0
  176. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/processor/KeyProcessor.kt +57 -0
  177. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/processor/PauseProcessor.kt +59 -0
  178. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/processor/PointerProcessor.kt +115 -0
  179. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/processor/ProcessorHelpers.kt +35 -0
  180. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/state/ActiveInputSources.kt +62 -0
  181. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/state/InputState.kt +6 -0
  182. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/state/InputStateTable.kt +95 -0
  183. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/state/KeyInputState.kt +82 -0
  184. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/state/PointerInputState.kt +45 -0
  185. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/http/RouteDefinition.kt +67 -0
  186. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/http/RouteMap.kt +51 -0
  187. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/http/Router.kt +250 -0
  188. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/http/Server.kt +109 -0
  189. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/http/response/AppiumResponse.kt +61 -0
  190. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/http/response/BaseResponse.kt +25 -0
  191. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/AlertParams.kt +21 -0
  192. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/AppiumParams.kt +55 -0
  193. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/BackdoorMethodArg.kt +3 -0
  194. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/ClipboardDataType.kt +18 -0
  195. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/DrawerActionParams.kt +21 -0
  196. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/EditorActionParams.kt +21 -0
  197. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/Element.kt +169 -0
  198. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/GetClipboardParams.kt +27 -0
  199. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/GlobalSession.kt +64 -0
  200. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/HamcrestMatcher.kt +144 -0
  201. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/IdlingResourcesParams.kt +66 -0
  202. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/KeyEventParams.kt +23 -0
  203. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/LocaleParams.kt +34 -0
  204. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/Location.kt +19 -0
  205. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/Locator.kt +22 -0
  206. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/MatcherJson.kt +37 -0
  207. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/MobileBackdoorMethod.kt +22 -0
  208. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/MobileBackdoorParams.kt +20 -0
  209. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/MobileClickActionParams.kt +81 -0
  210. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/MobileSwipeParams.kt +106 -0
  211. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/MotionEventParams.kt +37 -0
  212. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/MoveToParams.kt +26 -0
  213. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/MultiTouchActionsParams.kt +5 -0
  214. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/NavigateToParams.kt +21 -0
  215. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/OrientationParams.kt +21 -0
  216. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/OrientationType.kt +6 -0
  217. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/Rect.kt +24 -0
  218. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/RotationParams.kt +38 -0
  219. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/ScrollToPageParams.kt +36 -0
  220. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/SessionParams.kt +23 -0
  221. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/SetClipboardParams.kt +29 -0
  222. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/SetDateParams.kt +23 -0
  223. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/SetTimeParams.kt +22 -0
  224. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/SettingsParams.kt +19 -0
  225. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/Size.kt +22 -0
  226. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/SourceDocument.kt +286 -0
  227. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/StartActivityParams.kt +9 -0
  228. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/StartServiceParams.kt +22 -0
  229. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/StopServiceParams.kt +21 -0
  230. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/Strategy.kt +49 -0
  231. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/TextValueParams.kt +6 -0
  232. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/ToastLookupParams.kt +22 -0
  233. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/TouchAction.kt +178 -0
  234. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/TouchActionsParams.kt +5 -0
  235. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/UiautomatorParams.kt +123 -0
  236. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/ViewAttributesEnum.kt +51 -0
  237. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/ViewElement.kt +204 -0
  238. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/ViewFlashParams.kt +9 -0
  239. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/ViewText.kt +12 -0
  240. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/WindowRect.kt +24 -0
  241. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/WindowSize.kt +22 -0
  242. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/settings/AbstractSetting.kt +23 -0
  243. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/settings/DriverSetting.kt +40 -0
  244. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/settings/SettingType.kt +21 -0
  245. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/web/WebAtom.kt +26 -0
  246. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/web/WebAtomDeserializer.kt +99 -0
  247. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/web/WebAtomsMethods.kt +4 -0
  248. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/web/WebAtomsParams.kt +9 -0
  249. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/viewaction/OrientationChange.kt +47 -0
  250. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/viewaction/ScrollTo.kt +48 -0
  251. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/viewaction/UiControllerPerformer.kt +67 -0
  252. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/viewaction/UiControllerRunnable.kt +25 -0
  253. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/viewaction/ViewGetter.kt +79 -0
  254. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/viewaction/ViewTextGetter.kt +31 -0
  255. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/viewmatcher/RegexpTextMatcher.kt +38 -0
  256. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/viewmatcher/WithView.kt +33 -0
  257. package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/viewmatcher/WithXPath.kt +55 -0
  258. package/espresso-server/app/src/main/AndroidManifest.xml +7 -0
  259. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/assets/Helpers.kt +20 -0
  260. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/assets/backdoor-methods.json +51 -0
  261. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/assets/key-actions.json +15 -0
  262. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/assets/multi-touch-actions.json +28 -0
  263. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/GsonParserHelpersTest.kt +41 -0
  264. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/IntentCreationTests.kt +115 -0
  265. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/InvocationOperationTest.java +97 -0
  266. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/KReflectionUtilsTest.kt +108 -0
  267. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/XpathQueryParserTests.kt +42 -0
  268. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/ActionSequenceTest.kt +220 -0
  269. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/ActionsTest.kt +76 -0
  270. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/CapsUtilsTest.kt +76 -0
  271. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/Helpers.kt +7 -0
  272. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/InputSourceTest.kt +153 -0
  273. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/InputStateTableTest.kt +72 -0
  274. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/KeyDispatchTest.kt +133 -0
  275. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/KeyInputStateTest.kt +74 -0
  276. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/PointerDispatchTest.kt +370 -0
  277. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/ProcessorTest.kt +320 -0
  278. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/TickTest.kt +265 -0
  279. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/adapter/AndroidKeyEventTest.kt +114 -0
  280. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/adapter/HelpersTest.kt +31 -0
  281. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/http/RouteDefinitionTest.kt +74 -0
  282. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/model/HamcrestMatcherTest.kt +112 -0
  283. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/model/MatcherJsonTest.kt +20 -0
  284. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/model/MobileBackdoorMethodTest.java +110 -0
  285. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/model/MobileClickTest.kt +46 -0
  286. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/model/MobileSwipeTest.kt +68 -0
  287. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/model/TouchActionTest.kt +56 -0
  288. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/model/web/WebAtomTest.kt +68 -0
  289. package/espresso-server/app/src/test/java/io/appium/espressoserver/test/model/web/WebAtomsTest.kt +96 -0
  290. package/espresso-server/build.gradle.kts +33 -0
  291. package/espresso-server/gradle/wrapper/gradle-wrapper.jar +0 -0
  292. package/espresso-server/gradle/wrapper/gradle-wrapper.properties +5 -0
  293. package/espresso-server/gradle.properties +26 -0
  294. package/espresso-server/gradlew +185 -0
  295. package/espresso-server/gradlew.bat +89 -0
  296. package/espresso-server/lint.xml +4 -0
  297. package/espresso-server/settings.gradle.kts +1 -0
  298. package/index.js +29 -0
  299. package/lib/commands/execute.js +72 -0
  300. package/lib/commands/general.js +321 -0
  301. package/lib/commands/idling-resources.js +52 -0
  302. package/lib/commands/index.js +16 -0
  303. package/lib/commands/services.js +50 -0
  304. package/lib/desired-caps.js +55 -0
  305. package/lib/driver.js +566 -0
  306. package/lib/espresso-runner.js +340 -0
  307. package/lib/logger.js +6 -0
  308. package/lib/server-builder.js +194 -0
  309. package/lib/server.js +18 -0
  310. package/lib/utils.js +74 -0
  311. package/package.json +105 -0
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * See the NOTICE file distributed with this work for additional
5
+ * information regarding copyright ownership.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package io.appium.espressoserver.lib.handlers
18
+
19
+ import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
20
+ import io.appium.espressoserver.lib.model.AppiumParams
21
+ import io.appium.espressoserver.lib.model.EspressoElement
22
+ import io.appium.espressoserver.lib.model.Rect
23
+ import io.appium.espressoserver.lib.model.ViewElement
24
+
25
+ class GetRect : RequestHandler<AppiumParams, Rect> {
26
+
27
+ @Throws(AppiumException::class)
28
+ override fun handleInternal(params: AppiumParams): Rect {
29
+ val viewElement = ViewElement(EspressoElement.getViewById(params.elementId))
30
+ val elementBounds = viewElement.bounds
31
+ return Rect(
32
+ elementBounds.left,
33
+ elementBounds.top,
34
+ elementBounds.width(),
35
+ elementBounds.height()
36
+ )
37
+ }
38
+ }
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * See the NOTICE file distributed with this work for additional
5
+ * information regarding copyright ownership.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package io.appium.espressoserver.lib.handlers
18
+
19
+ import android.view.Surface
20
+ import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
21
+ import io.appium.espressoserver.lib.helpers.InteractionHelper.getUiDevice
22
+ import io.appium.espressoserver.lib.model.AppiumParams
23
+ import io.appium.espressoserver.lib.model.RotationParams
24
+
25
+ class GetRotation : RequestHandler<AppiumParams, RotationParams> {
26
+
27
+ @Throws(AppiumException::class)
28
+ override fun handleInternal(params: AppiumParams): RotationParams {
29
+ val rotation = getUiDevice().displayRotation
30
+ val degrees = if (rotation in Surface.ROTATION_0..Surface.ROTATION_270) rotation * 90 else 0
31
+ return RotationParams(0, 0, degrees)
32
+ }
33
+ }
@@ -0,0 +1,30 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * See the NOTICE file distributed with this work for additional
5
+ * information regarding copyright ownership.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package io.appium.espressoserver.lib.handlers
18
+
19
+ import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
20
+ import io.appium.espressoserver.lib.model.AppiumParams
21
+ import io.appium.espressoserver.lib.model.EspressoElement
22
+
23
+ import io.appium.espressoserver.lib.model.ViewElement
24
+
25
+ class GetSelected : RequestHandler<AppiumParams, Boolean> {
26
+
27
+ @Throws(AppiumException::class)
28
+ override fun handleInternal(params: AppiumParams): Boolean =
29
+ ViewElement(EspressoElement.getViewById(params.elementId)).isSelected
30
+ }
@@ -0,0 +1,34 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * See the NOTICE file distributed with this work for additional
5
+ * information regarding copyright ownership.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package io.appium.espressoserver.lib.handlers
18
+
19
+ import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
20
+ import io.appium.espressoserver.lib.model.AppiumParams
21
+ import io.appium.espressoserver.lib.model.GlobalSession
22
+ import io.appium.espressoserver.lib.model.SessionParams
23
+
24
+ class GetSession : RequestHandler<AppiumParams, SessionParams.W3CCapabilities?> {
25
+
26
+ @Throws(AppiumException::class)
27
+ override fun handleInternal(params: AppiumParams): SessionParams.W3CCapabilities? {
28
+ return if (GlobalSession.exists) {
29
+ GlobalSession.capabilities
30
+ } else {
31
+ null
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,41 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * See the NOTICE file distributed with this work for additional
5
+ * information regarding copyright ownership.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package io.appium.espressoserver.lib.handlers
18
+
19
+ import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
20
+ import io.appium.espressoserver.lib.model.AppiumParams
21
+ import io.appium.espressoserver.lib.model.GlobalSession
22
+
23
+ class GetSessions :
24
+ RequestHandler<AppiumParams, Collection<Map<String, Any?>>>, NoSessionCommandHandler {
25
+
26
+ @Throws(AppiumException::class)
27
+ override fun handleInternal(params: AppiumParams): Collection<Map<String, Any?>> {
28
+ return if (GlobalSession.exists) {
29
+ listOf(mapOf(
30
+ "id" to GlobalSession.sessionId,
31
+ "capabilities" to mapOf(
32
+ "firstMatch" to GlobalSession.capabilities?.firstMatch,
33
+ "alwaysMatch" to GlobalSession.capabilities?.alwaysMatch
34
+ )
35
+ ))
36
+ } else {
37
+ emptyList()
38
+ }
39
+ }
40
+
41
+ }
@@ -0,0 +1,25 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * See the NOTICE file distributed with this work for additional
5
+ * information regarding copyright ownership.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package io.appium.espressoserver.lib.handlers
18
+
19
+ import io.appium.espressoserver.lib.model.AppiumParams
20
+ import io.appium.espressoserver.lib.model.settings.SettingType
21
+
22
+ class GetSettings : RequestHandler<AppiumParams, Map<String, Any?>> {
23
+ override fun handleInternal(params: AppiumParams): Map<String, Any?> =
24
+ SettingType.values().map { it.setting.name to it.setting.value() }.toMap()
25
+ }
@@ -0,0 +1,32 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * See the NOTICE file distributed with this work for additional
5
+ * information regarding copyright ownership.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package io.appium.espressoserver.lib.handlers
18
+
19
+ import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
20
+ import io.appium.espressoserver.lib.model.AppiumParams
21
+ import io.appium.espressoserver.lib.model.EspressoElement
22
+ import io.appium.espressoserver.lib.model.Size
23
+ import io.appium.espressoserver.lib.model.ViewElement
24
+
25
+ class GetSize : RequestHandler<AppiumParams, Size> {
26
+
27
+ @Throws(AppiumException::class)
28
+ override fun handleInternal(params: AppiumParams): Size {
29
+ val bounds = ViewElement(EspressoElement.getViewById(params.elementId)).bounds
30
+ return Size(bounds.width(), bounds.height())
31
+ }
32
+ }
@@ -0,0 +1,34 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * See the NOTICE file distributed with this work for additional
5
+ * information regarding copyright ownership.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package io.appium.espressoserver.lib.handlers
18
+
19
+ import io.appium.espressoserver.lib.helpers.NotificationListener
20
+ import io.appium.espressoserver.lib.model.ToastLookupParams
21
+
22
+ class GetToastVisibility : RequestHandler<ToastLookupParams, Boolean> {
23
+ override fun handleInternal(params: ToastLookupParams): Boolean {
24
+ val toastMessage = NotificationListener.toastMessage.joinToString(separator = "\n")
25
+ if (toastMessage.isEmpty()) {
26
+ return false
27
+ }
28
+ return if (params.isRegexp) {
29
+ params.text.toRegex().containsMatchIn(toastMessage)
30
+ } else {
31
+ toastMessage.contains(params.text)
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,43 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * See the NOTICE file distributed with this work for additional
5
+ * information regarding copyright ownership.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package io.appium.espressoserver.lib.handlers
18
+
19
+ import android.content.Context
20
+ import android.util.DisplayMetrics
21
+ import android.view.WindowManager
22
+
23
+ import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
24
+ import io.appium.espressoserver.lib.model.AppiumParams
25
+ import io.appium.espressoserver.lib.model.WindowRect
26
+
27
+ import androidx.test.core.app.ApplicationProvider.getApplicationContext
28
+
29
+ class GetWindowRect : RequestHandler<AppiumParams, WindowRect> {
30
+
31
+ @Throws(AppiumException::class)
32
+ override fun handleInternal(params: AppiumParams): WindowRect {
33
+ val displayMetrics = DisplayMetrics()
34
+ val context = getApplicationContext<Context>()
35
+ val winManager = context.applicationContext.getSystemService(Context.WINDOW_SERVICE) as? WindowManager
36
+ ?: throw AppiumException("Couldn't get default display: " +
37
+ "context.getApplicationContext().getSystemService(Context.WINDOW_SERVICE) is null")
38
+
39
+ winManager.defaultDisplay.getMetrics(displayMetrics)
40
+
41
+ return WindowRect(displayMetrics.widthPixels, displayMetrics.heightPixels, 0, 0)
42
+ }
43
+ }
@@ -0,0 +1,42 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * See the NOTICE file distributed with this work for additional
5
+ * information regarding copyright ownership.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package io.appium.espressoserver.lib.handlers
18
+
19
+ import android.content.Context
20
+ import android.util.DisplayMetrics
21
+ import android.view.WindowManager
22
+
23
+ import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
24
+ import io.appium.espressoserver.lib.model.AppiumParams
25
+ import io.appium.espressoserver.lib.model.WindowSize
26
+
27
+ import androidx.test.core.app.ApplicationProvider.getApplicationContext
28
+
29
+ class GetWindowSize : RequestHandler<AppiumParams, WindowSize> {
30
+
31
+ @Throws(AppiumException::class)
32
+ override fun handleInternal(params: AppiumParams): WindowSize {
33
+ val displayMetrics = DisplayMetrics()
34
+ val context = getApplicationContext<Context>()
35
+ val winManager = context.applicationContext.getSystemService(Context.WINDOW_SERVICE) as? WindowManager
36
+ ?: throw AppiumException("Couldn't get default display: " +
37
+ "context.getApplicationContext().getSystemService(Context.WINDOW_SERVICE) is null")
38
+
39
+ winManager.defaultDisplay.getMetrics(displayMetrics)
40
+ return WindowSize(displayMetrics.widthPixels, displayMetrics.heightPixels)
41
+ }
42
+ }
@@ -0,0 +1,29 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * See the NOTICE file distributed with this work for additional
5
+ * information regarding copyright ownership.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package io.appium.espressoserver.lib.handlers
18
+
19
+ import androidx.test.espresso.Espresso
20
+ import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
21
+ import io.appium.espressoserver.lib.model.AppiumParams
22
+
23
+ class HideKeyboard : RequestHandler<AppiumParams, Void?> {
24
+ @Throws(AppiumException::class)
25
+ override fun handleInternal(params: AppiumParams): Void? {
26
+ Espresso.closeSoftKeyboard()
27
+ return null
28
+ }
29
+ }
@@ -0,0 +1,82 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * See the NOTICE file distributed with this work for additional
5
+ * information regarding copyright ownership.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package io.appium.espressoserver.lib.handlers
18
+
19
+ import androidx.test.espresso.UiController
20
+ import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
21
+ import io.appium.espressoserver.lib.helpers.w3c.adapter.espresso.EspressoW3CActionAdapter
22
+ import io.appium.espressoserver.lib.helpers.w3c.models.Actions.ActionsBuilder
23
+ import io.appium.espressoserver.lib.helpers.w3c.models.InputSource.Action
24
+ import io.appium.espressoserver.lib.helpers.w3c.models.InputSource.ActionBuilder
25
+ import io.appium.espressoserver.lib.helpers.w3c.models.InputSource.InputSourceBuilder
26
+ import io.appium.espressoserver.lib.viewaction.UiControllerPerformer
27
+ import io.appium.espressoserver.lib.viewaction.UiControllerRunnable
28
+
29
+ import io.appium.espressoserver.lib.helpers.w3c.models.InputSource.ActionType.KEY_DOWN
30
+ import io.appium.espressoserver.lib.helpers.w3c.models.InputSource.ActionType.KEY_UP
31
+ import io.appium.espressoserver.lib.helpers.w3c.models.InputSource.InputSourceType.KEY
32
+ import io.appium.espressoserver.lib.model.TextValueParams
33
+
34
+ class Keys : RequestHandler<TextValueParams, Void?> {
35
+
36
+ // Send keys to an active element which is only supported by MJSONWP
37
+ @Throws(AppiumException::class)
38
+ override fun handleInternal(params: TextValueParams): Void? {
39
+ val keys = params.value ?: emptyList()
40
+
41
+ val runnable = object : UiControllerRunnable<Void?> {
42
+ override fun run(uiController: UiController): Void? {
43
+ // Add a list of keyDown + keyUp actions for each key
44
+ val keyActions = arrayListOf<Action>()
45
+ keys.forEach {
46
+ // Key down event
47
+ keyActions.add(ActionBuilder()
48
+ .withType(KEY_DOWN)
49
+ .withValue(it)
50
+ .build()
51
+ )
52
+
53
+ // Key up event
54
+ keyActions.add(ActionBuilder()
55
+ .withType(KEY_UP)
56
+ .withValue(it)
57
+ .build()
58
+ )
59
+ }
60
+
61
+ val keyInputSource = InputSourceBuilder()
62
+ .withId("keyboard")
63
+ .withType(KEY)
64
+ .withActions(keyActions)
65
+ .build()
66
+
67
+ val actions = ActionsBuilder()
68
+ .withActions(listOf(keyInputSource))
69
+ .withAdapter(EspressoW3CActionAdapter(uiController))
70
+ .build()
71
+
72
+ actions.perform(params.sessionId!!)
73
+ actions.release(params.sessionId!!)
74
+
75
+ return null
76
+ }
77
+ }
78
+
79
+ UiControllerPerformer(runnable).run()
80
+ return null
81
+ }
82
+ }
@@ -0,0 +1,30 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * See the NOTICE file distributed with this work for additional
5
+ * information regarding copyright ownership.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package io.appium.espressoserver.lib.handlers
18
+
19
+ import androidx.test.espresso.IdlingRegistry
20
+ import io.appium.espressoserver.lib.model.*
21
+
22
+ class ListIdlingResources : RequestHandler<AppiumParams, List<String>> {
23
+
24
+ override fun handleInternal(params: AppiumParams): List<String> {
25
+ return IdlingRegistry.getInstance().resources.map {
26
+ it::class.java.canonicalName!!
27
+ }
28
+ }
29
+
30
+ }
@@ -0,0 +1,42 @@
1
+ package io.appium.espressoserver.lib.handlers
2
+
3
+ import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
4
+ import io.appium.espressoserver.lib.handlers.exceptions.InvalidArgumentException
5
+ import io.appium.espressoserver.lib.helpers.ActivityHelpers
6
+ import io.appium.espressoserver.lib.helpers.InvocationOperation
7
+ import io.appium.espressoserver.lib.model.EspressoElement
8
+ import io.appium.espressoserver.lib.model.InvocationTarget
9
+ import io.appium.espressoserver.lib.model.MobileBackdoorParams
10
+
11
+ class MobileBackdoor : RequestHandler<MobileBackdoorParams, Any?> {
12
+
13
+ @Throws(AppiumException::class)
14
+ override fun handleInternal(params: MobileBackdoorParams): Any? {
15
+ params.target?.let {target ->
16
+ val activity = ActivityHelpers.currentActivity
17
+ val ops = getBackdoorOperations(params)
18
+
19
+ @Suppress("REDUNDANT_ELSE_IN_WHEN")
20
+ return when (target) {
21
+ InvocationTarget.ACTIVITY -> invokeBackdoorMethods(activity, ops)
22
+ InvocationTarget.APPLICATION -> invokeBackdoorMethods(activity.application, ops)
23
+ InvocationTarget.ELEMENT -> invokeBackdoorMethods(EspressoElement.getViewById(params.targetElement), ops)
24
+ else -> throw InvalidArgumentException("target cannot be '$target'")
25
+ }
26
+ }
27
+
28
+ throw InvalidArgumentException("Target must not be empty and must be of type: 'activity', 'application'")
29
+ }
30
+
31
+ @Throws(AppiumException::class)
32
+ private fun invokeBackdoorMethods(invokeOn: Any, ops: List<InvocationOperation>): Any? {
33
+ return ops.fold(invokeOn) { invocationTarget, operation -> operation.apply(invocationTarget) }
34
+ }
35
+
36
+ @Throws(InvalidArgumentException::class)
37
+ private fun getBackdoorOperations(params: MobileBackdoorParams): List<InvocationOperation> {
38
+ return params.methods.map {method ->
39
+ InvocationOperation(method.name, method.arguments, method.argumentTypes)
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,49 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * See the NOTICE file distributed with this work for additional
5
+ * information regarding copyright ownership.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package io.appium.espressoserver.lib.handlers
18
+
19
+ import androidx.test.espresso.UiController
20
+ import androidx.test.espresso.action.GeneralClickAction
21
+ import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
22
+ import io.appium.espressoserver.lib.model.EspressoElement
23
+ import io.appium.espressoserver.lib.model.MobileClickActionParams
24
+ import io.appium.espressoserver.lib.viewaction.UiControllerPerformer
25
+ import io.appium.espressoserver.lib.viewaction.UiControllerRunnable
26
+
27
+ class MobileClickAction : RequestHandler<MobileClickActionParams, Void?> {
28
+
29
+ @Throws(AppiumException::class)
30
+ override fun handleInternal(params: MobileClickActionParams): Void? {
31
+ val runnable = object : UiControllerRunnable<Void?> {
32
+ override fun run(uiController: UiController): Void? {
33
+ val clickAction = GeneralClickAction(
34
+ params.tapper,
35
+ params.coordinatesProvider,
36
+ params.precisionDescriber,
37
+ params.inputDevice,
38
+ params.buttonState
39
+ )
40
+ clickAction.perform(uiController, EspressoElement.getViewById(params.elementId))
41
+
42
+ return null
43
+ }
44
+ }
45
+ UiControllerPerformer(runnable).run()
46
+
47
+ return null
48
+ }
49
+ }
@@ -0,0 +1,71 @@
1
+ /*
2
+ * Licensed under the Apache License, Version 2.0 (the "License");
3
+ * you may not use this file except in compliance with the License.
4
+ * See the NOTICE file distributed with this work for additional
5
+ * information regarding copyright ownership.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+
17
+ package io.appium.espressoserver.lib.handlers
18
+
19
+ import androidx.test.espresso.UiController
20
+ import androidx.test.espresso.action.GeneralSwipeAction
21
+ import androidx.test.espresso.action.ViewActions.*
22
+ import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
23
+ import io.appium.espressoserver.lib.handlers.exceptions.InvalidArgumentException
24
+ import io.appium.espressoserver.lib.helpers.AndroidLogger
25
+ import io.appium.espressoserver.lib.model.EspressoElement
26
+ import io.appium.espressoserver.lib.model.MobileSwipeParams
27
+ import io.appium.espressoserver.lib.model.MobileSwipeParams.Direction.*
28
+ import io.appium.espressoserver.lib.viewaction.UiControllerPerformer
29
+ import io.appium.espressoserver.lib.viewaction.UiControllerRunnable
30
+
31
+ class MobileSwipe : RequestHandler<MobileSwipeParams, Void?> {
32
+
33
+ @Throws(AppiumException::class)
34
+ override fun handleInternal(params: MobileSwipeParams): Void? {
35
+ // Get a reference to the view and call onData. This will automatically scroll to the view.
36
+ val viewInteraction = EspressoElement.getViewInteractionById(params.elementId)
37
+
38
+ if (params.direction != null) {
39
+ AndroidLogger.info("Performing swipe action with direction '${params.direction}'")
40
+ when (params.direction) {
41
+ UP -> viewInteraction.perform(swipeUp())
42
+ DOWN -> viewInteraction.perform(swipeDown())
43
+ LEFT -> viewInteraction.perform(swipeLeft())
44
+ RIGHT -> viewInteraction.perform(swipeRight())
45
+ else -> throw InvalidArgumentException("Direction cannot be ${params.direction}")
46
+ }
47
+ } else if (params.swiper != null) {
48
+
49
+ val runnable = object : UiControllerRunnable<Void?> {
50
+ override fun run(uiController: UiController): Void? {
51
+ val swipeAction = GeneralSwipeAction(
52
+ params.swiper,
53
+ params.startCoordinates,
54
+ params.endCoordinates,
55
+ params.precisionDescriber
56
+ )
57
+ AndroidLogger.info("""
58
+ Performing general swipe action with parameters
59
+ swiper=[${params.swiper}] startCoordinates=[${params.startCoordinates}]
60
+ endCoordinates=[${params.endCoordinates}] precisionDescriber=[${params.precisionDescriber}]
61
+ """.trimIndent())
62
+ swipeAction.perform(uiController, EspressoElement.getViewById(params.elementId))
63
+ return null
64
+ }
65
+ }
66
+ UiControllerPerformer(runnable).run()
67
+ }
68
+
69
+ return null
70
+ }
71
+ }