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,336 @@
|
|
|
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
|
|
18
|
+
|
|
19
|
+
import android.content.ComponentName
|
|
20
|
+
import android.content.Context
|
|
21
|
+
import android.content.Intent
|
|
22
|
+
import android.net.Uri
|
|
23
|
+
import kotlin.reflect.KClass
|
|
24
|
+
import kotlin.reflect.full.cast
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
private fun Intent.addFlags(flags: String) {
|
|
28
|
+
for (flagStr in flags.split(",")) {
|
|
29
|
+
@Suppress("DEPRECATION")
|
|
30
|
+
when (flagStr.trim().toUpperCase()) {
|
|
31
|
+
"FLAG_GRANT_READ_URI_PERMISSION", "GRANT_READ_URI_PERMISSION" ->
|
|
32
|
+
this.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION)
|
|
33
|
+
"FLAG_GRANT_WRITE_URI_PERMISSION", "GRANT_WRITE_URI_PERMISSION" ->
|
|
34
|
+
this.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION)
|
|
35
|
+
"FLAG_EXCLUDE_STOPPED_PACKAGES", "EXCLUDE_STOPPED_PACKAGES" ->
|
|
36
|
+
this.addFlags(Intent.FLAG_EXCLUDE_STOPPED_PACKAGES)
|
|
37
|
+
"FLAG_INCLUDE_STOPPED_PACKAGES", "INCLUDE_STOPPED_PACKAGES" ->
|
|
38
|
+
this.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES)
|
|
39
|
+
"FLAG_DEBUG_LOG_RESOLUTION", "DEBUG_LOG_RESOLUTION" ->
|
|
40
|
+
this.addFlags(Intent.FLAG_DEBUG_LOG_RESOLUTION)
|
|
41
|
+
"FLAG_ACTIVITY_BROUGHT_TO_FRONT", "ACTIVITY_BROUGHT_TO_FRONT" ->
|
|
42
|
+
this.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT)
|
|
43
|
+
"FLAG_ACTIVITY_CLEAR_TOP", "ACTIVITY_CLEAR_TOP" ->
|
|
44
|
+
this.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
|
45
|
+
"FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET", "ACTIVITY_CLEAR_WHEN_TASK_RESET" ->
|
|
46
|
+
this.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET)
|
|
47
|
+
"FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS", "ACTIVITY_EXCLUDE_FROM_RECENTS" ->
|
|
48
|
+
this.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)
|
|
49
|
+
"FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY", "ACTIVITY_LAUNCHED_FROM_HISTORY" ->
|
|
50
|
+
this.addFlags(Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY)
|
|
51
|
+
"FLAG_ACTIVITY_MULTIPLE_TASK", "ACTIVITY_MULTIPLE_TASK" ->
|
|
52
|
+
this.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK)
|
|
53
|
+
"FLAG_ACTIVITY_NO_ANIMATION", "ACTIVITY_NO_ANIMATION" ->
|
|
54
|
+
this.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
|
|
55
|
+
"FLAG_ACTIVITY_NO_HISTORY", "ACTIVITY_NO_HISTORY" ->
|
|
56
|
+
this.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY)
|
|
57
|
+
"FLAG_ACTIVITY_NO_USER_ACTION", "ACTIVITY_NO_USER_ACTION" ->
|
|
58
|
+
this.addFlags(Intent.FLAG_ACTIVITY_NO_USER_ACTION)
|
|
59
|
+
"FLAG_ACTIVITY_PREVIOUS_IS_TOP", "ACTIVITY_PREVIOUS_IS_TOP" ->
|
|
60
|
+
this.addFlags(Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP)
|
|
61
|
+
"FLAG_ACTIVITY_REORDER_TO_FRONT", "ACTIVITY_REORDER_TO_FRONT" ->
|
|
62
|
+
this.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)
|
|
63
|
+
"FLAG_ACTIVITY_RESET_TASK_IF_NEEDED", "ACTIVITY_RESET_TASK_IF_NEEDED" ->
|
|
64
|
+
this.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED)
|
|
65
|
+
"FLAG_ACTIVITY_SINGLE_TOP", "ACTIVITY_SINGLE_TOP" ->
|
|
66
|
+
this.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)
|
|
67
|
+
"FLAG_ACTIVITY_NEW_TASK", "ACTIVITY_NEW_TASK" ->
|
|
68
|
+
this.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
69
|
+
"FLAG_ACTIVITY_CLEAR_TASK", "ACTIVITY_CLEAR_TASK" ->
|
|
70
|
+
this.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK)
|
|
71
|
+
"FLAG_ACTIVITY_TASK_ON_HOME", "ACTIVITY_TASK_ON_HOME" ->
|
|
72
|
+
this.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME)
|
|
73
|
+
"FLAG_RECEIVER_REGISTERED_ONLY", "RECEIVER_REGISTERED_ONLY" ->
|
|
74
|
+
this.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY)
|
|
75
|
+
"FLAG_RECEIVER_REPLACE_PENDING", "RECEIVER_REPLACE_PENDING" ->
|
|
76
|
+
this.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING)
|
|
77
|
+
else -> throw IllegalArgumentException("The flag '${flagStr.trim()}' is not known")
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
private fun <T : Any> requireType(expectedType: KClass<T>, key: String, value: Any?): T {
|
|
83
|
+
var v = value
|
|
84
|
+
// It might be that GSON serializer converts all ints to long/floats to double by default
|
|
85
|
+
if (expectedType == Int::class && v is Long) {
|
|
86
|
+
v = v.toInt()
|
|
87
|
+
}
|
|
88
|
+
if (expectedType == Float::class && v is Double) {
|
|
89
|
+
v = v.toFloat()
|
|
90
|
+
}
|
|
91
|
+
require(expectedType.isInstance(v)) {
|
|
92
|
+
"The value of '$key' must be of type '${expectedType.simpleName}'. '$value' is given instead"
|
|
93
|
+
}
|
|
94
|
+
return expectedType.cast(v)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private fun requireString(key: String, value: Any?): String = requireType(String::class, key, value)
|
|
98
|
+
private fun requireInt(key: String, value: Any?): Int = requireType(Int::class, key, value)
|
|
99
|
+
private fun requireLong(key: String, value: Any?): Long = requireType(Long::class, key, value)
|
|
100
|
+
private fun requireFloat(key: String, value: Any?): Float = requireType(Float::class, key, value)
|
|
101
|
+
private fun requireBool(key: String, value: Any?): Boolean = requireType(Boolean::class, key, value)
|
|
102
|
+
private fun requireMap(key: String, value: Any?): Map<*, *> = requireType(Map::class, key, value)
|
|
103
|
+
private fun requireList(key: String, value: Any?): List<*> = requireType(List::class, key, value)
|
|
104
|
+
|
|
105
|
+
private fun String.toComponentName(): ComponentName = ComponentName.unflattenFromString(this)
|
|
106
|
+
?: throw IllegalArgumentException("Bad component name: $this")
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Creates an intent using the given options
|
|
111
|
+
*
|
|
112
|
+
* @param options intent options mapping. The mapping can have the following keys:
|
|
113
|
+
* - `action`: An action name, such as ACTION_VIEW. Application-specific
|
|
114
|
+
* actions should be prefixed with the vendor's package name.
|
|
115
|
+
* - `data`: Intent data URI, such as content://contacts/people/1
|
|
116
|
+
* - `type`: Intent MIME type, such as image/png
|
|
117
|
+
* - `categories`: One or more comma-separated Intent categories,
|
|
118
|
+
* such as android.intent.category.APP_CONTACTS
|
|
119
|
+
* - `component`: Component name with package name prefix to create an explicit intent,
|
|
120
|
+
* such as com.example.app/.ExampleActivity
|
|
121
|
+
* - `intFlags`: Single string value, which represents intent flags set encoded
|
|
122
|
+
* into an integer. Could also be provided in hexadecimal format, such as 0x0F.
|
|
123
|
+
* See https://developer.android.com/reference/android/content/Intent.html#setFlags(int)
|
|
124
|
+
* for more details.
|
|
125
|
+
* - `flags`: Comma-separated string of intent flag names, such as
|
|
126
|
+
* 'FLAG_GRANT_READ_URI_PERMISSION, ACTIVITY_CLEAR_TASK' (the 'FLAG_' prefix
|
|
127
|
+
* could be omitted).
|
|
128
|
+
* - `className`: The name of a class inside of the application package
|
|
129
|
+
* that will be used as the component for this Intent.
|
|
130
|
+
* - `e`, `es`: String data as key-value pairs stored in a map with
|
|
131
|
+
* keys and values of type string->string, such as {'foo': 'bar'}
|
|
132
|
+
* - `esn`: null-data, where the key name is only needed, such as ['foo', 'bar']
|
|
133
|
+
* - `ez`: Boolean data as key-value pairs stored in a map with
|
|
134
|
+
* keys and values of type string->boolean, such as {'foo': true, 'bar': false}
|
|
135
|
+
* - `ei`: Integer data as key-value pairs stored in a map with
|
|
136
|
+
* keys and values of type string->integer, such as {'foo': 1, 'bar': 2}
|
|
137
|
+
* - `el`: Long integer data as key-value pairs stored in a map with
|
|
138
|
+
* keys and values of type string->long, such as {'foo': 1L, 'bar': 2L}
|
|
139
|
+
* - `ef`: Float data as key-value pairs stored in a map with
|
|
140
|
+
* keys and values of type string->float, such as {'foo': 1.ff, 'bar': 2.2f}
|
|
141
|
+
* - `eu`: URI data as key-value pairs stored in a map with
|
|
142
|
+
* keys and values of type string->string, such as {'foo': 'content://contacts/people/1'}
|
|
143
|
+
* - `ecn`: Component name data as key-value pairs stored in a map with
|
|
144
|
+
* keys and values of type string->string, such as {'foo': 'com.example.app/.ExampleActivity'}
|
|
145
|
+
* - `eia`: Array of integers data as key-value pairs stored in a map with
|
|
146
|
+
* keys and values of type string->string, such as {'foo': '1,2,3,4'}
|
|
147
|
+
* - `ela`: Array of long data as key-value pairs stored in a map with
|
|
148
|
+
* keys and values of type string->string, such as {'foo': '1L,2L,3L,4L'}
|
|
149
|
+
* - `efa`: Array of float data as key-value pairs stored in a map with
|
|
150
|
+
* keys and values of type string->string, such as {'foo': '1.1,2.2,3.2,4.4'}
|
|
151
|
+
* @return The created intent
|
|
152
|
+
* @throws IllegalArgumentException if required options are missing or
|
|
153
|
+
* there is an issue with mapping value format
|
|
154
|
+
*/
|
|
155
|
+
fun makeIntent(context: Context?, options: Map<String, Any?>): Intent {
|
|
156
|
+
val intent = Intent()
|
|
157
|
+
var hasIntentInfo = false
|
|
158
|
+
var data: Uri? = null
|
|
159
|
+
var type: String? = null
|
|
160
|
+
|
|
161
|
+
val handlersMapping = mapOf<String, (key: String, value: Any?) -> Unit>(
|
|
162
|
+
"action" to fun(key, value) {
|
|
163
|
+
intent.action = requireString(key, value)
|
|
164
|
+
hasIntentInfo = true
|
|
165
|
+
},
|
|
166
|
+
"data" to fun(key, value) {
|
|
167
|
+
data = Uri.parse(requireString(key, value))
|
|
168
|
+
hasIntentInfo = true
|
|
169
|
+
},
|
|
170
|
+
"type" to fun(key, value) {
|
|
171
|
+
type = requireString(key, value)
|
|
172
|
+
hasIntentInfo = true
|
|
173
|
+
},
|
|
174
|
+
"categories" to fun(key, value) {
|
|
175
|
+
requireString(key, value).split(",")
|
|
176
|
+
.forEach { intent.addCategory(it.trim()) }
|
|
177
|
+
hasIntentInfo = true
|
|
178
|
+
},
|
|
179
|
+
"className" to fun(key, value) {
|
|
180
|
+
intent.setClassName(context!!, requireString(key, value))
|
|
181
|
+
},
|
|
182
|
+
"component" to fun(key, value) {
|
|
183
|
+
intent.component = requireString(key, value).toComponentName()
|
|
184
|
+
hasIntentInfo = true
|
|
185
|
+
},
|
|
186
|
+
"intFlags" to fun(key, value) {
|
|
187
|
+
intent.flags = Integer.decode(requireString(key, value)).toInt()
|
|
188
|
+
},
|
|
189
|
+
"flags" to fun(key, value) {
|
|
190
|
+
intent.addFlags(requireString(key, value))
|
|
191
|
+
},
|
|
192
|
+
"e" to fun(key, value) {
|
|
193
|
+
requireMap(key, value)
|
|
194
|
+
.filter { it.key is String }
|
|
195
|
+
.forEach {
|
|
196
|
+
intent.putExtra(it.key as String, requireString(it.key as String, it.value))
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
"es" to fun(key, value) {
|
|
200
|
+
requireMap(key, value)
|
|
201
|
+
.filter { it.key is String }
|
|
202
|
+
.forEach {
|
|
203
|
+
intent.putExtra(it.key as String, requireString(it.key as String, it.value))
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
"esn" to fun(key, value) {
|
|
207
|
+
requireList(key, value)
|
|
208
|
+
.filterIsInstance<String>()
|
|
209
|
+
.forEach { intent.putExtra(it, null as String?) }
|
|
210
|
+
},
|
|
211
|
+
"ei" to fun(key, value) {
|
|
212
|
+
requireMap(key, value)
|
|
213
|
+
.filter { it.key is String }
|
|
214
|
+
.forEach {
|
|
215
|
+
intent.putExtra(it.key as String, requireInt(it.key as String, it.value))
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
"eu" to fun(key, value) {
|
|
219
|
+
requireMap(key, value)
|
|
220
|
+
.filter { it.key is String }
|
|
221
|
+
.forEach {
|
|
222
|
+
intent.putExtra(it.key as String, Uri.parse(requireString(it.key as String, it.value)))
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
"el" to fun(key, value) {
|
|
226
|
+
requireMap(key, value)
|
|
227
|
+
.filter { it.key is String }
|
|
228
|
+
.forEach {
|
|
229
|
+
intent.putExtra(it.key as String, requireLong(it.key as String, it.value))
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
"ef" to fun(key, value) {
|
|
233
|
+
requireMap(key, value)
|
|
234
|
+
.filter { it.key is String }
|
|
235
|
+
.forEach {
|
|
236
|
+
intent.putExtra(it.key as String, requireFloat(it.key as String, it.value))
|
|
237
|
+
}
|
|
238
|
+
},
|
|
239
|
+
"ez" to fun(key, value) {
|
|
240
|
+
requireMap(key, value)
|
|
241
|
+
.filter { it.key is String }
|
|
242
|
+
.forEach {
|
|
243
|
+
intent.putExtra(it.key as String, requireBool(it.key as String, it.value))
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
"eia" to fun(key, value) {
|
|
247
|
+
requireMap(key, value)
|
|
248
|
+
.filter { it.key is String }
|
|
249
|
+
.forEach { entry ->
|
|
250
|
+
requireString(entry.key as String, entry.value)
|
|
251
|
+
.split(",")
|
|
252
|
+
.map {
|
|
253
|
+
try {
|
|
254
|
+
it.trim().toInt()
|
|
255
|
+
} catch (e: NumberFormatException) {
|
|
256
|
+
throw IllegalArgumentException(
|
|
257
|
+
"The value of '${entry.key}' is expected " +
|
|
258
|
+
"to be a comma-separated list of integers. " +
|
|
259
|
+
"'${entry.value}' is given instead", e)
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
.toIntArray()
|
|
263
|
+
.let { intent.putExtra(entry.key as String, it) }
|
|
264
|
+
}
|
|
265
|
+
},
|
|
266
|
+
"ela" to fun(key, value) {
|
|
267
|
+
requireMap(key, value)
|
|
268
|
+
.filter { it.key is String }
|
|
269
|
+
.forEach { entry ->
|
|
270
|
+
requireString(entry.key as String, entry.value)
|
|
271
|
+
.split(",")
|
|
272
|
+
.map {
|
|
273
|
+
try {
|
|
274
|
+
it.trim().toLong()
|
|
275
|
+
} catch (e: NumberFormatException) {
|
|
276
|
+
throw IllegalArgumentException(
|
|
277
|
+
"The value of '${entry.key}' is expected " +
|
|
278
|
+
"to be a comma-separated list of long integers. " +
|
|
279
|
+
"'${entry.value}' is given instead", e)
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
.toLongArray()
|
|
283
|
+
.let { intent.putExtra(entry.key as String, it) }
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
"efa" to fun(key, value) {
|
|
287
|
+
requireMap(key, value)
|
|
288
|
+
.filter { it.key is String }
|
|
289
|
+
.forEach { entry ->
|
|
290
|
+
requireString(entry.key as String, entry.value)
|
|
291
|
+
.split(",")
|
|
292
|
+
.map {
|
|
293
|
+
try {
|
|
294
|
+
it.trim().toFloat()
|
|
295
|
+
} catch (e: NumberFormatException) {
|
|
296
|
+
throw IllegalArgumentException(
|
|
297
|
+
"The value of '${entry.key}' is expected " +
|
|
298
|
+
"to be a comma-separated list of float numbers. " +
|
|
299
|
+
"'${entry.value}' is given instead", e)
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
.toFloatArray()
|
|
303
|
+
.let { intent.putExtra(entry.key as String, it) }
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
"ecn" to fun(key, value) {
|
|
307
|
+
requireMap(key, value)
|
|
308
|
+
.filter { it.key is String }
|
|
309
|
+
.forEach {
|
|
310
|
+
intent.putExtra(it.key as String,
|
|
311
|
+
requireString(it.key as String, it.value).toComponentName())
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
)
|
|
315
|
+
|
|
316
|
+
for ((optName, optValue) in options) {
|
|
317
|
+
val handler = handlersMapping[optName]
|
|
318
|
+
?: throw IllegalArgumentException("The option named '$optName' is not known. " +
|
|
319
|
+
"Only the following options are supported: ${handlersMapping.keys}")
|
|
320
|
+
handler(optName, optValue)
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
intent.setDataAndType(data, type)
|
|
324
|
+
|
|
325
|
+
require(hasIntentInfo) { "Either intent action, data, type or categories must be supplied" }
|
|
326
|
+
return intent
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
fun extractQualifiedClassName(pkg: String, fullName: String): String {
|
|
330
|
+
var className = fullName
|
|
331
|
+
val slashPos = className.indexOf("/")
|
|
332
|
+
if (slashPos >= 0 && className.length > slashPos) {
|
|
333
|
+
className = className.substring(slashPos + 1)
|
|
334
|
+
}
|
|
335
|
+
return if (className.startsWith(".")) "${pkg}${className}" else className
|
|
336
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
|
18
|
+
|
|
19
|
+
import android.app.UiAutomation
|
|
20
|
+
import androidx.test.platform.app.InstrumentationRegistry
|
|
21
|
+
import androidx.test.uiautomator.UiDevice
|
|
22
|
+
import io.appium.espressoserver.lib.helpers.ReflectionUtils.extractMethod
|
|
23
|
+
import io.appium.espressoserver.lib.helpers.ReflectionUtils.invokeMethod
|
|
24
|
+
|
|
25
|
+
object InteractionHelper {
|
|
26
|
+
private var uiDevice: UiDevice? = null
|
|
27
|
+
|
|
28
|
+
@Synchronized
|
|
29
|
+
fun getUiDevice(): UiDevice {
|
|
30
|
+
if (uiDevice == null) {
|
|
31
|
+
uiDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
|
32
|
+
}
|
|
33
|
+
return uiDevice!!
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
fun getUiAutomation(): UiAutomation {
|
|
37
|
+
val getUiAutomation = extractMethod(UiDevice::class.java, "getUiAutomation")
|
|
38
|
+
return invokeMethod(getUiDevice(), getUiAutomation) as UiAutomation
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
package io.appium.espressoserver.lib.helpers;
|
|
2
|
+
|
|
3
|
+
import java.lang.reflect.Method;
|
|
4
|
+
import java.util.Arrays;
|
|
5
|
+
import java.util.concurrent.Executor;
|
|
6
|
+
import java.util.concurrent.atomic.AtomicReference;
|
|
7
|
+
|
|
8
|
+
import androidx.annotation.NonNull;
|
|
9
|
+
import androidx.annotation.VisibleForTesting;
|
|
10
|
+
import androidx.test.platform.app.InstrumentationRegistry;
|
|
11
|
+
import io.appium.espressoserver.lib.handlers.exceptions.AppiumException;
|
|
12
|
+
|
|
13
|
+
//https://github.com/calabash/calabash-android-server/blob/develop/server/app/src/androidTest/java/sh/calaba/instrumentationbackend/query/InvocationOperation.java
|
|
14
|
+
|
|
15
|
+
public class InvocationOperation {
|
|
16
|
+
public static final String VOID = "<VOID>";
|
|
17
|
+
private final String methodName;
|
|
18
|
+
private final Class<?>[] argumentTypes;
|
|
19
|
+
private final Object[] argumentValues;
|
|
20
|
+
private final Executor executor;
|
|
21
|
+
|
|
22
|
+
public InvocationOperation(String methodName, Object[] argumentValues, Class<?>[] argumentTypes) {
|
|
23
|
+
this(methodName, argumentValues, argumentTypes, new Executor() {
|
|
24
|
+
@Override
|
|
25
|
+
public void execute(@NonNull Runnable runnable) {
|
|
26
|
+
InstrumentationRegistry.getInstrumentation().runOnMainSync(runnable);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@VisibleForTesting
|
|
32
|
+
public InvocationOperation(String methodName, Object[] argumentValues, Class<?>[] argumentTypes, Executor executor) {
|
|
33
|
+
this.methodName = methodName;
|
|
34
|
+
this.argumentValues = argumentValues;
|
|
35
|
+
this.argumentTypes = argumentTypes;
|
|
36
|
+
this.executor = executor;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
public Object apply(final Object applyOn) throws Exception {
|
|
41
|
+
final AtomicReference<Object> ref = new AtomicReference<>();
|
|
42
|
+
final AtomicReference<Exception> refEx = new AtomicReference<>();
|
|
43
|
+
final Method method = findCompatibleMethod(applyOn);
|
|
44
|
+
executor.execute(new Runnable() {
|
|
45
|
+
@Override
|
|
46
|
+
public void run() {
|
|
47
|
+
Object result;
|
|
48
|
+
try {
|
|
49
|
+
result = method.invoke(applyOn, argumentValues);
|
|
50
|
+
if (method.getReturnType().equals(Void.TYPE)) {
|
|
51
|
+
result = VOID;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
ref.set(result);
|
|
55
|
+
} catch (Exception e) {
|
|
56
|
+
e.printStackTrace();
|
|
57
|
+
refEx.set(e);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
if (refEx.get() != null) {
|
|
63
|
+
throw refEx.get();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return ref.get();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
private Method findCompatibleMethod(Object target) throws AppiumException {
|
|
70
|
+
try {
|
|
71
|
+
Method result = target.getClass().getMethod(methodName, argumentTypes);
|
|
72
|
+
result.setAccessible(true);
|
|
73
|
+
return result;
|
|
74
|
+
} catch (NoSuchMethodException e) {
|
|
75
|
+
throw new AppiumException(String.format
|
|
76
|
+
("No public method '%s' is defined on %s or its parents which takes %s arguments", methodName,
|
|
77
|
+
target.getClass(), Arrays.toString(argumentTypes)), e);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
|
18
|
+
|
|
19
|
+
import android.content.Context
|
|
20
|
+
import android.os.Build
|
|
21
|
+
import android.os.Build.VERSION.SDK_INT
|
|
22
|
+
import android.os.LocaleList
|
|
23
|
+
import java.util.*
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
fun changeLocale(context: Context, locale: Locale) {
|
|
27
|
+
val res = context.applicationContext.resources
|
|
28
|
+
val config = res.configuration
|
|
29
|
+
|
|
30
|
+
Locale.setDefault(locale)
|
|
31
|
+
if (SDK_INT >= Build.VERSION_CODES.O) {
|
|
32
|
+
Locale.setDefault(Locale.Category.DISPLAY, locale)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (SDK_INT >= Build.VERSION_CODES.N) {
|
|
36
|
+
val localeList = LocaleList(locale)
|
|
37
|
+
LocaleList.setDefault(localeList)
|
|
38
|
+
config.setLocales(localeList)
|
|
39
|
+
context.createConfigurationContext(config)
|
|
40
|
+
} else {
|
|
41
|
+
config.setLocale(locale)
|
|
42
|
+
config.setLayoutDirection(locale)
|
|
43
|
+
@Suppress("DEPRECATION")
|
|
44
|
+
res.updateConfiguration(config, res.displayMetrics)
|
|
45
|
+
}
|
|
46
|
+
}
|
package/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/helpers/Logger.kt
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
* you may not use this file except in compliance with the License.
|
|
4
|
+
* See the NOTICE file distributed with this work for additional
|
|
5
|
+
* information regarding copyright ownership.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
package io.appium.espressoserver.lib.helpers
|
|
18
|
+
|
|
19
|
+
interface Logger {
|
|
20
|
+
fun error(vararg messages: Any)
|
|
21
|
+
fun error(message: String, throwable: Throwable)
|
|
22
|
+
fun info(vararg messages: Any)
|
|
23
|
+
fun debug(vararg messages: Any)
|
|
24
|
+
fun warn(vararg messages: Any)
|
|
25
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
|
18
|
+
|
|
19
|
+
import android.app.UiAutomation.OnAccessibilityEventListener
|
|
20
|
+
import android.view.accessibility.AccessibilityEvent
|
|
21
|
+
import io.appium.espressoserver.lib.helpers.extensions.withPermit
|
|
22
|
+
import java.util.*
|
|
23
|
+
import java.util.concurrent.Semaphore
|
|
24
|
+
|
|
25
|
+
const val TOAST_CLEAR_TIMEOUT_MS = 3500L
|
|
26
|
+
|
|
27
|
+
object NotificationListener : OnAccessibilityEventListener {
|
|
28
|
+
private var recentToastTimestamp = 0L
|
|
29
|
+
@Suppress("ObjectPropertyName")
|
|
30
|
+
private val _toastMessage = mutableListOf<CharSequence>()
|
|
31
|
+
private var originalListener: OnAccessibilityEventListener? = null
|
|
32
|
+
private val TOAST_MESSAGE_GUARD = Semaphore(1)
|
|
33
|
+
|
|
34
|
+
@Volatile
|
|
35
|
+
var isListening = false
|
|
36
|
+
private set
|
|
37
|
+
|
|
38
|
+
fun start() {
|
|
39
|
+
if (isListening) {
|
|
40
|
+
AndroidLogger.debug("Toast notification listener is already started")
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
AndroidLogger.debug("Starting toast notification listener")
|
|
44
|
+
originalListener = UiAutomationWrapper.onAccessibilityEventListener
|
|
45
|
+
isListening = true
|
|
46
|
+
AndroidLogger.debug("Original listener: $originalListener")
|
|
47
|
+
UiAutomationWrapper.onAccessibilityEventListener = this
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
fun stop() {
|
|
51
|
+
if (!isListening) {
|
|
52
|
+
AndroidLogger.debug("Toast notification listener is already stopped")
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
AndroidLogger.debug("Stopping toast notification listener")
|
|
56
|
+
isListening = false
|
|
57
|
+
UiAutomationWrapper.onAccessibilityEventListener = originalListener
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@Synchronized
|
|
61
|
+
override fun onAccessibilityEvent(event: AccessibilityEvent) {
|
|
62
|
+
if (event.eventType == AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED) {
|
|
63
|
+
AndroidLogger.debug("Caught toast message: $event")
|
|
64
|
+
event.text?.let { if (it.isNotEmpty()) toastMessage = it }
|
|
65
|
+
}
|
|
66
|
+
originalListener?.onAccessibilityEvent(event)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
var toastMessage: List<CharSequence>
|
|
70
|
+
get() {
|
|
71
|
+
return TOAST_MESSAGE_GUARD.withPermit {
|
|
72
|
+
if (_toastMessage.isNotEmpty()
|
|
73
|
+
&& System.currentTimeMillis() - recentToastTimestamp > TOAST_CLEAR_TIMEOUT_MS) {
|
|
74
|
+
AndroidLogger.info("Clearing the outdated toast message: $_toastMessage")
|
|
75
|
+
_toastMessage.clear()
|
|
76
|
+
}
|
|
77
|
+
Collections.unmodifiableList(_toastMessage)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
private set(text) {
|
|
81
|
+
TOAST_MESSAGE_GUARD.withPermit {
|
|
82
|
+
_toastMessage.clear()
|
|
83
|
+
_toastMessage.addAll(text)
|
|
84
|
+
recentToastTimestamp = System.currentTimeMillis()
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
package io.appium.espressoserver.lib.helpers
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copies parts of the Android Rect
|
|
5
|
+
*
|
|
6
|
+
* This is copied so that we can run in Java context
|
|
7
|
+
*/
|
|
8
|
+
class Rect(private val left: Int, private val top: Int, private val right: Int, private val bottom: Int) {
|
|
9
|
+
|
|
10
|
+
fun contains(x: Int, y: Int): Boolean {
|
|
11
|
+
return (left < right && top < bottom // check for empty first
|
|
12
|
+
&& x >= left && x < right && y >= top && y < bottom)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
override fun toString(): String {
|
|
16
|
+
return "Rect($left, $top, $right, $bottom)"
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
fun toShortString(): String {
|
|
20
|
+
return "Rect[$left, $top, $right, $bottom]"
|
|
21
|
+
}
|
|
22
|
+
}
|