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,93 @@
|
|
|
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.helpers.w3c.processor
|
|
18
|
+
|
|
19
|
+
import io.appium.espressoserver.lib.handlers.exceptions.InvalidArgumentException
|
|
20
|
+
import io.appium.espressoserver.lib.handlers.exceptions.NotYetImplementedException
|
|
21
|
+
import io.appium.espressoserver.lib.helpers.w3c.models.ActionObject
|
|
22
|
+
import io.appium.espressoserver.lib.helpers.w3c.models.InputSource
|
|
23
|
+
import io.appium.espressoserver.lib.helpers.w3c.models.InputSource.InputSourceType
|
|
24
|
+
import io.appium.espressoserver.lib.helpers.w3c.state.ActiveInputSources
|
|
25
|
+
import io.appium.espressoserver.lib.helpers.w3c.state.InputStateTable
|
|
26
|
+
|
|
27
|
+
import io.appium.espressoserver.lib.helpers.w3c.processor.KeyProcessor.processKeyAction
|
|
28
|
+
import io.appium.espressoserver.lib.helpers.w3c.processor.PauseProcessor.processNullAction
|
|
29
|
+
import io.appium.espressoserver.lib.helpers.w3c.processor.PointerProcessor.processPointerAction
|
|
30
|
+
|
|
31
|
+
object ActionsProcessor {
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Follows algorithm "for process an input source action sequence" in section 17.3
|
|
35
|
+
*/
|
|
36
|
+
@Throws(InvalidArgumentException::class, NotYetImplementedException::class)
|
|
37
|
+
fun processSourceActionSequence(inputSource: InputSource, activeInputSources: ActiveInputSources, inputStateTable: InputStateTable): List<ActionObject> {
|
|
38
|
+
// 1: Get the type
|
|
39
|
+
// 2: If type is not "key", "pointer", or "none", return an error
|
|
40
|
+
inputSource.type
|
|
41
|
+
?: throw InvalidArgumentException("'type' is required in input source and must be one of: pointer, key, none")
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
// 3: Get the ID from the input source
|
|
45
|
+
// 4: If id is undefined or is not a String, return error
|
|
46
|
+
val id = inputSource.id
|
|
47
|
+
?: throw InvalidArgumentException("'id' in action cannot be null")
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
// 6: Let source be the input source in the list of active input sources where that input source’s input id matches id,
|
|
51
|
+
val activeSource = activeInputSources.getInputSource(inputSource)
|
|
52
|
+
|
|
53
|
+
// 7: source is undefined:
|
|
54
|
+
if (activeSource == null) {
|
|
55
|
+
activeInputSources.addInputSource(inputSource)
|
|
56
|
+
inputStateTable.addInputState(inputSource.id!!, inputSource.defaultState!!)
|
|
57
|
+
} else {
|
|
58
|
+
|
|
59
|
+
// 8: If source's type does not match type return an error
|
|
60
|
+
if (activeSource.type != inputSource.type) {
|
|
61
|
+
throw InvalidArgumentException("Input type ${inputSource.type} does not match pre-existing input type '${activeSource.type}' in actions input source with id '${id}'")
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// 9: If it's a pointer type, check that they match parameter types
|
|
65
|
+
if (activeSource.type == InputSourceType.POINTER && activeSource.pointerType != inputSource.pointerType) {
|
|
66
|
+
throw InvalidArgumentException("Pointer type ${inputSource.pointerType} does not match pre-existing pointer type '${activeSource.pointerType}' in actions input " +
|
|
67
|
+
"source with id '${id}'")
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// 10: Let action items be the result of getting a property named actions from action sequence
|
|
72
|
+
// 11: If action items is not an Array, return error
|
|
73
|
+
val actionItems = inputSource.actions
|
|
74
|
+
?: throw InvalidArgumentException("'actions' array not provided in actions input source with id '${id}'")
|
|
75
|
+
|
|
76
|
+
// 12: Let actions be a new list
|
|
77
|
+
val actionObjects = arrayListOf<ActionObject>()
|
|
78
|
+
|
|
79
|
+
// 13: For each item in action items
|
|
80
|
+
var index = 0
|
|
81
|
+
for (action in actionItems) {
|
|
82
|
+
index++
|
|
83
|
+
when (inputSource.type) {
|
|
84
|
+
InputSourceType.NONE -> actionObjects.add(processNullAction(action, inputSource.type, id, index))
|
|
85
|
+
InputSourceType.POINTER -> actionObjects.add(processPointerAction(action, inputSource, id, index))
|
|
86
|
+
InputSourceType.KEY -> actionObjects.add(processKeyAction(action, inputSource.type, id, index))
|
|
87
|
+
else -> throw InvalidArgumentException("'actions[${index}]' of input source with id '${id}' did not provide a valid type")
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return actionObjects
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
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.processor
|
|
17
|
+
|
|
18
|
+
import io.appium.espressoserver.lib.handlers.exceptions.InvalidArgumentException
|
|
19
|
+
import io.appium.espressoserver.lib.helpers.w3c.models.ActionObject
|
|
20
|
+
import io.appium.espressoserver.lib.helpers.w3c.models.InputSource
|
|
21
|
+
import io.appium.espressoserver.lib.helpers.w3c.models.InputSource.InputSourceType
|
|
22
|
+
|
|
23
|
+
object KeyProcessor {
|
|
24
|
+
/**
|
|
25
|
+
* Follows the 'process a key action' algorithm in 17.2
|
|
26
|
+
* @param action Action being processed
|
|
27
|
+
* @param inputSourceType Source type
|
|
28
|
+
* @param id ID of input source that it's part of
|
|
29
|
+
* @param index Index within the 'actions' array
|
|
30
|
+
* @return Processed action object
|
|
31
|
+
* @throws InvalidArgumentException If failed to process, throw this. Means that args are bad.
|
|
32
|
+
*/
|
|
33
|
+
@Throws(InvalidArgumentException::class)
|
|
34
|
+
fun processKeyAction(action: InputSource.Action, inputSourceType: InputSourceType?, id: String?, index: Int): ActionObject {
|
|
35
|
+
|
|
36
|
+
// 1-3 get and validate the action type
|
|
37
|
+
val subType = action.type
|
|
38
|
+
val validKeyTypes = listOf(InputSource.ActionType.KEY_UP, InputSource.ActionType.KEY_DOWN, InputSource.ActionType.PAUSE)
|
|
39
|
+
if (!validKeyTypes.contains(subType)) {
|
|
40
|
+
throwArgException(index, id, "has an invalid type. 'type' for 'key' actions must be one of: keyUp, keyDown or pause")
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// 4 if pause return PAUSE action
|
|
44
|
+
if (subType == InputSource.ActionType.PAUSE) {
|
|
45
|
+
return PauseProcessor.processPauseAction(action, inputSourceType, id, index)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// 5-7 get the Unicode value of the keystroke (verify that it's a single character)
|
|
49
|
+
val key = action.value
|
|
50
|
+
if (key?.length != 1) {
|
|
51
|
+
throwArgException(index, id, String.format("has invalid 'value' %s. Must be a unicode point", key))
|
|
52
|
+
}
|
|
53
|
+
val actionObject = ActionObject(id, inputSourceType, subType, index)
|
|
54
|
+
actionObject.value = key
|
|
55
|
+
return actionObject
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
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.processor
|
|
17
|
+
|
|
18
|
+
import io.appium.espressoserver.lib.handlers.exceptions.InvalidArgumentException
|
|
19
|
+
import io.appium.espressoserver.lib.helpers.w3c.models.ActionObject
|
|
20
|
+
import io.appium.espressoserver.lib.helpers.w3c.models.InputSource
|
|
21
|
+
import io.appium.espressoserver.lib.helpers.w3c.models.InputSource.InputSourceType
|
|
22
|
+
|
|
23
|
+
object PauseProcessor {
|
|
24
|
+
/**
|
|
25
|
+
* Implement the 'process a null action' in 17.3
|
|
26
|
+
* @param action Action being processed
|
|
27
|
+
* @param inputSourceType Source type
|
|
28
|
+
* @param id ID of input source that it's part of
|
|
29
|
+
* @param index Index within the 'actions' array
|
|
30
|
+
* @return Processed action object
|
|
31
|
+
* @throws InvalidArgumentException If failed to process, throw this. Means that args are bad.
|
|
32
|
+
*/
|
|
33
|
+
@Throws(InvalidArgumentException::class)
|
|
34
|
+
fun processNullAction(action: InputSource.Action, inputSourceType: InputSourceType?, id: String?, index: Int): ActionObject {
|
|
35
|
+
if (action.type != InputSource.ActionType.PAUSE) {
|
|
36
|
+
throwArgException(index, id, "must be type 'pause' if input source type is null")
|
|
37
|
+
}
|
|
38
|
+
return processPauseAction(action, inputSourceType, id, index)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Follows the 'process a pause action' algorithm in 17.3
|
|
43
|
+
* @param action Action being processed
|
|
44
|
+
* @param inputSourceType Source type
|
|
45
|
+
* @param id ID of input source that it's part of
|
|
46
|
+
* @param index Index within the 'actions' array
|
|
47
|
+
* @return Processed action object
|
|
48
|
+
* @throws InvalidArgumentException If failed to process, throw this. Means that args are bad.
|
|
49
|
+
*/
|
|
50
|
+
@JvmStatic
|
|
51
|
+
@Throws(InvalidArgumentException::class)
|
|
52
|
+
fun processPauseAction(action: InputSource.Action, inputSourceType: InputSourceType?, id: String?, index: Int): ActionObject {
|
|
53
|
+
val duration = action.duration
|
|
54
|
+
assertNullOrPositive(index, id, "duration", duration)
|
|
55
|
+
val actionObject = ActionObject(id, inputSourceType, InputSource.ActionType.PAUSE, index)
|
|
56
|
+
actionObject.duration = duration
|
|
57
|
+
return actionObject
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
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.processor
|
|
17
|
+
|
|
18
|
+
import io.appium.espressoserver.lib.handlers.exceptions.InvalidArgumentException
|
|
19
|
+
import io.appium.espressoserver.lib.helpers.w3c.models.ActionObject
|
|
20
|
+
import io.appium.espressoserver.lib.helpers.w3c.models.InputSource
|
|
21
|
+
import io.appium.espressoserver.lib.helpers.w3c.models.InputSource.InputSourceType
|
|
22
|
+
import io.appium.espressoserver.lib.helpers.w3c.processor.PauseProcessor.processPauseAction
|
|
23
|
+
|
|
24
|
+
object PointerProcessor {
|
|
25
|
+
/**
|
|
26
|
+
* Follows the 'process a pointer action' algorithm in 17.2
|
|
27
|
+
* @param action Action being processed
|
|
28
|
+
* @param inputSource Input source
|
|
29
|
+
* @param id ID of input source that it's part of
|
|
30
|
+
* @param index Index within the 'actions' array
|
|
31
|
+
* @return Processed action object
|
|
32
|
+
* @throws InvalidArgumentException If failed to process, throw this. Means that args are bad.
|
|
33
|
+
*/
|
|
34
|
+
@Throws(InvalidArgumentException::class)
|
|
35
|
+
fun processPointerAction(action: InputSource.Action, inputSource: InputSource, id: String?, index: Int): ActionObject {
|
|
36
|
+
|
|
37
|
+
// 1 -2 get and validate the type
|
|
38
|
+
val subType = action.type
|
|
39
|
+
val validKeyTypes = listOf(InputSource.ActionType.POINTER_MOVE, InputSource.ActionType.POINTER_DOWN,
|
|
40
|
+
InputSource.ActionType.POINTER_UP, InputSource.ActionType.POINTER_CANCEL, InputSource.ActionType.PAUSE)
|
|
41
|
+
if (!validKeyTypes.contains(subType)) {
|
|
42
|
+
throwArgException(index, id, "has an invalid type. 'type' for 'key' actions must be one of:" +
|
|
43
|
+
"pointerMove, pointerDown, pointerUp, pointerCancel, pause")
|
|
44
|
+
}
|
|
45
|
+
val actionObject: ActionObject
|
|
46
|
+
|
|
47
|
+
// 4 if pause return PAUSE action
|
|
48
|
+
if (subType == InputSource.ActionType.PAUSE) {
|
|
49
|
+
return processPauseAction(action, inputSource.type, id, index)
|
|
50
|
+
}
|
|
51
|
+
actionObject = when (subType) {
|
|
52
|
+
InputSource.ActionType.POINTER_DOWN, InputSource.ActionType.POINTER_UP -> processPointerUpOrDownAction(action, inputSource.type, id, index)
|
|
53
|
+
InputSource.ActionType.POINTER_MOVE -> processPointerMoveAction(action, inputSource.type, id, index)
|
|
54
|
+
InputSource.ActionType.POINTER_CANCEL -> processPointerCancelAction(action, inputSource.type, id, index)
|
|
55
|
+
else -> throw InvalidArgumentException(String.format("Invalid pointer type %s", subType))
|
|
56
|
+
}
|
|
57
|
+
actionObject.pointer = inputSource.pointerType
|
|
58
|
+
return actionObject
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Follows the 'process a pointer up or pointer down action' algorithm in 17.2
|
|
63
|
+
* @param action Action being processed
|
|
64
|
+
* @param inputSourceType Source type
|
|
65
|
+
* @param id ID of input source that it's part of
|
|
66
|
+
* @param index Index within the 'actions' array
|
|
67
|
+
* @return Processed action object
|
|
68
|
+
* @throws InvalidArgumentException If failed to process, throw this. Means that args are bad.
|
|
69
|
+
*/
|
|
70
|
+
@Throws(InvalidArgumentException::class)
|
|
71
|
+
fun processPointerUpOrDownAction(action: InputSource.Action, inputSourceType: InputSourceType?, id: String?, index: Int): ActionObject {
|
|
72
|
+
val actionObject = ActionObject(id, inputSourceType, action.type, index)
|
|
73
|
+
val button = action.button
|
|
74
|
+
if (button!! < 0) {
|
|
75
|
+
throwArgException(index, id, String.format("property 'button' must be greater than or equal to 0. Found %s", button))
|
|
76
|
+
}
|
|
77
|
+
actionObject.button = button
|
|
78
|
+
return actionObject
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
fun processPointerCancelAction(action: InputSource.Action, inputSourceType: InputSourceType?, id: String?, index: Int): ActionObject {
|
|
82
|
+
return ActionObject(id, inputSourceType, action.type, index)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Follows the 'process pointer move action' algorithm in 17.3
|
|
87
|
+
* @param action Action being processed
|
|
88
|
+
* @param inputSourceType Source type
|
|
89
|
+
* @param id ID of input source that it's part of
|
|
90
|
+
* @param index Index within the 'actions' array
|
|
91
|
+
* @return Processed action object
|
|
92
|
+
* @throws InvalidArgumentException If failed to process, throw this. Means that args are bad.
|
|
93
|
+
*/
|
|
94
|
+
@Throws(InvalidArgumentException::class)
|
|
95
|
+
fun processPointerMoveAction(action: InputSource.Action, inputSourceType: InputSourceType?, id: String?, index: Int): ActionObject {
|
|
96
|
+
val actionObject = ActionObject(id, inputSourceType, action.type, index)
|
|
97
|
+
|
|
98
|
+
// 1-3 Add the duration
|
|
99
|
+
val duration = action.duration
|
|
100
|
+
assertNullOrPositive(index, id, "duration", duration)
|
|
101
|
+
actionObject.duration = duration
|
|
102
|
+
|
|
103
|
+
// 4-7 Add the origin
|
|
104
|
+
actionObject.origin = action.origin
|
|
105
|
+
|
|
106
|
+
// 8-10 Add the X coordinate
|
|
107
|
+
val x = action.x
|
|
108
|
+
actionObject.x = x
|
|
109
|
+
|
|
110
|
+
// 11-14 Add the Y coordinate
|
|
111
|
+
val y = action.y
|
|
112
|
+
actionObject.y = y
|
|
113
|
+
return actionObject
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
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.processor
|
|
17
|
+
|
|
18
|
+
import io.appium.espressoserver.lib.handlers.exceptions.InvalidArgumentException
|
|
19
|
+
|
|
20
|
+
fun isNullOrPositive(num: Float?): Boolean {
|
|
21
|
+
return num == null || num >= 0
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@Throws(InvalidArgumentException::class)
|
|
25
|
+
fun throwArgException(index: Int, id: String?, message: String?) {
|
|
26
|
+
throw InvalidArgumentException("action in actions[$index] of action input source with id '$id' $message")
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Throws(InvalidArgumentException::class)
|
|
30
|
+
fun assertNullOrPositive(index: Int, id: String?, propertyName: String?, propertyValue: Float?) {
|
|
31
|
+
if (!isNullOrPositive(propertyValue)) {
|
|
32
|
+
throwArgException(index, id,
|
|
33
|
+
"must have property '$propertyName' be greater than or equal to 0 or undefined. Found $propertyValue")
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
package io.appium.espressoserver.lib.helpers.w3c.state
|
|
2
|
+
|
|
3
|
+
import io.appium.espressoserver.lib.handlers.exceptions.InvalidArgumentException
|
|
4
|
+
import io.appium.espressoserver.lib.helpers.w3c.models.InputSource
|
|
5
|
+
import java.util.*
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Active Input Source defined in W3C spec
|
|
9
|
+
*
|
|
10
|
+
* (see https://www.w3.org/TR/webdriver/#terminology-0)
|
|
11
|
+
*/
|
|
12
|
+
class ActiveInputSources {
|
|
13
|
+
private val inputSources: MutableMap<String?, InputSource> = WeakHashMap()
|
|
14
|
+
|
|
15
|
+
@Throws(InvalidArgumentException::class)
|
|
16
|
+
fun addInputSource(inputSource: InputSource) {
|
|
17
|
+
inputSources[inputSource.id] = inputSource
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Remove an input source and also remove it from InputStateTable
|
|
22
|
+
* @param inputSource Source to remove
|
|
23
|
+
*/
|
|
24
|
+
fun removeInputSource(inputSource: InputSource) {
|
|
25
|
+
removeInputSource(inputSource.id)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
fun removeInputSource(id: String?) {
|
|
29
|
+
inputSources.remove(id)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
fun getInputSource(inputSource: InputSource): InputSource? {
|
|
33
|
+
return inputSources[inputSource.id]
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
fun getInputSource(id: String?): InputSource? {
|
|
37
|
+
return inputSources[id]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
fun hasInputSource(id: String?): Boolean {
|
|
41
|
+
return inputSources.containsKey(id)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
companion object {
|
|
45
|
+
private val activeInputSources: MutableMap<String, ActiveInputSources> = WeakHashMap()
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Get the `active input sources` table for a session
|
|
49
|
+
*
|
|
50
|
+
* @return Global instance of ActiveInputSources
|
|
51
|
+
*/
|
|
52
|
+
@Synchronized
|
|
53
|
+
fun getActiveInputSourcesForSession(sessionId: String): ActiveInputSources {
|
|
54
|
+
var globalInputStateTable = activeInputSources[sessionId]
|
|
55
|
+
if (globalInputStateTable == null) {
|
|
56
|
+
activeInputSources[sessionId] = ActiveInputSources()
|
|
57
|
+
globalInputStateTable = activeInputSources[sessionId]
|
|
58
|
+
}
|
|
59
|
+
return globalInputStateTable!!
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
package io.appium.espressoserver.lib.helpers.w3c.state
|
|
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.models.ActionObject
|
|
6
|
+
import io.appium.espressoserver.lib.helpers.w3c.models.InputSource.InputSourceType
|
|
7
|
+
import java.util.*
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Keep the state of all active input sources
|
|
11
|
+
*
|
|
12
|
+
* (defined in 17.1 of spec)
|
|
13
|
+
*/
|
|
14
|
+
class InputStateTable {
|
|
15
|
+
private val stateTable: MutableMap<String, InputState> = HashMap()
|
|
16
|
+
val cancelList: MutableList<ActionObject> = ArrayList()
|
|
17
|
+
fun addInputState(id: String, inputState: InputState) {
|
|
18
|
+
stateTable[id] = inputState
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
fun getInputState(id: String): InputState? {
|
|
22
|
+
return stateTable[id]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
fun getOrCreateInputState(sourceId: String, actionObject: ActionObject): InputState? {
|
|
26
|
+
if (!hasInputState(sourceId)) {
|
|
27
|
+
val newInputState: InputState? = when (actionObject.type) {
|
|
28
|
+
InputSourceType.KEY -> KeyInputState()
|
|
29
|
+
InputSourceType.POINTER -> PointerInputState(actionObject.pointer)
|
|
30
|
+
else -> null
|
|
31
|
+
}
|
|
32
|
+
newInputState?.let {
|
|
33
|
+
addInputState(sourceId, it)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return stateTable[sourceId]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
fun hasInputState(id: String): Boolean {
|
|
40
|
+
return stateTable.containsKey(id)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
fun addActionToCancel(actionObject: ActionObject) {
|
|
44
|
+
cancelList.add(actionObject)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
val globalKeyInputState: KeyInputState
|
|
48
|
+
get() {
|
|
49
|
+
val keyInputStates: MutableList<KeyInputState> = ArrayList()
|
|
50
|
+
for ((_, inputState) in stateTable) {
|
|
51
|
+
if (inputState is KeyInputState) {
|
|
52
|
+
keyInputStates.add(inputState)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return getGlobalKeyState(keyInputStates)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Do the release actions to undo everything
|
|
60
|
+
* @param adapter W3C Action adapter
|
|
61
|
+
* @param timeAtBeginningOfTick When did the tick begin
|
|
62
|
+
* @throws AppiumException
|
|
63
|
+
*/
|
|
64
|
+
@Throws(AppiumException::class)
|
|
65
|
+
fun undoAll(adapter: W3CActionAdapter, timeAtBeginningOfTick: Long) {
|
|
66
|
+
// 2-3: Dispatch tick actions with arguments undo actions and duration 0 in reverse order
|
|
67
|
+
cancelList.reverse()
|
|
68
|
+
for (actionObject in cancelList) {
|
|
69
|
+
actionObject.dispatch(adapter, this, 0f, timeAtBeginningOfTick)
|
|
70
|
+
}
|
|
71
|
+
adapter.sychronousTickActionsComplete()
|
|
72
|
+
|
|
73
|
+
// Clear the cancel list now that the Undo operations are all fulfilled
|
|
74
|
+
cancelList.clear()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
companion object {
|
|
78
|
+
private val inputStateTables: MutableMap<String, InputStateTable> = HashMap()
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Get the global input states for a given session
|
|
82
|
+
* @param sessionId ID of the session
|
|
83
|
+
* @return
|
|
84
|
+
*/
|
|
85
|
+
@Synchronized
|
|
86
|
+
fun getInputStateTableOfSession(sessionId: String): InputStateTable {
|
|
87
|
+
var globalInputStateTable = inputStateTables[sessionId]
|
|
88
|
+
if (globalInputStateTable == null) {
|
|
89
|
+
inputStateTables[sessionId] = InputStateTable()
|
|
90
|
+
globalInputStateTable = inputStateTables[sessionId]
|
|
91
|
+
}
|
|
92
|
+
return globalInputStateTable!!
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
package io.appium.espressoserver.lib.helpers.w3c.state
|
|
2
|
+
|
|
3
|
+
import android.view.KeyEvent
|
|
4
|
+
import java.util.*
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Implement 'calculated global key state' in spec 17.2
|
|
8
|
+
*/
|
|
9
|
+
fun getGlobalKeyState(keyInputStates: List<KeyInputState>): KeyInputState {
|
|
10
|
+
var isAlt = false
|
|
11
|
+
var isShift = false
|
|
12
|
+
var isCtrl = false
|
|
13
|
+
var isMeta = false
|
|
14
|
+
val outputState = KeyInputState()
|
|
15
|
+
for (keyInputState in keyInputStates) {
|
|
16
|
+
if (keyInputState.isAlt) {
|
|
17
|
+
isAlt = true
|
|
18
|
+
}
|
|
19
|
+
if (keyInputState.isShift) {
|
|
20
|
+
isShift = true
|
|
21
|
+
}
|
|
22
|
+
if (keyInputState.isCtrl) {
|
|
23
|
+
isCtrl = true
|
|
24
|
+
}
|
|
25
|
+
if (keyInputState.isMeta) {
|
|
26
|
+
isMeta = true
|
|
27
|
+
}
|
|
28
|
+
for (key in keyInputState.pressed) {
|
|
29
|
+
outputState.addPressed(key)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
outputState.isAlt = isAlt
|
|
33
|
+
outputState.isShift = isShift
|
|
34
|
+
outputState.isCtrl = isCtrl
|
|
35
|
+
outputState.isMeta = isMeta
|
|
36
|
+
return outputState
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Key input state specified in 17.2 of spec
|
|
41
|
+
*
|
|
42
|
+
* https://www.w3.org/TR/webdriver/#input-source-state
|
|
43
|
+
*/
|
|
44
|
+
class KeyInputState : InputState {
|
|
45
|
+
val pressed: MutableSet<String> = HashSet()
|
|
46
|
+
var isAlt = false
|
|
47
|
+
var isShift = false
|
|
48
|
+
var isCtrl = false
|
|
49
|
+
var isMeta = false
|
|
50
|
+
fun isPressed(key: String): Boolean {
|
|
51
|
+
return pressed.contains(key)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
fun addPressed(key: String) {
|
|
55
|
+
pressed.add(key)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
fun removePressed(key: String) {
|
|
59
|
+
pressed.remove(key)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
fun logMessage(): String {
|
|
63
|
+
return "alt=[$isAlt] shift=[$isShift] ctrl=[$isCtrl] meta=[$isMeta] pressed=[$pressed]"
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
fun toMetaState(): Int {
|
|
67
|
+
var metaState = 0
|
|
68
|
+
if (isAlt) {
|
|
69
|
+
metaState = metaState or KeyEvent.META_ALT_MASK
|
|
70
|
+
}
|
|
71
|
+
if (isCtrl) {
|
|
72
|
+
metaState = metaState or KeyEvent.META_CTRL_MASK
|
|
73
|
+
}
|
|
74
|
+
if (isShift) {
|
|
75
|
+
metaState = metaState or KeyEvent.META_SHIFT_MASK
|
|
76
|
+
}
|
|
77
|
+
if (isMeta) {
|
|
78
|
+
metaState = metaState or KeyEvent.META_META_MASK
|
|
79
|
+
}
|
|
80
|
+
return metaState
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
package io.appium.espressoserver.lib.helpers.w3c.state
|
|
2
|
+
|
|
3
|
+
import io.appium.espressoserver.lib.helpers.w3c.models.InputSource
|
|
4
|
+
import java.util.*
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Pointer input state specified in 17.2 of spec
|
|
8
|
+
*
|
|
9
|
+
* https://www.w3.org/TR/webdriver/#input-source-state
|
|
10
|
+
*/
|
|
11
|
+
class PointerInputState : InputState {
|
|
12
|
+
private val pressed: MutableSet<Int> = HashSet()
|
|
13
|
+
var x = 0f
|
|
14
|
+
var y = 0f
|
|
15
|
+
var type: InputSource.PointerType? = null
|
|
16
|
+
get() { return field ?: InputSource.PointerType.TOUCH }
|
|
17
|
+
|
|
18
|
+
@Suppress("ConvertSecondaryConstructorToPrimary")
|
|
19
|
+
constructor(type: InputSource.PointerType?) {
|
|
20
|
+
this.type = type
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
fun isPressed(num: Int): Boolean {
|
|
24
|
+
return pressed.contains(num)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
fun addPressed(num: Int) {
|
|
28
|
+
pressed.add(num)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
fun removePressed(num: Int) {
|
|
32
|
+
pressed.remove(num)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
val buttons: Set<Int>
|
|
36
|
+
get() = pressed
|
|
37
|
+
|
|
38
|
+
fun hasPressedButtons(): Boolean {
|
|
39
|
+
return pressed.isNotEmpty()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
fun logMessage(): String {
|
|
43
|
+
return "pointer-type=[$type] x=[$x] y=[$y] pressed=[$pressed]"
|
|
44
|
+
}
|
|
45
|
+
}
|