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.
- package/CHANGELOG.md +23 -0
- package/LICENSE +201 -0
- package/README.md +864 -0
- package/build/index.js +48 -0
- package/build/lib/commands/execute.js +67 -0
- package/build/lib/commands/general.js +337 -0
- package/build/lib/commands/idling-resources.js +31 -0
- package/build/lib/commands/index.js +26 -0
- package/build/lib/commands/services.js +27 -0
- package/build/lib/desired-caps.js +65 -0
- package/build/lib/driver.js +475 -0
- package/build/lib/espresso-runner.js +381 -0
- package/build/lib/logger.js +18 -0
- package/build/lib/server-builder.js +213 -0
- package/build/lib/server.js +39 -0
- package/build/lib/utils.js +85 -0
- package/espresso-server/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk +0 -0
- package/espresso-server/app/build/outputs/apk/androidTest/debug/output-metadata.json +18 -0
- package/espresso-server/app/build.gradle.kts +153 -0
- package/espresso-server/app/proguard-rules.pro +25 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/EspressoServerRunnerTest.kt +93 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/drivers/AppDriver.kt +29 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/drivers/ComposeDriver.kt +73 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/drivers/DriverContext.kt +35 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/drivers/EspressoDriver.kt +70 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/AcceptAlert.kt +32 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/Back.kt +31 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/Clear.kt +40 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/Click.kt +27 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/CreateSession.kt +58 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/DeleteSession.kt +33 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/DismissAlert.kt +32 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/DrawerActionHandler.kt +45 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/ElementEquals.kt +19 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/ElementScreenshot.kt +31 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/ElementValue.kt +85 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/FindActive.kt +32 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/FindElement.kt +29 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/FindElements.kt +43 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetAlertText.kt +31 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetAttribute.kt +101 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetClipboard.kt +65 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetDeviceInfo.kt +44 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetDisplayed.kt +28 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetEnabled.kt +30 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetLocation.kt +32 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetLocationInView.kt +33 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetName.kt +31 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetOrientation.kt +44 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetRect.kt +38 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetRotation.kt +33 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetSelected.kt +30 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetSession.kt +34 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetSessions.kt +41 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetSettings.kt +25 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetSize.kt +32 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetToastVisibility.kt +34 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetWindowRect.kt +43 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetWindowSize.kt +42 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/HideKeyboard.kt +29 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/Keys.kt +82 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/ListIdlingResources.kt +30 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/MobileBackdoor.kt +42 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/MobileClickAction.kt +49 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/MobileSwipe.kt +71 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/MobileViewFlash.kt +50 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/MoveTo.kt +50 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/MultiTouchAction.kt +50 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/NavigateTo.kt +42 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/NoSessionCommandHandler.kt +4 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/NotYetImplemented.kt +28 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/OpenNotifications.kt +28 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/PerformAction.kt +42 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/PerformAutofillDismissal.kt +31 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/PerformEditorAction.kt +30 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/PointerEventHandler.kt +281 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/PressKeyCode.kt +90 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/RegisterIdlingResources.kt +33 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/ReleaseActions.kt +41 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/RequestHandler.kt +43 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/ScreenshotHandler.kt +29 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/ScrollToPage.kt +60 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/SetClipboard.kt +64 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/SetDate.kt +41 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/SetOrientation.kt +61 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/SetRotation.kt +46 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/SetTime.kt +41 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/Source.kt +29 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/StartActivity.kt +30 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/StartService.kt +40 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/Status.kt +26 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/StopService.kt +37 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/Text.kt +28 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/TouchAction.kt +49 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/Uiautomator.kt +68 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/UiautomatorPageSource.kt +35 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/UnregisterIdlingResources.kt +33 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/UpdateSettings.kt +35 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/WebAtoms.kt +69 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/AppiumException.kt +40 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/DuplicateRouteException.kt +22 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/ElementNotVisibleException.kt +30 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/InvalidArgumentException.kt +35 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/InvalidElementStateException.kt +41 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/InvalidSelectorException.kt +35 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/MoveTargetOutOfBoundsException.kt +39 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/NoAlertOpenException.kt +33 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/NoSuchDriverException.kt +31 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/NoSuchElementException.kt +34 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/NotYetImplementedException.kt +33 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/ScreenCaptureException.kt +30 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/SessionNotCreatedException.kt +34 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/StaleElementException.kt +30 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/exceptions/XPathLookupException.kt +31 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/AccessibilityServiceState.kt +15 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/ActivityHelpers.kt +125 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/ActivityOptionsHelpers.kt +60 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/AlertHelpers.kt +170 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/AndroidLogger.kt +45 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/AssertHelpers.kt +17 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/AutofillHelpers.kt +44 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/BackdoorUtils.java +49 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/ClipboardHelper.kt +51 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/ComposeNodeFinder.kt +59 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/DeviceInfoHelper.kt +148 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/EspressoViewsCache.kt +57 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/GsonParserHelpers.kt +72 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/IMEHelpers.kt +88 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/IntentHelpers.kt +336 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/InteractionHelper.kt +40 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/InvocationOperation.java +80 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/LocaleHelpers.kt +46 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/Logger.kt +25 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/NotificationListener.kt +87 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/Rect.kt +22 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/ReflectionUtils.kt +64 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/ScreenshotsHelper.kt +59 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/StringHelpers.kt +42 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/ThreadHelpers.kt +15 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/UiAutomationWrapper.kt +48 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/ViewFinder.kt +316 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/XMLHelpers.kt +56 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/extensions/Semaphore.kt +22 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/reflection/ArrayUtils.java +110 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/reflection/ClassUtils.java +180 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/reflection/MethodUtils.java +155 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/reflection/Validate.java +34 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/adapter/BaseW3CActionAdapter.kt +71 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/adapter/DummyW3CActionAdapter.kt +133 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/adapter/W3CActionAdapter.kt +71 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/adapter/espresso/AndroidKeyEvent.kt +271 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/adapter/espresso/AndroidMotionEvent.kt +90 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/adapter/espresso/EspressoW3CActionAdapter.kt +147 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/adapter/espresso/Helpers.kt +71 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/adapter/espresso/MotionEventBuilder.kt +153 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/adapter/espresso/MultiTouchState.kt +132 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/adapter/espresso/TouchState.kt +7 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/caps/CapsUtils.kt +96 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/dispatcher/BaseDispatchResult.kt +14 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/dispatcher/DispatchPointerMoveResult.kt +22 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/dispatcher/KeyDispatch.kt +151 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/dispatcher/PointerDispatch.kt +286 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/dispatcher/W3CKeyEvent.kt +21 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/dispatcher/constants/KeyCodeMapper.kt +169 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/dispatcher/constants/KeyLocationMapper.kt +50 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/dispatcher/constants/KeyNormalizer.kt +84 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/dispatcher/constants/NormalizedKeys.kt +60 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/models/ActionObject.kt +138 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/models/ActionSequence.kt +112 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/models/Actions.kt +89 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/models/InputSource.kt +173 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/models/Origin.kt +24 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/models/OriginDeserializer.kt +25 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/models/Tick.kt +62 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/processor/ActionsProcessor.kt +93 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/processor/KeyProcessor.kt +57 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/processor/PauseProcessor.kt +59 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/processor/PointerProcessor.kt +115 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/processor/ProcessorHelpers.kt +35 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/state/ActiveInputSources.kt +62 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/state/InputState.kt +6 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/state/InputStateTable.kt +95 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/state/KeyInputState.kt +82 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/w3c/state/PointerInputState.kt +45 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/http/RouteDefinition.kt +67 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/http/RouteMap.kt +51 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/http/Router.kt +250 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/http/Server.kt +109 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/http/response/AppiumResponse.kt +61 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/http/response/BaseResponse.kt +25 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/AlertParams.kt +21 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/AppiumParams.kt +55 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/BackdoorMethodArg.kt +3 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/ClipboardDataType.kt +18 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/DrawerActionParams.kt +21 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/EditorActionParams.kt +21 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/Element.kt +169 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/GetClipboardParams.kt +27 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/GlobalSession.kt +64 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/HamcrestMatcher.kt +144 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/IdlingResourcesParams.kt +66 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/KeyEventParams.kt +23 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/LocaleParams.kt +34 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/Location.kt +19 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/Locator.kt +22 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/MatcherJson.kt +37 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/MobileBackdoorMethod.kt +22 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/MobileBackdoorParams.kt +20 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/MobileClickActionParams.kt +81 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/MobileSwipeParams.kt +106 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/MotionEventParams.kt +37 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/MoveToParams.kt +26 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/MultiTouchActionsParams.kt +5 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/NavigateToParams.kt +21 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/OrientationParams.kt +21 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/OrientationType.kt +6 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/Rect.kt +24 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/RotationParams.kt +38 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/ScrollToPageParams.kt +36 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/SessionParams.kt +23 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/SetClipboardParams.kt +29 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/SetDateParams.kt +23 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/SetTimeParams.kt +22 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/SettingsParams.kt +19 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/Size.kt +22 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/SourceDocument.kt +286 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/StartActivityParams.kt +9 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/StartServiceParams.kt +22 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/StopServiceParams.kt +21 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/Strategy.kt +49 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/TextValueParams.kt +6 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/ToastLookupParams.kt +22 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/TouchAction.kt +178 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/TouchActionsParams.kt +5 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/UiautomatorParams.kt +123 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/ViewAttributesEnum.kt +51 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/ViewElement.kt +204 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/ViewFlashParams.kt +9 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/ViewText.kt +12 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/WindowRect.kt +24 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/WindowSize.kt +22 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/settings/AbstractSetting.kt +23 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/settings/DriverSetting.kt +40 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/settings/SettingType.kt +21 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/web/WebAtom.kt +26 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/web/WebAtomDeserializer.kt +99 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/web/WebAtomsMethods.kt +4 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/model/web/WebAtomsParams.kt +9 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/viewaction/OrientationChange.kt +47 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/viewaction/ScrollTo.kt +48 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/viewaction/UiControllerPerformer.kt +67 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/viewaction/UiControllerRunnable.kt +25 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/viewaction/ViewGetter.kt +79 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/viewaction/ViewTextGetter.kt +31 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/viewmatcher/RegexpTextMatcher.kt +38 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/viewmatcher/WithView.kt +33 -0
- package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/viewmatcher/WithXPath.kt +55 -0
- package/espresso-server/app/src/main/AndroidManifest.xml +7 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/assets/Helpers.kt +20 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/assets/backdoor-methods.json +51 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/assets/key-actions.json +15 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/assets/multi-touch-actions.json +28 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/GsonParserHelpersTest.kt +41 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/IntentCreationTests.kt +115 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/InvocationOperationTest.java +97 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/KReflectionUtilsTest.kt +108 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/XpathQueryParserTests.kt +42 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/ActionSequenceTest.kt +220 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/ActionsTest.kt +76 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/CapsUtilsTest.kt +76 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/Helpers.kt +7 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/InputSourceTest.kt +153 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/InputStateTableTest.kt +72 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/KeyDispatchTest.kt +133 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/KeyInputStateTest.kt +74 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/PointerDispatchTest.kt +370 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/ProcessorTest.kt +320 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/TickTest.kt +265 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/adapter/AndroidKeyEventTest.kt +114 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/helpers/w3c/adapter/HelpersTest.kt +31 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/http/RouteDefinitionTest.kt +74 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/model/HamcrestMatcherTest.kt +112 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/model/MatcherJsonTest.kt +20 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/model/MobileBackdoorMethodTest.java +110 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/model/MobileClickTest.kt +46 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/model/MobileSwipeTest.kt +68 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/model/TouchActionTest.kt +56 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/model/web/WebAtomTest.kt +68 -0
- package/espresso-server/app/src/test/java/io/appium/espressoserver/test/model/web/WebAtomsTest.kt +96 -0
- package/espresso-server/build.gradle.kts +33 -0
- package/espresso-server/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/espresso-server/gradle/wrapper/gradle-wrapper.properties +5 -0
- package/espresso-server/gradle.properties +26 -0
- package/espresso-server/gradlew +185 -0
- package/espresso-server/gradlew.bat +89 -0
- package/espresso-server/lint.xml +4 -0
- package/espresso-server/settings.gradle.kts +1 -0
- package/index.js +29 -0
- package/lib/commands/execute.js +72 -0
- package/lib/commands/general.js +321 -0
- package/lib/commands/idling-resources.js +52 -0
- package/lib/commands/index.js +16 -0
- package/lib/commands/services.js +50 -0
- package/lib/desired-caps.js +55 -0
- package/lib/driver.js +566 -0
- package/lib/espresso-runner.js +340 -0
- package/lib/logger.js +6 -0
- package/lib/server-builder.js +194 -0
- package/lib/server.js +18 -0
- package/lib/utils.js +74 -0
- package/package.json +105 -0
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
package io.appium.espressoserver.lib.helpers.w3c.models
|
|
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.w3c.adapter.W3CActionAdapter
|
|
6
|
+
import io.appium.espressoserver.lib.helpers.w3c.dispatcher.BaseDispatchResult
|
|
7
|
+
import io.appium.espressoserver.lib.helpers.w3c.dispatcher.PointerDispatch
|
|
8
|
+
import io.appium.espressoserver.lib.helpers.w3c.dispatcher.dispatchKeyDown
|
|
9
|
+
import io.appium.espressoserver.lib.helpers.w3c.dispatcher.dispatchKeyUp
|
|
10
|
+
import io.appium.espressoserver.lib.helpers.w3c.models.InputSource.InputSourceType
|
|
11
|
+
import io.appium.espressoserver.lib.helpers.w3c.state.InputStateTable
|
|
12
|
+
import io.appium.espressoserver.lib.helpers.w3c.state.KeyInputState
|
|
13
|
+
import io.appium.espressoserver.lib.helpers.w3c.state.PointerInputState
|
|
14
|
+
import java.util.concurrent.Callable
|
|
15
|
+
|
|
16
|
+
class ActionObject {
|
|
17
|
+
private var index = 0
|
|
18
|
+
var type: InputSourceType? = null
|
|
19
|
+
var subType: InputSource.ActionType? = null
|
|
20
|
+
var id: String? = null
|
|
21
|
+
var duration: Float? = null
|
|
22
|
+
var x: Float? = null
|
|
23
|
+
get() { return field ?: 0f }
|
|
24
|
+
var y: Float? = null
|
|
25
|
+
get() { return field ?: 0f }
|
|
26
|
+
var button = 0
|
|
27
|
+
var value: String? = null
|
|
28
|
+
var pointer: InputSource.PointerType? = null
|
|
29
|
+
var origin = Origin()
|
|
30
|
+
|
|
31
|
+
constructor() {}
|
|
32
|
+
|
|
33
|
+
// Copy constructor
|
|
34
|
+
constructor(actionObject: ActionObject) {
|
|
35
|
+
index = actionObject.index
|
|
36
|
+
type = actionObject.type
|
|
37
|
+
subType = actionObject.subType
|
|
38
|
+
id = actionObject.id
|
|
39
|
+
duration = actionObject.duration
|
|
40
|
+
origin = actionObject.origin
|
|
41
|
+
x = actionObject.x
|
|
42
|
+
y = actionObject.y
|
|
43
|
+
button = actionObject.button
|
|
44
|
+
value = actionObject.value
|
|
45
|
+
pointer = actionObject.pointer
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
constructor(id: String?, type: InputSourceType?, subType: InputSource.ActionType?, index: Int) {
|
|
49
|
+
this.type = type
|
|
50
|
+
this.subType = subType
|
|
51
|
+
this.id = id
|
|
52
|
+
this.index = index // Store the index of the action for possible future logging issues
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Call `dispatch tick actions` algorithm in section 17.4
|
|
57
|
+
* @param adapter Adapter for actions
|
|
58
|
+
* @param inputStateTable State of all inputs
|
|
59
|
+
* @param tickDuration How long the tick is
|
|
60
|
+
* @param timeAtBeginningOfTick When the tick began
|
|
61
|
+
* @return
|
|
62
|
+
* @throws AppiumException
|
|
63
|
+
*/
|
|
64
|
+
@Throws(AppiumException::class)
|
|
65
|
+
fun dispatch(adapter: W3CActionAdapter,
|
|
66
|
+
inputStateTable: InputStateTable,
|
|
67
|
+
tickDuration: Float, timeAtBeginningOfTick: Long): Callable<BaseDispatchResult>? {
|
|
68
|
+
val inputSourceType = type
|
|
69
|
+
val actionType = subType
|
|
70
|
+
adapter.logger.info(String.format(
|
|
71
|
+
"Dispatching action #%s of input source %s",
|
|
72
|
+
index, id
|
|
73
|
+
))
|
|
74
|
+
// 1.3 If the current session's input state table doesn't have a property corresponding to
|
|
75
|
+
// source id, then let the property corresponding to source id be a new object of the
|
|
76
|
+
// corresponding input source state type for source type.
|
|
77
|
+
// 1.4 Let device state be the input source state corresponding to source id in the current session’s input state table
|
|
78
|
+
val deviceState = inputStateTable.getOrCreateInputState(id!!, this)
|
|
79
|
+
try {
|
|
80
|
+
if (inputSourceType == InputSourceType.KEY) {
|
|
81
|
+
when (actionType) {
|
|
82
|
+
InputSource.ActionType.KEY_DOWN -> dispatchKeyDown(adapter, this, (deviceState as KeyInputState), inputStateTable, tickDuration)
|
|
83
|
+
InputSource.ActionType.KEY_UP -> dispatchKeyUp(adapter, this, (deviceState as KeyInputState), inputStateTable, tickDuration)
|
|
84
|
+
else -> {}
|
|
85
|
+
}
|
|
86
|
+
} else if (inputSourceType == InputSourceType.POINTER) {
|
|
87
|
+
when (actionType) {
|
|
88
|
+
InputSource.ActionType.POINTER_MOVE -> return PointerDispatch.dispatchPointerMove(
|
|
89
|
+
adapter,
|
|
90
|
+
id,
|
|
91
|
+
this,
|
|
92
|
+
deviceState as PointerInputState,
|
|
93
|
+
tickDuration,
|
|
94
|
+
timeAtBeginningOfTick,
|
|
95
|
+
inputStateTable.globalKeyInputState
|
|
96
|
+
)
|
|
97
|
+
InputSource.ActionType.POINTER_DOWN -> {
|
|
98
|
+
PointerDispatch.dispatchPointerDown(
|
|
99
|
+
adapter,
|
|
100
|
+
this,
|
|
101
|
+
deviceState as PointerInputState,
|
|
102
|
+
inputStateTable,
|
|
103
|
+
inputStateTable.globalKeyInputState
|
|
104
|
+
)
|
|
105
|
+
return null
|
|
106
|
+
}
|
|
107
|
+
InputSource.ActionType.POINTER_UP -> {
|
|
108
|
+
PointerDispatch.dispatchPointerUp(
|
|
109
|
+
adapter,
|
|
110
|
+
this,
|
|
111
|
+
deviceState as PointerInputState,
|
|
112
|
+
inputStateTable,
|
|
113
|
+
inputStateTable.globalKeyInputState
|
|
114
|
+
)
|
|
115
|
+
return null
|
|
116
|
+
}
|
|
117
|
+
InputSource.ActionType.POINTER_CANCEL -> {
|
|
118
|
+
PointerDispatch.dispatchPointerCancel(
|
|
119
|
+
adapter,
|
|
120
|
+
this
|
|
121
|
+
)
|
|
122
|
+
return null
|
|
123
|
+
}
|
|
124
|
+
else -> adapter.logger.info(String.format(
|
|
125
|
+
"Dispatching pause event for %s milliseconds",
|
|
126
|
+
duration
|
|
127
|
+
))
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
} catch (cce: ClassCastException) {
|
|
131
|
+
throw InvalidArgumentException(String.format(
|
|
132
|
+
"Attempted to apply action of type '%s' to a source with type '%s': %s",
|
|
133
|
+
inputSourceType, deviceState!!.javaClass.simpleName, cce.message
|
|
134
|
+
))
|
|
135
|
+
}
|
|
136
|
+
return null
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
package io.appium.espressoserver.lib.helpers.w3c.models
|
|
2
|
+
|
|
3
|
+
import java.util.concurrent.ExecutionException
|
|
4
|
+
import java.util.concurrent.ExecutorCompletionService
|
|
5
|
+
import java.util.concurrent.Executors
|
|
6
|
+
|
|
7
|
+
import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
|
|
8
|
+
import io.appium.espressoserver.lib.handlers.exceptions.InvalidArgumentException
|
|
9
|
+
import io.appium.espressoserver.lib.handlers.exceptions.NotYetImplementedException
|
|
10
|
+
import io.appium.espressoserver.lib.helpers.w3c.adapter.W3CActionAdapter
|
|
11
|
+
import io.appium.espressoserver.lib.helpers.w3c.dispatcher.BaseDispatchResult
|
|
12
|
+
import io.appium.espressoserver.lib.helpers.w3c.state.ActiveInputSources
|
|
13
|
+
import io.appium.espressoserver.lib.helpers.w3c.state.InputStateTable
|
|
14
|
+
|
|
15
|
+
import io.appium.espressoserver.lib.helpers.w3c.processor.ActionsProcessor.processSourceActionSequence
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The algorithm for extracting an action sequence from a request takes the JSON Object representing
|
|
19
|
+
* an action sequence, validates the input, and returns a data structure that is the transpose of
|
|
20
|
+
* the input JSON, such that the actions to be performed in a single tick are grouped together
|
|
21
|
+
*
|
|
22
|
+
* (Defined in 17.3 of spec 'extract an action sequence')
|
|
23
|
+
*/
|
|
24
|
+
class ActionSequence @Throws(InvalidArgumentException::class, NotYetImplementedException::class)
|
|
25
|
+
constructor(actions: Actions, activeInputSources: ActiveInputSources,
|
|
26
|
+
inputStateTable: InputStateTable) : Iterator<Tick> {
|
|
27
|
+
|
|
28
|
+
private val ticks = arrayListOf<Tick>()
|
|
29
|
+
private var tickCounter = 0
|
|
30
|
+
|
|
31
|
+
init {
|
|
32
|
+
// Check if null to keep Codacy happy. It will never make it this far if it's null though.
|
|
33
|
+
actions.actions?.let {
|
|
34
|
+
for (inputSource in it) {
|
|
35
|
+
val actionObjects = processSourceActionSequence(inputSource, activeInputSources, inputStateTable)
|
|
36
|
+
for ((tickIndex, action) in actionObjects.withIndex()) {
|
|
37
|
+
if (ticks.size == tickIndex) {
|
|
38
|
+
ticks.add(Tick())
|
|
39
|
+
}
|
|
40
|
+
val tick = ticks[tickIndex]
|
|
41
|
+
tick.addAction(action)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
override fun hasNext(): Boolean {
|
|
48
|
+
return tickCounter < ticks.size
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
override fun next(): Tick {
|
|
52
|
+
return ticks[tickCounter++]
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Call the dispatchAll algorithm defined in 17.4
|
|
57
|
+
* @param adapter W3C ActionsPerformer adapter
|
|
58
|
+
* @param inputStateTable Input states for this session
|
|
59
|
+
* @throws AppiumException
|
|
60
|
+
* @throws InterruptedException
|
|
61
|
+
* @throws ExecutionException
|
|
62
|
+
*/
|
|
63
|
+
@Throws(AppiumException::class, InterruptedException::class, ExecutionException::class)
|
|
64
|
+
fun dispatch(adapter: W3CActionAdapter, inputStateTable: InputStateTable) {
|
|
65
|
+
for ((tickIndex, tick) in ticks.withIndex()) {
|
|
66
|
+
val timeAtBeginningOfTick = System.currentTimeMillis()
|
|
67
|
+
val tickDuration = tick.calculateTickDuration()
|
|
68
|
+
|
|
69
|
+
// 1. Dispatch all of the events
|
|
70
|
+
adapter.logger.info("Dispatching tick #${tickIndex + 1} of ${ticks.size}")
|
|
71
|
+
val callables = tick.dispatchAll(adapter, inputStateTable, tickDuration)
|
|
72
|
+
var callableCount = callables.size
|
|
73
|
+
|
|
74
|
+
adapter.sychronousTickActionsComplete()
|
|
75
|
+
|
|
76
|
+
// 2. Wait until the following conditions are all met:
|
|
77
|
+
|
|
78
|
+
// 2.1 Wait for any pending async operations
|
|
79
|
+
if (callables.isNotEmpty()) {
|
|
80
|
+
val executor = Executors.newCachedThreadPool()
|
|
81
|
+
val completionService = ExecutorCompletionService<BaseDispatchResult>(executor)
|
|
82
|
+
for (callable in callables) {
|
|
83
|
+
completionService.submit(callable)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
var received = 0
|
|
87
|
+
while (received < callableCount) {
|
|
88
|
+
val resultFuture = completionService.take() //blocks if none available
|
|
89
|
+
val dispatchResult = resultFuture.get()
|
|
90
|
+
dispatchResult.perform()
|
|
91
|
+
if (dispatchResult.hasNext()) {
|
|
92
|
+
callableCount++
|
|
93
|
+
completionService.submit(dispatchResult.next)
|
|
94
|
+
}
|
|
95
|
+
received++
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// 2.2 At least tick duration milliseconds have passed
|
|
100
|
+
val timeSinceBeginningOfTick = (System.currentTimeMillis() - timeAtBeginningOfTick).toFloat()
|
|
101
|
+
if (timeSinceBeginningOfTick < tickDuration) {
|
|
102
|
+
val timeToSleep = tickDuration - timeSinceBeginningOfTick
|
|
103
|
+
adapter.logger.info("Wait for tick to finish for $timeToSleep ms")
|
|
104
|
+
adapter.sleep(timeToSleep)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// 2.3 The UI thread is complete
|
|
108
|
+
adapter.waitForUiThread()
|
|
109
|
+
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
package io.appium.espressoserver.lib.helpers.w3c.models
|
|
17
|
+
|
|
18
|
+
import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
|
|
19
|
+
import io.appium.espressoserver.lib.helpers.w3c.adapter.W3CActionAdapter
|
|
20
|
+
import io.appium.espressoserver.lib.helpers.w3c.state.ActiveInputSources
|
|
21
|
+
import io.appium.espressoserver.lib.helpers.w3c.state.InputStateTable
|
|
22
|
+
import io.appium.espressoserver.lib.model.AppiumParams
|
|
23
|
+
import java.util.concurrent.ExecutionException
|
|
24
|
+
|
|
25
|
+
class Actions : AppiumParams() {
|
|
26
|
+
var actions: List<InputSource>? = null
|
|
27
|
+
var adapter: W3CActionAdapter? = null
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Perform actions (17.5)
|
|
31
|
+
* @param sessionId ID of the session to perform actions on
|
|
32
|
+
* @throws AppiumException
|
|
33
|
+
*/
|
|
34
|
+
@Throws(AppiumException::class)
|
|
35
|
+
fun perform(sessionId: String) {
|
|
36
|
+
if (adapter == null) {
|
|
37
|
+
throw AppiumException("An internal server error has occurred: Failed to initialize /actions adapter")
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Get state of session
|
|
41
|
+
val activeInputSources = ActiveInputSources.getActiveInputSourcesForSession(sessionId)
|
|
42
|
+
val inputStateTable = InputStateTable.getInputStateTableOfSession(sessionId)
|
|
43
|
+
|
|
44
|
+
// Let `actions by tick` be the result of trying to extract an action sequence with argument parameters
|
|
45
|
+
adapter!!.logger.info("Performing actions")
|
|
46
|
+
val actionsByTick = ActionSequence(this, activeInputSources, inputStateTable)
|
|
47
|
+
try {
|
|
48
|
+
// Dispatch the actions
|
|
49
|
+
actionsByTick.dispatch(adapter!!, inputStateTable)
|
|
50
|
+
} catch (e: InterruptedException) {
|
|
51
|
+
throw AppiumException(e.cause.toString())
|
|
52
|
+
} catch (e: ExecutionException) {
|
|
53
|
+
throw AppiumException(e.cause.toString())
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Release actions (17.6)
|
|
59
|
+
* @param sessionId ID of the session to release actions on
|
|
60
|
+
*/
|
|
61
|
+
@Throws(AppiumException::class)
|
|
62
|
+
fun release(sessionId: String) {
|
|
63
|
+
if (adapter == null) {
|
|
64
|
+
throw AppiumException("An internal server error has occurred: Failed to initialize /actions adapter")
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// Get state of session
|
|
68
|
+
val inputStateTable = InputStateTable.getInputStateTableOfSession(sessionId)
|
|
69
|
+
|
|
70
|
+
// Undo all actions
|
|
71
|
+
adapter!!.logger.info(String.format("Releasing actions performed during session %s", sessionId))
|
|
72
|
+
inputStateTable.undoAll(adapter!!, System.currentTimeMillis())
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
class ActionsBuilder {
|
|
76
|
+
private var actions: List<InputSource>? = null
|
|
77
|
+
private var adapter: W3CActionAdapter? = null
|
|
78
|
+
fun withActions(actions: List<InputSource>?): ActionsBuilder = apply { this.actions = actions }
|
|
79
|
+
|
|
80
|
+
fun withAdapter(adapter: W3CActionAdapter?): ActionsBuilder = apply { this.adapter = adapter }
|
|
81
|
+
|
|
82
|
+
fun build(): Actions {
|
|
83
|
+
val actions = Actions()
|
|
84
|
+
actions.adapter = adapter
|
|
85
|
+
actions.actions = this.actions
|
|
86
|
+
return actions
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
package io.appium.espressoserver.lib.helpers.w3c.models
|
|
2
|
+
|
|
3
|
+
import com.google.gson.annotations.SerializedName
|
|
4
|
+
import io.appium.espressoserver.lib.helpers.w3c.state.InputState
|
|
5
|
+
import io.appium.espressoserver.lib.helpers.w3c.state.KeyInputState
|
|
6
|
+
import io.appium.espressoserver.lib.helpers.w3c.state.PointerInputState
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* InputSource
|
|
10
|
+
*
|
|
11
|
+
* (refer to https://www.w3.org/TR/webdriver/#terminology-0 of W3C spec)
|
|
12
|
+
*
|
|
13
|
+
* Represents a Virtual Device providing input events
|
|
14
|
+
*/
|
|
15
|
+
@Suppress("unused")
|
|
16
|
+
class InputSource {
|
|
17
|
+
var type: InputSourceType? = null
|
|
18
|
+
var id: String? = null
|
|
19
|
+
var parameters: Parameters? = null
|
|
20
|
+
var actions: List<Action>? = null
|
|
21
|
+
private val state: InputState? = null
|
|
22
|
+
|
|
23
|
+
constructor() {}
|
|
24
|
+
constructor(type: InputSourceType?, id: String?, parameters: Parameters?, actions: List<Action>?) {
|
|
25
|
+
this.type = type
|
|
26
|
+
this.id = id
|
|
27
|
+
this.parameters = parameters
|
|
28
|
+
this.actions = actions
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get the initial state of an Input Source
|
|
33
|
+
* @return Get the initial input state (see 17.3 for info on Input State)
|
|
34
|
+
*/
|
|
35
|
+
val defaultState: InputState?
|
|
36
|
+
get() = when (type) {
|
|
37
|
+
InputSourceType.POINTER -> PointerInputState(pointerType)
|
|
38
|
+
InputSourceType.KEY -> KeyInputState()
|
|
39
|
+
else -> null
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// NOTE: The spec specifies that the default should be MOUSE. This is an exception
|
|
43
|
+
// because the vast majority of use cases on a mobile device will use TOUCH.
|
|
44
|
+
val pointerType: PointerType?
|
|
45
|
+
get() {
|
|
46
|
+
if (parameters != null) {
|
|
47
|
+
return parameters!!.pointerType
|
|
48
|
+
} else if (type == InputSourceType.POINTER) {
|
|
49
|
+
// NOTE: The spec specifies that the default should be MOUSE. This is an exception
|
|
50
|
+
// because the vast majority of use cases on a mobile device will use TOUCH.
|
|
51
|
+
return PointerType.TOUCH
|
|
52
|
+
}
|
|
53
|
+
return null
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
enum class InputSourceType {
|
|
57
|
+
@SerializedName("pointer")
|
|
58
|
+
POINTER,
|
|
59
|
+
@SerializedName("key")
|
|
60
|
+
KEY,
|
|
61
|
+
@SerializedName("none")
|
|
62
|
+
NONE
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
class Action {
|
|
66
|
+
var type // type of action
|
|
67
|
+
: ActionType? = null
|
|
68
|
+
var duration // time in milliseconds
|
|
69
|
+
: Float? = null
|
|
70
|
+
var button // Button that is being pressed. Defaults to 0.
|
|
71
|
+
: Int? = null
|
|
72
|
+
get() { return field ?: 0 }
|
|
73
|
+
var x // x coordinate of pointer
|
|
74
|
+
: Float? = null
|
|
75
|
+
var y // y coordinate of pointer
|
|
76
|
+
: Float? = null
|
|
77
|
+
var value // a string containing a single Unicode code point or a number
|
|
78
|
+
: String? = null
|
|
79
|
+
var origin = Origin() // origin; could be viewport, pointer or <{element-6066-11e4-a52e-4f735466cecf: <element-uuid>}>
|
|
80
|
+
|
|
81
|
+
val isOriginViewport: Boolean
|
|
82
|
+
get() = origin.type != null && origin.type.equals(Origin.VIEWPORT, ignoreCase = true)
|
|
83
|
+
|
|
84
|
+
val isOriginPointer: Boolean
|
|
85
|
+
get() = origin.type != null && origin.type.equals(Origin.POINTER, ignoreCase = true)
|
|
86
|
+
|
|
87
|
+
val isOriginElement: Boolean
|
|
88
|
+
get() = origin.type != null && origin.type.equals(Origin.ELEMENT, ignoreCase = true)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
enum class ActionType {
|
|
92
|
+
@SerializedName("pause")
|
|
93
|
+
PAUSE,
|
|
94
|
+
@SerializedName("pointerDown")
|
|
95
|
+
POINTER_DOWN,
|
|
96
|
+
@SerializedName("pointerUp")
|
|
97
|
+
POINTER_UP,
|
|
98
|
+
@SerializedName("pointerMove")
|
|
99
|
+
POINTER_MOVE,
|
|
100
|
+
@SerializedName("pointerCancel")
|
|
101
|
+
POINTER_CANCEL,
|
|
102
|
+
@SerializedName("keyUp")
|
|
103
|
+
KEY_UP,
|
|
104
|
+
@SerializedName("keyDown")
|
|
105
|
+
KEY_DOWN
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
class Parameters {
|
|
109
|
+
var pointerType: PointerType? = null
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
enum class PointerType {
|
|
113
|
+
@SerializedName("mouse")
|
|
114
|
+
MOUSE,
|
|
115
|
+
@SerializedName("pen")
|
|
116
|
+
PEN,
|
|
117
|
+
@SerializedName("touch")
|
|
118
|
+
TOUCH
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
class InputSourceBuilder {
|
|
122
|
+
private var type: InputSourceType? = null
|
|
123
|
+
private var id: String? = null
|
|
124
|
+
private var parameters: Parameters? = null
|
|
125
|
+
private var actions: List<Action>? = null
|
|
126
|
+
fun withType(type: InputSourceType?): InputSourceBuilder = apply { this.type = type }
|
|
127
|
+
fun withId(id: String?): InputSourceBuilder = apply { this.id = id }
|
|
128
|
+
fun withParameters(parameters: Parameters?): InputSourceBuilder = apply { this.parameters = parameters }
|
|
129
|
+
fun withActions(actions: List<Action>?): InputSourceBuilder = apply { this.actions = actions }
|
|
130
|
+
fun build(): InputSource {
|
|
131
|
+
val inputSource = InputSource()
|
|
132
|
+
inputSource.actions = actions
|
|
133
|
+
inputSource.type = type
|
|
134
|
+
inputSource.id = id
|
|
135
|
+
inputSource.parameters = parameters
|
|
136
|
+
return inputSource
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
class ActionBuilder {
|
|
141
|
+
private var type: ActionType? = null
|
|
142
|
+
private var duration: Long? = null
|
|
143
|
+
private var button: Int? = null
|
|
144
|
+
private var x: Long? = null
|
|
145
|
+
private var y: Long? = null
|
|
146
|
+
private var value: String? = null
|
|
147
|
+
private var origin = Origin()
|
|
148
|
+
fun withType(type: ActionType?): ActionBuilder = apply { this.type = type }
|
|
149
|
+
fun withDuration(duration: Long?): ActionBuilder = apply { this.duration = duration }
|
|
150
|
+
fun withButton(button: Int?): ActionBuilder = apply { this.button = button }
|
|
151
|
+
fun withX(x: Long?): ActionBuilder = apply { this.x = x }
|
|
152
|
+
fun withY(y: Long?): ActionBuilder = apply { this.y = y }
|
|
153
|
+
fun withValue(value: String?): ActionBuilder = apply { this.value = value }
|
|
154
|
+
fun withOrigin(origin: Origin): ActionBuilder = apply { this.origin = origin }
|
|
155
|
+
fun withOriginType(originType: String?): ActionBuilder = apply { this.origin.type = originType }
|
|
156
|
+
fun withOriginElementId(elementId: String?): ActionBuilder = apply {
|
|
157
|
+
this.origin.type = Origin.ELEMENT
|
|
158
|
+
this.origin.elementId = elementId
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
fun build(): Action {
|
|
162
|
+
val action = Action()
|
|
163
|
+
duration?.let { action.duration = it.toFloat() }
|
|
164
|
+
action.type = type
|
|
165
|
+
button?.let { action.button = it }
|
|
166
|
+
action.value = value
|
|
167
|
+
x?.let { action.x = it.toFloat() }
|
|
168
|
+
y?.let { action.y = it.toFloat() }
|
|
169
|
+
action.origin = origin
|
|
170
|
+
return action
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
package io.appium.espressoserver.lib.helpers.w3c.models
|
|
2
|
+
|
|
3
|
+
import com.google.gson.annotations.JsonAdapter
|
|
4
|
+
|
|
5
|
+
@JsonAdapter(OriginDeserializer::class)
|
|
6
|
+
class Origin {
|
|
7
|
+
var type: String? = VIEWPORT
|
|
8
|
+
var elementId: String? = null
|
|
9
|
+
|
|
10
|
+
constructor()
|
|
11
|
+
constructor(type: String) {
|
|
12
|
+
this.type = type
|
|
13
|
+
}
|
|
14
|
+
constructor(type: String, elementId: String) {
|
|
15
|
+
this.type = type
|
|
16
|
+
this.elementId = elementId
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
companion object {
|
|
20
|
+
const val VIEWPORT = "viewport"
|
|
21
|
+
const val POINTER = "pointer"
|
|
22
|
+
const val ELEMENT = "element-6066-11e4-a52e-4f735466cecf"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
package io.appium.espressoserver.lib.helpers.w3c.models
|
|
2
|
+
|
|
3
|
+
import com.google.gson.JsonDeserializationContext
|
|
4
|
+
import com.google.gson.JsonDeserializer
|
|
5
|
+
import com.google.gson.JsonElement
|
|
6
|
+
import com.google.gson.JsonParseException
|
|
7
|
+
import java.lang.reflect.Type
|
|
8
|
+
|
|
9
|
+
class OriginDeserializer : JsonDeserializer<Origin> {
|
|
10
|
+
@Throws(JsonParseException::class)
|
|
11
|
+
override fun deserialize(json: JsonElement, paramType: Type,
|
|
12
|
+
paramJsonDeserializationContext: JsonDeserializationContext): Origin {
|
|
13
|
+
val origin = Origin()
|
|
14
|
+
if (json.isJsonPrimitive) {
|
|
15
|
+
origin.type = json.asString
|
|
16
|
+
} else if (json.isJsonObject && json.asJsonObject[Origin.ELEMENT].isJsonPrimitive) {
|
|
17
|
+
val elementId = json.asJsonObject[Origin.ELEMENT].asString
|
|
18
|
+
origin.elementId = elementId
|
|
19
|
+
origin.type = Origin.ELEMENT
|
|
20
|
+
} else if (json.isJsonNull) {
|
|
21
|
+
origin.type = Origin.VIEWPORT
|
|
22
|
+
}
|
|
23
|
+
return origin
|
|
24
|
+
}
|
|
25
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
package io.appium.espressoserver.lib.helpers.w3c.models
|
|
2
|
+
|
|
3
|
+
import io.appium.espressoserver.lib.handlers.exceptions.AppiumException
|
|
4
|
+
import io.appium.espressoserver.lib.helpers.w3c.adapter.W3CActionAdapter
|
|
5
|
+
import io.appium.espressoserver.lib.helpers.w3c.dispatcher.BaseDispatchResult
|
|
6
|
+
import io.appium.espressoserver.lib.helpers.w3c.models.InputSource.InputSourceType
|
|
7
|
+
import io.appium.espressoserver.lib.helpers.w3c.state.InputStateTable
|
|
8
|
+
import java.util.*
|
|
9
|
+
import java.util.concurrent.Callable
|
|
10
|
+
|
|
11
|
+
class Tick : Iterator<ActionObject> {
|
|
12
|
+
private val tickActions: MutableList<ActionObject> = ArrayList()
|
|
13
|
+
private var actionCounter = 0
|
|
14
|
+
fun addAction(action: ActionObject) {
|
|
15
|
+
tickActions.add(action)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
override fun hasNext(): Boolean {
|
|
19
|
+
return actionCounter < tickActions.size
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
override fun next(): ActionObject {
|
|
23
|
+
return tickActions[actionCounter++]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Get max tick duration for a tick
|
|
28
|
+
* @return Max tick duration
|
|
29
|
+
*/
|
|
30
|
+
fun calculateTickDuration(): Float {
|
|
31
|
+
var maxDuration = 0f
|
|
32
|
+
for (actionObject in tickActions) {
|
|
33
|
+
var currDuration = 0.0f
|
|
34
|
+
val type = actionObject.type
|
|
35
|
+
val duration = actionObject.duration
|
|
36
|
+
val subType = actionObject.subType
|
|
37
|
+
if (duration != null && (subType === InputSource.ActionType.PAUSE
|
|
38
|
+
|| type === InputSourceType.POINTER && subType === InputSource.ActionType.POINTER_MOVE)) {
|
|
39
|
+
currDuration = duration
|
|
40
|
+
}
|
|
41
|
+
if (currDuration > maxDuration) {
|
|
42
|
+
maxDuration = currDuration
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return maxDuration
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@Throws(AppiumException::class)
|
|
49
|
+
fun dispatchAll(adapter: W3CActionAdapter, inputStateTable: InputStateTable, tickDuration: Float): List<Callable<BaseDispatchResult>> {
|
|
50
|
+
val timeAtBeginningOfTick = System.currentTimeMillis()
|
|
51
|
+
val asyncOperations: MutableList<Callable<BaseDispatchResult>> = ArrayList()
|
|
52
|
+
for (actionObject in tickActions) {
|
|
53
|
+
// 2. Run algorithm with arguments source id, action object, device state and tick duration
|
|
54
|
+
val dispatchResult = actionObject.dispatch(adapter,
|
|
55
|
+
inputStateTable, tickDuration, timeAtBeginningOfTick)
|
|
56
|
+
|
|
57
|
+
// If it's an async operation, add it to the list
|
|
58
|
+
dispatchResult?.let { asyncOperations.add(it) }
|
|
59
|
+
}
|
|
60
|
+
return asyncOperations
|
|
61
|
+
}
|
|
62
|
+
}
|