From d77f640867155fddbbbc9575f0a77802602865e7 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Mon, 12 Feb 2024 20:54:55 +0100 Subject: [PATCH 1/2] feat: Remove obsolete MJSONWP touch actions (#847) BREAKING CHANGE: The following REST endpoints have been removed, use W3C actions instead: - /wda/touch/perform - /wda/touch/multi/perform --- WebDriverAgent.xcodeproj/project.pbxproj | 20 - .../XCUIApplication+FBTouchAction.h | 37 -- .../XCUIApplication+FBTouchAction.m | 15 - .../Commands/FBTouchActionCommands.m | 13 - .../Utilities/FBAppiumActionsSynthesizer.h | 20 - .../Utilities/FBAppiumActionsSynthesizer.m | 554 ------------------ ...BAppiumMultiTouchActionsIntegrationTests.m | 206 ------- .../FBAppiumTouchActionsIntegrationTests.m | 404 ------------- 8 files changed, 1269 deletions(-) delete mode 100644 WebDriverAgentLib/Utilities/FBAppiumActionsSynthesizer.h delete mode 100644 WebDriverAgentLib/Utilities/FBAppiumActionsSynthesizer.m delete mode 100644 WebDriverAgentTests/IntegrationTests/FBAppiumMultiTouchActionsIntegrationTests.m delete mode 100644 WebDriverAgentTests/IntegrationTests/FBAppiumTouchActionsIntegrationTests.m diff --git a/WebDriverAgent.xcodeproj/project.pbxproj b/WebDriverAgent.xcodeproj/project.pbxproj index 4c098bde88..bc4f298134 100644 --- a/WebDriverAgent.xcodeproj/project.pbxproj +++ b/WebDriverAgent.xcodeproj/project.pbxproj @@ -49,7 +49,6 @@ 641EE5DA2240C5CA00173FCB /* XCUIApplicationProcessDelay.m in Sources */ = {isa = PBXBuildFile; fileRef = 6385F4A5220A40760095BBDB /* XCUIApplicationProcessDelay.m */; }; 641EE5DB2240C5CA00173FCB /* FBXPath.m in Sources */ = {isa = PBXBuildFile; fileRef = 711084431DA3AA7500F913D6 /* FBXPath.m */; }; 641EE5DC2240C5CA00173FCB /* XCUIApplication+FBAlert.m in Sources */ = {isa = PBXBuildFile; fileRef = 719CD8FB2126C88B00C7D0C2 /* XCUIApplication+FBAlert.m */; }; - 641EE5DD2240C5CA00173FCB /* FBAppiumActionsSynthesizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 71241D771FAE31F100B9559F /* FBAppiumActionsSynthesizer.m */; }; 641EE5DE2240C5CA00173FCB /* XCUIApplication+FBTouchAction.m in Sources */ = {isa = PBXBuildFile; fileRef = 71BD20721F86116100B36EC2 /* XCUIApplication+FBTouchAction.m */; }; 641EE5DF2240C5CA00173FCB /* FBWebServer.m in Sources */ = {isa = PBXBuildFile; fileRef = EE9AB78D1CAEDF0C008C271F /* FBWebServer.m */; }; 641EE5E02240C5CA00173FCB /* FBTCPSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = 715557D2211DBCE700613B26 /* FBTCPSocket.m */; }; @@ -269,7 +268,6 @@ 641EE6D82240C5CA00173FCB /* XCUIElement.h in Headers */ = {isa = PBXBuildFile; fileRef = EE35ACFE1E3B77D600A02D78 /* XCUIElement.h */; settings = {ATTRIBUTES = (Public, ); }; }; 641EE6D92240C5CA00173FCB /* XCKeyboardInputSolver.h in Headers */ = {isa = PBXBuildFile; fileRef = EE35ACBE1E3B77D600A02D78 /* XCKeyboardInputSolver.h */; settings = {ATTRIBUTES = (Public, ); }; }; 641EE6DB2240C5CA00173FCB /* FBPasteboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 71930C4020662E1F00D3AFEC /* FBPasteboard.h */; }; - 641EE6DC2240C5CA00173FCB /* FBAppiumActionsSynthesizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 714097451FAE1B32008FB2C5 /* FBAppiumActionsSynthesizer.h */; }; 641EE6DD2240C5CA00173FCB /* FBDebugLogDelegateDecorator.h in Headers */ = {isa = PBXBuildFile; fileRef = EE7E27181D06C69F001BEC7B /* FBDebugLogDelegateDecorator.h */; settings = {ATTRIBUTES = (Public, ); }; }; 641EE6DE2240C5CA00173FCB /* XCUIDevice+FBHealthCheck.h in Headers */ = {isa = PBXBuildFile; fileRef = EEDFE11F1D9C06F800E6FFE5 /* XCUIDevice+FBHealthCheck.h */; settings = {ATTRIBUTES = (Public, ); }; }; 641EE6DF2240C5CA00173FCB /* FBMjpegServer.h in Headers */ = {isa = PBXBuildFile; fileRef = 7155D701211DCEF400166C20 /* FBMjpegServer.h */; }; @@ -318,7 +316,6 @@ 7119E1EC1E891F8600D0B125 /* FBPickerWheelSelectTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 7119E1EB1E891F8600D0B125 /* FBPickerWheelSelectTests.m */; }; 711CD03425ED1106001C01D2 /* XCUIScreenDataSource-Protocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 711CD03325ED1106001C01D2 /* XCUIScreenDataSource-Protocol.h */; }; 711CD03525ED1106001C01D2 /* XCUIScreenDataSource-Protocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 711CD03325ED1106001C01D2 /* XCUIScreenDataSource-Protocol.h */; }; - 71241D781FAE31F100B9559F /* FBAppiumActionsSynthesizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 71241D771FAE31F100B9559F /* FBAppiumActionsSynthesizer.m */; }; 71241D7B1FAE3D2500B9559F /* FBTouchActionCommands.h in Headers */ = {isa = PBXBuildFile; fileRef = 71241D791FAE3D2500B9559F /* FBTouchActionCommands.h */; }; 71241D7C1FAE3D2500B9559F /* FBTouchActionCommands.m in Sources */ = {isa = PBXBuildFile; fileRef = 71241D7A1FAE3D2500B9559F /* FBTouchActionCommands.m */; }; 71241D7E1FAF084E00B9559F /* FBW3CTouchActionsIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 71241D7D1FAF084E00B9559F /* FBW3CTouchActionsIntegrationTests.m */; }; @@ -336,7 +333,6 @@ 713C6DCF1DDC772A00285B92 /* FBElementUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = 713C6DCD1DDC772A00285B92 /* FBElementUtils.h */; }; 713C6DD01DDC772A00285B92 /* FBElementUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 713C6DCE1DDC772A00285B92 /* FBElementUtils.m */; }; 714097431FAE1B0B008FB2C5 /* FBBaseActionsSynthesizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 714097411FAE1B0B008FB2C5 /* FBBaseActionsSynthesizer.h */; }; - 714097471FAE1B32008FB2C5 /* FBAppiumActionsSynthesizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 714097451FAE1B32008FB2C5 /* FBAppiumActionsSynthesizer.h */; }; 7140974B1FAE1B51008FB2C5 /* FBW3CActionsSynthesizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 714097491FAE1B51008FB2C5 /* FBW3CActionsSynthesizer.h */; }; 7140974C1FAE1B51008FB2C5 /* FBW3CActionsSynthesizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 7140974A1FAE1B51008FB2C5 /* FBW3CActionsSynthesizer.m */; }; 7140974E1FAE20EE008FB2C5 /* FBBaseActionsSynthesizer.m in Sources */ = {isa = PBXBuildFile; fileRef = 7140974D1FAE20EE008FB2C5 /* FBBaseActionsSynthesizer.m */; }; @@ -432,7 +428,6 @@ 71930C4220662E1F00D3AFEC /* FBPasteboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 71930C4020662E1F00D3AFEC /* FBPasteboard.h */; }; 71930C4320662E1F00D3AFEC /* FBPasteboard.m in Sources */ = {isa = PBXBuildFile; fileRef = 71930C4120662E1F00D3AFEC /* FBPasteboard.m */; }; 71930C472066434000D3AFEC /* FBPasteboardTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 71930C462066434000D3AFEC /* FBPasteboardTests.m */; }; - 719A97AC1F88E7370063B4BD /* FBAppiumMultiTouchActionsIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 719A97AB1F88E7370063B4BD /* FBAppiumMultiTouchActionsIntegrationTests.m */; }; 719CD8F82126C78F00C7D0C2 /* FBAlertsMonitor.h in Headers */ = {isa = PBXBuildFile; fileRef = 719CD8F62126C78F00C7D0C2 /* FBAlertsMonitor.h */; }; 719CD8F92126C78F00C7D0C2 /* FBAlertsMonitor.m in Sources */ = {isa = PBXBuildFile; fileRef = 719CD8F72126C78F00C7D0C2 /* FBAlertsMonitor.m */; }; 719CD8FC2126C88B00C7D0C2 /* XCUIApplication+FBAlert.h in Headers */ = {isa = PBXBuildFile; fileRef = 719CD8FA2126C88B00C7D0C2 /* XCUIApplication+FBAlert.h */; }; @@ -464,7 +459,6 @@ 71B49EC81ED1A58100D51AD6 /* XCUIElement+FBUID.m in Sources */ = {isa = PBXBuildFile; fileRef = 71B49EC61ED1A58100D51AD6 /* XCUIElement+FBUID.m */; }; 71BD20731F86116100B36EC2 /* XCUIApplication+FBTouchAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 71BD20711F86116100B36EC2 /* XCUIApplication+FBTouchAction.h */; }; 71BD20741F86116100B36EC2 /* XCUIApplication+FBTouchAction.m in Sources */ = {isa = PBXBuildFile; fileRef = 71BD20721F86116100B36EC2 /* XCUIApplication+FBTouchAction.m */; }; - 71BD20781F869E0F00B36EC2 /* FBAppiumTouchActionsIntegrationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 71BD20771F869E0F00B36EC2 /* FBAppiumTouchActionsIntegrationTests.m */; }; 71C8E55125399A6B008572C1 /* XCUIApplication+FBQuiescence.h in Headers */ = {isa = PBXBuildFile; fileRef = 71C8E54F25399A6B008572C1 /* XCUIApplication+FBQuiescence.h */; }; 71C8E55225399A6B008572C1 /* XCUIApplication+FBQuiescence.h in Headers */ = {isa = PBXBuildFile; fileRef = 71C8E54F25399A6B008572C1 /* XCUIApplication+FBQuiescence.h */; }; 71C8E55325399A6B008572C1 /* XCUIApplication+FBQuiescence.m in Sources */ = {isa = PBXBuildFile; fileRef = 71C8E55025399A6B008572C1 /* XCUIApplication+FBQuiescence.m */; }; @@ -940,7 +934,6 @@ 7119097B2152580600BA3C7E /* XCUIScreen.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XCUIScreen.h; sourceTree = ""; }; 7119E1EB1E891F8600D0B125 /* FBPickerWheelSelectTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBPickerWheelSelectTests.m; sourceTree = ""; }; 711CD03325ED1106001C01D2 /* XCUIScreenDataSource-Protocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "XCUIScreenDataSource-Protocol.h"; sourceTree = ""; }; - 71241D771FAE31F100B9559F /* FBAppiumActionsSynthesizer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBAppiumActionsSynthesizer.m; sourceTree = ""; }; 71241D791FAE3D2500B9559F /* FBTouchActionCommands.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FBTouchActionCommands.h; sourceTree = ""; }; 71241D7A1FAE3D2500B9559F /* FBTouchActionCommands.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBTouchActionCommands.m; sourceTree = ""; }; 71241D7D1FAF084E00B9559F /* FBW3CTouchActionsIntegrationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBW3CTouchActionsIntegrationTests.m; sourceTree = ""; }; @@ -958,7 +951,6 @@ 713C6DCD1DDC772A00285B92 /* FBElementUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBElementUtils.h; sourceTree = ""; }; 713C6DCE1DDC772A00285B92 /* FBElementUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBElementUtils.m; sourceTree = ""; }; 714097411FAE1B0B008FB2C5 /* FBBaseActionsSynthesizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FBBaseActionsSynthesizer.h; sourceTree = ""; }; - 714097451FAE1B32008FB2C5 /* FBAppiumActionsSynthesizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FBAppiumActionsSynthesizer.h; sourceTree = ""; }; 714097491FAE1B51008FB2C5 /* FBW3CActionsSynthesizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FBW3CActionsSynthesizer.h; sourceTree = ""; }; 7140974A1FAE1B51008FB2C5 /* FBW3CActionsSynthesizer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBW3CActionsSynthesizer.m; sourceTree = ""; }; 7140974D1FAE20EE008FB2C5 /* FBBaseActionsSynthesizer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBBaseActionsSynthesizer.m; sourceTree = ""; }; @@ -1018,7 +1010,6 @@ 71930C4020662E1F00D3AFEC /* FBPasteboard.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FBPasteboard.h; sourceTree = ""; }; 71930C4120662E1F00D3AFEC /* FBPasteboard.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBPasteboard.m; sourceTree = ""; }; 71930C462066434000D3AFEC /* FBPasteboardTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBPasteboardTests.m; sourceTree = ""; }; - 719A97AB1F88E7370063B4BD /* FBAppiumMultiTouchActionsIntegrationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBAppiumMultiTouchActionsIntegrationTests.m; sourceTree = ""; }; 719CD8F62126C78F00C7D0C2 /* FBAlertsMonitor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FBAlertsMonitor.h; sourceTree = ""; }; 719CD8F72126C78F00C7D0C2 /* FBAlertsMonitor.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBAlertsMonitor.m; sourceTree = ""; }; 719CD8FA2126C88B00C7D0C2 /* XCUIApplication+FBAlert.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "XCUIApplication+FBAlert.h"; sourceTree = ""; }; @@ -1046,7 +1037,6 @@ 71B49EC61ED1A58100D51AD6 /* XCUIElement+FBUID.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "XCUIElement+FBUID.m"; sourceTree = ""; }; 71BD20711F86116100B36EC2 /* XCUIApplication+FBTouchAction.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "XCUIApplication+FBTouchAction.h"; sourceTree = ""; }; 71BD20721F86116100B36EC2 /* XCUIApplication+FBTouchAction.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "XCUIApplication+FBTouchAction.m"; sourceTree = ""; }; - 71BD20771F869E0F00B36EC2 /* FBAppiumTouchActionsIntegrationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FBAppiumTouchActionsIntegrationTests.m; sourceTree = ""; }; 71C8E54F25399A6B008572C1 /* XCUIApplication+FBQuiescence.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "XCUIApplication+FBQuiescence.h"; sourceTree = ""; }; 71C8E55025399A6B008572C1 /* XCUIApplication+FBQuiescence.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "XCUIApplication+FBQuiescence.m"; sourceTree = ""; }; 71C9EAAA25E8415A00470CD8 /* FBScreenshot.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FBScreenshot.h; sourceTree = ""; }; @@ -1866,8 +1856,6 @@ 13815F6E2328D20400CDAB61 /* FBActiveAppDetectionPoint.m */, 719CD8F62126C78F00C7D0C2 /* FBAlertsMonitor.h */, 719CD8F72126C78F00C7D0C2 /* FBAlertsMonitor.m */, - 714097451FAE1B32008FB2C5 /* FBAppiumActionsSynthesizer.h */, - 71241D771FAE31F100B9559F /* FBAppiumActionsSynthesizer.m */, 714097411FAE1B0B008FB2C5 /* FBBaseActionsSynthesizer.h */, 7140974D1FAE20EE008FB2C5 /* FBBaseActionsSynthesizer.m */, 714EAA0B2673FDFE005C5B47 /* FBCapabilities.h */, @@ -1965,8 +1953,6 @@ isa = PBXGroup; children = ( EE9B76991CF799F400275851 /* FBAlertTests.m */, - 71BD20771F869E0F00B36EC2 /* FBAppiumTouchActionsIntegrationTests.m */, - 719A97AB1F88E7370063B4BD /* FBAppiumMultiTouchActionsIntegrationTests.m */, 719CD8FE2126C90200C7D0C2 /* FBAutoAlertsHandlerTests.m */, EE26409C1D0EBA25009BE6B0 /* FBElementAttributeTests.m */, 71F5BE33252E5B2200EE9EBA /* FBElementSwipingTests.m */, @@ -2439,7 +2425,6 @@ 718226CB2587443700661B83 /* GCDAsyncUdpSocket.h in Headers */, 641EE6DB2240C5CA00173FCB /* FBPasteboard.h in Headers */, 711CD03525ED1106001C01D2 /* XCUIScreenDataSource-Protocol.h in Headers */, - 641EE6DC2240C5CA00173FCB /* FBAppiumActionsSynthesizer.h in Headers */, 641EE6DD2240C5CA00173FCB /* FBDebugLogDelegateDecorator.h in Headers */, 641EE6DE2240C5CA00173FCB /* XCUIDevice+FBHealthCheck.h in Headers */, 641EE6DF2240C5CA00173FCB /* FBMjpegServer.h in Headers */, @@ -2675,7 +2660,6 @@ EE35AD6F1E3B77D600A02D78 /* XCUIElement.h in Headers */, EE35AD2F1E3B77D600A02D78 /* XCKeyboardInputSolver.h in Headers */, 71930C4220662E1F00D3AFEC /* FBPasteboard.h in Headers */, - 714097471FAE1B32008FB2C5 /* FBAppiumActionsSynthesizer.h in Headers */, EE7E271C1D06C69F001BEC7B /* FBDebugLogDelegateDecorator.h in Headers */, EEDFE1211D9C06F800E6FFE5 /* XCUIDevice+FBHealthCheck.h in Headers */, 7155D703211DCEF400166C20 /* FBMjpegServer.h in Headers */, @@ -3066,7 +3050,6 @@ 641EE5DB2240C5CA00173FCB /* FBXPath.m in Sources */, 71C8E55425399A6B008572C1 /* XCUIApplication+FBQuiescence.m in Sources */, 641EE5DC2240C5CA00173FCB /* XCUIApplication+FBAlert.m in Sources */, - 641EE5DD2240C5CA00173FCB /* FBAppiumActionsSynthesizer.m in Sources */, 641EE70F2240CE4800173FCB /* FBTVNavigationTracker.m in Sources */, 714D88CF2733FB970074A925 /* FBXMLGenerationOptions.m in Sources */, 641EE5DE2240C5CA00173FCB /* XCUIApplication+FBTouchAction.m in Sources */, @@ -3180,7 +3163,6 @@ 711084451DA3AA7500F913D6 /* FBXPath.m in Sources */, 719CD8FD2126C88B00C7D0C2 /* XCUIApplication+FBAlert.m in Sources */, 13DE7A45287C2A8D003243C6 /* FBXCAccessibilityElement.m in Sources */, - 71241D781FAE31F100B9559F /* FBAppiumActionsSynthesizer.m in Sources */, 641EE70E2240CE4800173FCB /* FBTVNavigationTracker.m in Sources */, 71BD20741F86116100B36EC2 /* XCUIApplication+FBTouchAction.m in Sources */, EE158AE71CBD456F00A3E3F0 /* FBWebServer.m in Sources */, @@ -3298,8 +3280,6 @@ 63FD950221F9D06100A3E356 /* FBImageProcessorTests.m in Sources */, 719CD8FF2126C90200C7D0C2 /* FBAutoAlertsHandlerTests.m in Sources */, EE2202131ECC612200A29571 /* FBIntegrationTestCase.m in Sources */, - 71BD20781F869E0F00B36EC2 /* FBAppiumTouchActionsIntegrationTests.m in Sources */, - 719A97AC1F88E7370063B4BD /* FBAppiumMultiTouchActionsIntegrationTests.m in Sources */, 715AFAC41FFA2AAF0053896D /* FBScreenTests.m in Sources */, EE22021E1ECC618900A29571 /* FBTapTest.m in Sources */, 71930C472066434000D3AFEC /* FBPasteboardTests.m in Sources */, diff --git a/WebDriverAgentLib/Categories/XCUIApplication+FBTouchAction.h b/WebDriverAgentLib/Categories/XCUIApplication+FBTouchAction.h index 5ab5e357ca..6be298b498 100644 --- a/WebDriverAgentLib/Categories/XCUIApplication+FBTouchAction.h +++ b/WebDriverAgentLib/Categories/XCUIApplication+FBTouchAction.h @@ -15,43 +15,6 @@ NS_ASSUME_NONNULL_BEGIN @interface XCUIApplication (FBTouchAction) -/** - Perform complex touch action in scope of the current application. - Touch actions are represented as lists of dictionaries with predefined sets of values and keys. - Each dictionary must contain 'action' key, which is one of the following: - - 'tap' to perform a single tap - - 'longPress' to perform long tap - - 'press' to perform press - - 'release' to release the finger - - 'moveTo' to move the virtual finger - - 'wait' to modify the duration of the preceeding action - - 'cancel' to cancel the preceeding action in the chain - Each dictionary can also contain 'options' key with additional parameters dictionary related to the appropriate action. - - The following options are mandatory for 'tap', 'longPress', 'press' and 'moveTo' actions: - - 'x' the X coordinate of the action - - 'y' the Y coordinate of the action - - 'element' the corresponding element instance, for which the action is going to be performed - If only 'element' is set then hit point coordinates of this element will be used. - If only 'x' and 'y' are set then these will be considered as absolute coordinates. - If both 'element' and 'x'/'y' are set then these will act as relative element coordinates. - - It is also mandatory, that 'release' and 'wait' actions are preceeded with at least one chain item, which contains absolute coordinates, like 'tap', 'press' or 'longPress'. Empty chains are not allowed. - - The following additional options are available for different actions: - - 'tap': 'count' (defines count of taps to be performed in a row; 1 by default) - - 'longPress': 'duration' (number of milliseconds to hold/move the virtual finger; 500.0 ms by default) - - 'wait': 'ms' (number of milliseconds to wait for the preceeding action; 0.0 ms by default) - - List of lists can be passed there is order to perform multi-finger touch action. Each single actions chain is going to be executed by a separate virtual finger in such case. - - @param actions Either array of dictionaries, whose format is described above to peform single-finger touch action or array of array to perform multi-finger touch action. - @param elementCache Cached elements mapping for the currrent application. The method assumes all elements are already represented by their actual instances if nil value is set - @param error If there is an error, upon return contains an NSError object that describes the problem - @return YES If the touch action has been successfully performed without errors - */ -- (BOOL)fb_performAppiumTouchActions:(NSArray *)actions elementCache:(nullable FBElementCache *)elementCache error:(NSError * _Nullable*)error; - /** Perform complex touch action in scope of the current application. diff --git a/WebDriverAgentLib/Categories/XCUIApplication+FBTouchAction.m b/WebDriverAgentLib/Categories/XCUIApplication+FBTouchAction.m index 703a0096d0..622dac479e 100644 --- a/WebDriverAgentLib/Categories/XCUIApplication+FBTouchAction.m +++ b/WebDriverAgentLib/Categories/XCUIApplication+FBTouchAction.m @@ -10,7 +10,6 @@ #import "XCUIApplication+FBTouchAction.h" -#import "FBAppiumActionsSynthesizer.h" #import "FBBaseActionsSynthesizer.h" #import "FBConfiguration.h" #import "FBExceptions.h" @@ -54,20 +53,6 @@ - (BOOL)fb_performActionsWithSynthesizerType:(Class)synthesizerType return [self fb_synthesizeEvent:eventRecord error:error]; } -- (BOOL)fb_performAppiumTouchActions:(NSArray *)actions - elementCache:(FBElementCache *)elementCache - error:(NSError **)error -{ - if (![self fb_performActionsWithSynthesizerType:FBAppiumActionsSynthesizer.class - actions:actions - elementCache:elementCache - error:error]) { - return NO; - } - [self fb_waitUntilStableWithTimeout:FBConfiguration.animationCoolOffTimeout]; - return YES; -} - - (BOOL)fb_performW3CActions:(NSArray *)actions elementCache:(FBElementCache *)elementCache error:(NSError **)error diff --git a/WebDriverAgentLib/Commands/FBTouchActionCommands.m b/WebDriverAgentLib/Commands/FBTouchActionCommands.m index 3e31ddf2ed..c14edcb631 100644 --- a/WebDriverAgentLib/Commands/FBTouchActionCommands.m +++ b/WebDriverAgentLib/Commands/FBTouchActionCommands.m @@ -22,25 +22,12 @@ + (NSArray *)routes { return @[ - [[FBRoute POST:@"/wda/touch/perform"] respondWithTarget:self action:@selector(handlePerformAppiumTouchActions:)], - [[FBRoute POST:@"/wda/touch/multi/perform"] respondWithTarget:self action:@selector(handlePerformAppiumTouchActions:)], [[FBRoute POST:@"/actions"] respondWithTarget:self action:@selector(handlePerformW3CTouchActions:)], ]; } #pragma mark - Commands -+ (id)handlePerformAppiumTouchActions:(FBRouteRequest *)request -{ - XCUIApplication *application = request.session.activeApplication; - NSArray *actions = (NSArray *)request.arguments[@"actions"]; - NSError *error; - if (![application fb_performAppiumTouchActions:actions elementCache:request.session.elementCache error:&error]) { - return FBResponseWithUnknownError(error); - } - return FBResponseWithOK(); -} - + (id)handlePerformW3CTouchActions:(FBRouteRequest *)request { XCUIApplication *application = request.session.activeApplication; diff --git a/WebDriverAgentLib/Utilities/FBAppiumActionsSynthesizer.h b/WebDriverAgentLib/Utilities/FBAppiumActionsSynthesizer.h deleted file mode 100644 index 090bacdd74..0000000000 --- a/WebDriverAgentLib/Utilities/FBAppiumActionsSynthesizer.h +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -#import "FBBaseActionsSynthesizer.h" - -NS_ASSUME_NONNULL_BEGIN - -#if !TARGET_OS_TV -@interface FBAppiumActionsSynthesizer : FBBaseActionsSynthesizer - -@end -#endif - -NS_ASSUME_NONNULL_END diff --git a/WebDriverAgentLib/Utilities/FBAppiumActionsSynthesizer.m b/WebDriverAgentLib/Utilities/FBAppiumActionsSynthesizer.m deleted file mode 100644 index 235d97e632..0000000000 --- a/WebDriverAgentLib/Utilities/FBAppiumActionsSynthesizer.m +++ /dev/null @@ -1,554 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -#import "FBAppiumActionsSynthesizer.h" - -#import "FBErrorBuilder.h" -#import "FBElementCache.h" -#import "FBLogger.h" -#import "FBMacros.h" -#import "FBMathUtils.h" -#import "FBXCTestDaemonsProxy.h" -#import "FBProtocolHelpers.h" -#import "XCUIElement+FBUtilities.h" -#import "XCUIElement.h" -#import "XCSynthesizedEventRecord.h" -#import "XCPointerEventPath.h" -#import "XCPointerEvent.h" - -static NSString *const FB_ACTION_KEY = @"action"; -static NSString *const FB_ACTION_TAP = @"tap"; -static NSString *const FB_ACTION_PRESS = @"press"; -static NSString *const FB_ACTION_LONG_PRESS = @"longPress"; -static NSString *const FB_ACTION_MOVE_TO = @"moveTo"; -static NSString *const FB_ACTION_RELEASE = @"release"; -static NSString *const FB_ACTION_CANCEL = @"cancel"; -static NSString *const FB_ACTION_WAIT = @"wait"; - -static NSString *const FB_OPTION_DURATION = @"duration"; -static NSString *const FB_OPTION_COUNT = @"count"; -static NSString *const FB_OPTION_MS = @"ms"; -static NSString *const FB_OPTION_PRESSURE = @"pressure"; - -static NSString *const FB_OPTIONS_KEY = @"options"; - -#if !TARGET_OS_TV -// Some useful constants might be found at -// https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/view/ViewConfiguration.java -static const double FB_TAP_DURATION_MS = 100.0; -static const double FB_INTERTAP_MIN_DURATION_MS = 40.0; -static const double FB_LONG_TAP_DURATION_MS = 600.0; - -@interface FBAppiumGestureItem : FBBaseGestureItem - -@end - -@interface FBTapItem : FBAppiumGestureItem - -@end - -@interface FBPressItem : FBAppiumGestureItem -@property (nonatomic, nullable, readonly) NSNumber *pressure; -@end - -@interface FBLongPressItem : FBAppiumGestureItem - -@end - -@interface FBWaitItem : FBAppiumGestureItem - -@end - -@interface FBMoveToItem : FBAppiumGestureItem - -@property (nonatomic, nonnull) NSValue *recentPosition; - -@end - -@interface FBReleaseItem : FBAppiumGestureItem - -@end - - -@implementation FBAppiumGestureItem - -- (nullable instancetype)initWithActionItem:(NSDictionary *)item - application:(XCUIApplication *)application - atPosition:(nullable XCUICoordinate *)atPosition - offset:(double)offset - error:(NSError **)error -{ - self = [super init]; - if (self) { - self.actionItem = item; - self.application = application; - self.offset = offset; - id options = [item objectForKey:FB_OPTIONS_KEY]; - if (nil != atPosition) { - self.atPosition = (id) atPosition; - } else { - XCUICoordinate *result = [self coordinatesWithOptions:options error:error]; - if (nil == result) { - return nil; - } - self.atPosition = result; - } - self.duration = [self durationWithOptions:options]; - if (self.duration < 0) { - NSString *description = [NSString stringWithFormat:@"%@ value cannot be negative for '%@' action", FB_OPTION_DURATION, self.class.actionName]; - if (error) { - *error = [[FBErrorBuilder.builder withDescription:description] build]; - } - return nil; - } - } - return self; -} - -+ (BOOL)hasAbsolutePositioning -{ - @throw [[FBErrorBuilder.builder withDescription:@"Override this method in subclasses"] build]; - return NO; -} - -- (double)durationWithOptions:(nullable NSDictionary *)options -{ - return (options && [options objectForKey:FB_OPTION_DURATION]) ? - ((NSNumber *)[options objectForKey:FB_OPTION_DURATION]).doubleValue : - 0.0; -} - -- (nullable XCUICoordinate *)coordinatesWithOptions:(nullable NSDictionary *)options - error:(NSError **)error -{ - if (![options isKindOfClass:NSDictionary.class]) { - NSString *description = [NSString stringWithFormat:@"'%@' key is mandatory for '%@' action", FB_OPTIONS_KEY, self.class.actionName]; - if (error) { - *error = [[FBErrorBuilder.builder withDescription:description] build]; - } - return nil; - } - XCUIElement *element = FBExtractElement((id) options); - NSNumber *x = [options objectForKey:@"x"]; - NSNumber *y = [options objectForKey:@"y"]; - if ((nil != x && nil == y) || (nil != y && nil == x) || (nil == x && nil == y && nil == element)) { - NSString *description = [NSString stringWithFormat:@"Either element or 'x' and 'y' options should be set for '%@' action", self.class.actionName]; - if (error) { - *error = [[FBErrorBuilder.builder withDescription:description] build]; - } - return nil; - } - NSValue *offset = (nil != x && nil != y) ? [NSValue valueWithCGPoint:CGPointMake(x.floatValue, y.floatValue)] : nil; - return [self hitpointWithElement:element positionOffset:offset error:error]; -} - -@end - -@implementation FBTapItem - -+ (NSString *)actionName -{ - return FB_ACTION_TAP; -} - -+ (BOOL)hasAbsolutePositioning -{ - return YES; -} - -- (NSArray *)addToEventPath:(XCPointerEventPath *)eventPath - allItems:(NSArray *)allItems - currentItemIndex:(NSUInteger)currentItemIndex - error:(NSError **)error -{ - NSTimeInterval currentOffset = FBMillisToSeconds(self.offset); - NSMutableArray *result = [NSMutableArray array]; - XCPointerEventPath *currentPath = [[XCPointerEventPath alloc] - initForTouchAtPoint:self.atPosition.screenPoint - offset:currentOffset]; - [result addObject:currentPath]; - currentOffset += FBMillisToSeconds(FB_TAP_DURATION_MS); - [currentPath liftUpAtOffset:currentOffset]; - - id options = [self.actionItem objectForKey:FB_OPTIONS_KEY]; - if ([options isKindOfClass:NSDictionary.class]) { - NSNumber *tapCount = [options objectForKey:FB_OPTION_COUNT] ?: @1; - for (NSInteger times = 1; times < tapCount.integerValue; ++times) { - currentOffset += FBMillisToSeconds(FB_INTERTAP_MIN_DURATION_MS); - XCPointerEventPath *nextPath = [[XCPointerEventPath alloc] initForTouchAtPoint:self.atPosition.screenPoint - offset:currentOffset]; - [result addObject:nextPath]; - currentOffset += FBMillisToSeconds(FB_TAP_DURATION_MS); - [nextPath liftUpAtOffset:currentOffset]; - } - } - return result.copy; -} - -- (double)durationWithOptions:(nullable NSDictionary *)options -{ - NSNumber *tapCount = @1; - if ([options isKindOfClass:NSDictionary.class]) { - tapCount = [options objectForKey:FB_OPTION_COUNT] ?: tapCount; - } - return FB_TAP_DURATION_MS * tapCount.integerValue + FB_INTERTAP_MIN_DURATION_MS * (tapCount.integerValue - 1); -} - -@end - -@implementation FBPressItem - -- (nullable instancetype)initWithActionItem:(NSDictionary *)item - application:(XCUIApplication *)application - atPosition:(nullable XCUICoordinate *)atPosition - offset:(double)offset - error:(NSError **)error -{ - self = [super initWithActionItem:item - application:application - atPosition:atPosition - offset:offset - error:error]; - if (self) { - _pressure = nil; - id options = [item objectForKey:FB_OPTIONS_KEY]; - if ([options isKindOfClass:NSDictionary.class]) { - _pressure = [options objectForKey:FB_OPTION_PRESSURE]; - } - } - return self; -} - -+ (NSString *)actionName -{ - return FB_ACTION_PRESS; -} - -+ (BOOL)hasAbsolutePositioning -{ - return YES; -} - -- (NSArray *)addToEventPath:(XCPointerEventPath *)eventPath - allItems:(NSArray *)allItems - currentItemIndex:(NSUInteger)currentItemIndex - error:(NSError **)error -{ - XCPointerEventPath *result = [[XCPointerEventPath alloc] - initForTouchAtPoint:self.atPosition.screenPoint - offset:FBMillisToSeconds(self.offset)]; - if (nil != self.pressure && nil != result.pointerEvents.lastObject) { - XCPointerEvent *pointerEvent = (XCPointerEvent *)result.pointerEvents.lastObject; - pointerEvent.pressure = self.pressure.doubleValue; - } - return @[result]; -} - -- (double)durationWithOptions:(nullable NSDictionary *)options -{ - return 0.0; -} - -@end - -@implementation FBLongPressItem - -+ (NSString *)actionName -{ - return FB_ACTION_LONG_PRESS; -} - -+ (BOOL)hasAbsolutePositioning -{ - return YES; -} - -- (NSArray *)addToEventPath:(XCPointerEventPath *)eventPath - allItems:(NSArray *)allItems - currentItemIndex:(NSUInteger)currentItemIndex - error:(NSError **)error -{ - return @[[[XCPointerEventPath alloc] initForTouchAtPoint:self.atPosition.screenPoint - offset:FBMillisToSeconds(self.offset)]]; -} - -- (double)durationWithOptions:(nullable NSDictionary *)options -{ - return (options && [options objectForKey:FB_OPTION_DURATION]) ? - ((NSNumber *)[options objectForKey:FB_OPTION_DURATION]).doubleValue : - FB_LONG_TAP_DURATION_MS; -} - -@end - -@implementation FBWaitItem - -+ (NSString *)actionName -{ - return FB_ACTION_WAIT; -} - -+ (BOOL)hasAbsolutePositioning -{ - return NO; -} - -- (NSArray *)addToEventPath:(XCPointerEventPath *)eventPath - allItems:(NSArray *)allItems - currentItemIndex:(NSUInteger)currentItemIndex - error:(NSError **)error -{ - if (nil != eventPath) { - if (0 == currentItemIndex) { - return @[]; - } - FBBaseGestureItem *preceedingItem = [allItems objectAtIndex:currentItemIndex - 1]; - if (![preceedingItem isKindOfClass:FBReleaseItem.class] && currentItemIndex < allItems.count - 1) { - return @[]; - } - } - NSTimeInterval currentOffset = FBMillisToSeconds(self.offset + self.duration); - XCPointerEventPath *result = [[XCPointerEventPath alloc] initForTouchAtPoint:self.atPosition.screenPoint - offset:currentOffset]; - if (currentItemIndex == allItems.count - 1) { - [result liftUpAtOffset:currentOffset]; - } - return @[result]; -} - -- (double)durationWithOptions:(nullable NSDictionary *)options -{ - return (options && [options objectForKey:FB_OPTION_MS]) ? - ((NSNumber *)[options objectForKey:FB_OPTION_MS]).doubleValue : - 0.0; -} - -@end - -@implementation FBMoveToItem - -+ (NSString *)actionName -{ - return FB_ACTION_MOVE_TO; -} - -+ (BOOL)hasAbsolutePositioning -{ - return YES; -} - -- (NSArray *)addToEventPath:(XCPointerEventPath *)eventPath - allItems:(NSArray *)allItems - currentItemIndex:(NSUInteger)currentItemIndex - error:(NSError **)error -{ - if (nil == eventPath) { - NSString *description = [NSString stringWithFormat:@"Move To must not be the first action in '%@'", self.actionItem]; - if (error) { - *error = [[FBErrorBuilder.builder withDescription:description] build]; - } - return nil; - } - - [eventPath moveToPoint:self.atPosition.screenPoint - atOffset:FBMillisToSeconds(self.offset)]; - return @[]; -} - -@end - -@implementation FBReleaseItem - -+ (NSString *)actionName -{ - return FB_ACTION_RELEASE; -} - -+ (BOOL)hasAbsolutePositioning -{ - return NO; -} - -- (NSArray *)addToEventPath:(XCPointerEventPath *)eventPath - allItems:(NSArray *)allItems - currentItemIndex:(NSUInteger)currentItemIndex - error:(NSError **)error -{ - if (nil == eventPath) { - NSString *description = [NSString stringWithFormat:@"Pointer Up must not be the first action in '%@'", self.actionItem]; - if (error) { - *error = [[FBErrorBuilder.builder withDescription:description] build]; - } - return nil; - } - - [eventPath liftUpAtOffset:FBMillisToSeconds(self.offset)]; - return @[]; -} - -- (double)durationWithOptions:(nullable NSDictionary *)options -{ - return 0.0; -} - -@end - - -@interface FBAppiumGestureItemsChain : FBBaseActionItemsChain - -@end - -@implementation FBAppiumGestureItemsChain - -- (void)addItem:(FBBaseActionItem *)item -{ - self.durationOffset += ((FBAppiumGestureItem *) item).duration; - [self.items addObject:item]; -} - -- (void)reset -{ - [self.items removeAllObjects]; - self.durationOffset = 0.0; -} - -@end - -@implementation FBAppiumActionsSynthesizer - -- (NSArray *> *)preprocessAction:(NSArray *> *)touchActionItems -{ - NSMutableArray *> *result = [NSMutableArray array]; - BOOL shouldSkipNextItem = NO; - for (NSDictionary *touchItem in [touchActionItems reverseObjectEnumerator]) { - id actionItemName = [touchItem objectForKey:FB_ACTION_KEY]; - if ([actionItemName isKindOfClass:NSString.class] && [actionItemName isEqualToString:FB_ACTION_CANCEL]) { - shouldSkipNextItem = YES; - continue; - } - if (shouldSkipNextItem) { - shouldSkipNextItem = NO; - continue; - } - - id options = [touchItem objectForKey:FB_OPTIONS_KEY]; - if (![options isKindOfClass:NSDictionary.class]) { - [result addObject:touchItem]; - continue; - } - id origin = FBExtractElement(options); - XCUIElement *element; - if ([origin isKindOfClass:XCUIElement.class]) { - element = origin; - } else if ([origin isKindOfClass:NSString.class]) { - element = [self.elementCache elementForUUID:(NSString *)origin]; - } else { - [result addObject:touchItem]; - continue; - } - NSMutableDictionary *elementDict = FBCleanupElements(options).mutableCopy; - [elementDict addEntriesFromDictionary:FBToElementDict(element)]; - NSMutableDictionary *processedItem = touchItem.mutableCopy; - processedItem[FB_OPTIONS_KEY] = elementDict.copy; - [result addObject:processedItem.copy]; - } - return [[result reverseObjectEnumerator] allObjects]; -} - -- (nullable NSArray *)eventPathsWithAction:(NSArray *> *)action - error:(NSError **)error -{ - static NSDictionary *gestureItemsMapping; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - NSMutableDictionary *itemsMapping = [NSMutableDictionary dictionary]; - for (Class cls in @[FBTapItem.class, - FBPressItem.class, - FBLongPressItem.class, - FBMoveToItem.class, - FBWaitItem.class, - FBReleaseItem.class]) { - [itemsMapping setObject:cls forKey:[cls actionName]]; - } - gestureItemsMapping = itemsMapping.copy; - }); - - FBAppiumGestureItemsChain *chain = [[FBAppiumGestureItemsChain alloc] init]; - BOOL isAbsoluteTouchPositionSet = NO; - for (NSDictionary *actionItem in action) { - id actionItemName = [actionItem objectForKey:FB_ACTION_KEY]; - if (![actionItemName isKindOfClass:NSString.class]) { - NSString *description = [NSString stringWithFormat:@"'%@' property is mandatory for gesture chain item %@", FB_ACTION_KEY, actionItem]; - if (error) { - *error = [[FBErrorBuilder.builder withDescription:description] build]; - } - return nil; - } - - Class gestureItemClass = [gestureItemsMapping objectForKey:actionItemName]; - if (nil == gestureItemClass) { - NSString *description = [NSString stringWithFormat:@"%@ value '%@' is unknown", FB_ACTION_KEY, actionItemName]; - if (error) { - *error = [[FBErrorBuilder.builder withDescription:description] build]; - } - return nil; - } - - FBAppiumGestureItem *gestureItem = nil; - if ([gestureItemClass hasAbsolutePositioning]) { - gestureItem = [[gestureItemClass alloc] initWithActionItem:actionItem application:self.application atPosition:nil offset:chain.durationOffset error:error]; - isAbsoluteTouchPositionSet = YES; - } else { - if (!isAbsoluteTouchPositionSet) { - if (error) { - NSString *description = [NSString stringWithFormat:@"'%@' %@ should be preceded by an item with absolute positioning", actionItemName, FB_ACTION_KEY]; - *error = [[FBErrorBuilder.builder withDescription:description] build]; - } - return nil; - } - FBAppiumGestureItem *lastItem = [chain.items lastObject]; - gestureItem = [[gestureItemClass alloc] initWithActionItem:actionItem - application:self.application - atPosition:lastItem.atPosition - offset:chain.durationOffset - error:error]; - } - if (nil == gestureItem) { - return nil; - } - - [chain addItem:gestureItem]; - } - - return [chain asEventPathsWithError:error]; -} - -- (nullable XCSynthesizedEventRecord *)synthesizeWithError:(NSError **)error -{ - XCSynthesizedEventRecord *eventRecord; - BOOL isMultiTouch = [self.actions.firstObject isKindOfClass:NSArray.class]; - eventRecord = [[XCSynthesizedEventRecord alloc] - initWithName:(isMultiTouch ? @"Multi-Finger Touch Action" : @"Single-Finger Touch Action") - interfaceOrientation:self.application.interfaceOrientation]; - for (NSArray *> *action in (isMultiTouch ? self.actions : @[self.actions])) { - NSArray *> *preprocessedAction = [self preprocessAction:action]; - NSArray *eventPaths = [self eventPathsWithAction:preprocessedAction error:error]; - if (nil == eventPaths) { - return nil; - } - for (XCPointerEventPath *eventPath in eventPaths) { - [eventRecord addPointerEventPath:eventPath]; - } - } - return eventRecord; -} - -@end - -#endif diff --git a/WebDriverAgentTests/IntegrationTests/FBAppiumMultiTouchActionsIntegrationTests.m b/WebDriverAgentTests/IntegrationTests/FBAppiumMultiTouchActionsIntegrationTests.m deleted file mode 100644 index 9b767c67ad..0000000000 --- a/WebDriverAgentTests/IntegrationTests/FBAppiumMultiTouchActionsIntegrationTests.m +++ /dev/null @@ -1,206 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -#import - -#import "FBIntegrationTestCase.h" - -#import "FBMacros.h" -#import "XCUIElement.h" -#import "XCUIApplication+FBTouchAction.h" -#import "FBTestMacros.h" -#import "XCUIDevice+FBRotation.h" -#import "FBRunLoopSpinner.h" - -@interface FBAppiumMultiTouchActionsIntegrationTestsPart1 : FBIntegrationTestCase -@end - -@interface FBAppiumMultiTouchActionsIntegrationTestsPart2 : FBIntegrationTestCase -@property (nonatomic) XCUIElement *touchesLabel; -@property (nonatomic) XCUIElement *tapsLabel; -@end - -@implementation FBAppiumMultiTouchActionsIntegrationTestsPart1 - -- (void)verifyGesture:(NSArray *> *> *)gesture orientation:(UIDeviceOrientation)orientation -{ - [[XCUIDevice sharedDevice] fb_setDeviceInterfaceOrientation:orientation]; - NSError *error; - XCTAssertTrue([self.testedApplication fb_performAppiumTouchActions:gesture elementCache:nil error:&error]); - FBAssertWaitTillBecomesTrue(self.testedApplication.alerts.count > 0); -} - -- (void)setUp -{ - [super setUp]; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - [self launchApplication]; - [self goToAlertsPage]; - }); - [self clearAlert]; -} - -- (void)tearDown -{ - [self clearAlert]; - [self resetOrientation]; - [super tearDown]; -} - -- (void)testErroneousGestures -{ - NSArray *> *> *invalidGestures = - @[ - // One of the chains is empty - @[ - @[], - @[@{@"action": @"tap", - @"options": @{ - @"ELEMENT": self.testedApplication.buttons[FBShowAlertButtonName], - } - } - ], - ], - - ]; - - for (NSArray *> *> *invalidGesture in invalidGestures) { - NSError *error; - XCTAssertFalse([self.testedApplication fb_performAppiumTouchActions:invalidGesture elementCache:nil error:&error]); - XCTAssertNotNil(error); - } -} - -- (void)testSymmetricTwoFingersTap -{ - XCUIElement *element = self.testedApplication.buttons[FBShowAlertButtonName]; - NSArray *> *> *gesture = - @[ - @[@{ - @"action": @"tap", - @"options": @{ - @"ELEMENT": element - } - } - ], - @[@{ - @"action": @"tap", - @"options": @{ - @"ELEMENT": element - } - } - ], - ]; - - [self verifyGesture:gesture orientation:UIDeviceOrientationPortrait]; -} - -@end - -@implementation FBAppiumMultiTouchActionsIntegrationTestsPart2 - -- (void)verifyGesture:(NSArray *>*>*)gesture orientation:(UIDeviceOrientation)orientation tapsCount:(int)tapsCount touchesCount:(int)touchesCount -{ - [[XCUIDevice sharedDevice] fb_setDeviceInterfaceOrientation:orientation]; - NSError *error; - XCTAssertTrue([self.testedApplication fb_performAppiumTouchActions:gesture elementCache:nil error:&error]); - NSString *taps = [[self tapsLabel] label]; - NSString *touches = [[self touchesLabel] label] ; - BOOL tapsEqual = [[NSString stringWithFormat:@"%d", tapsCount] isEqualToString:taps]; - BOOL touchesEqual = [[NSString stringWithFormat:@"%d", touchesCount] isEqualToString:touches]; - XCTAssertTrue(tapsEqual); - XCTAssertTrue(touchesEqual); -} - -- (void)setUp -{ - [super setUp]; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - [self launchApplication]; - [self goToTouchPage]; - }); - self.touchesLabel = self.testedApplication.staticTexts[FBTouchesCountLabelIdentifier]; - self.tapsLabel = self.testedApplication.staticTexts[FBTapsCountLabelIdentifier]; -} - -- (void)testMultiTouchWithMultiTaps -{ - if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"15.0")) { - // Does not work on iOS 15. - // It tapped two times, but one was touch count was one. Not two finguer taps. - return; - } - - XCUIElement *touchableView = self.testedApplication.otherElements[@"touchableView"]; - XCTAssertNotNil(touchableView); - NSArray *>*> *gesture = - @[@[@{ - @"action": @"tap", - @"options": @{ - @"ELEMENT": touchableView - } - }, - @{ - @"action": @"wait", - @"options": @{ - @"ms": @1000 - } - }, - @{ - @"action": @"tap", - @"options": @{ - @"ELEMENT": touchableView - } - }, - @{ - @"action": @"wait", - @"options": @{ - @"ms": @1000 - } - }, - @{ - @"action": @"release" - } - ], - @[@{ - @"action": @"tap", - @"options": @{ - @"ELEMENT": touchableView - } - }, - @{ - @"action": @"wait", - @"options": @{ - @"ms": @1000 - } - }, - @{ - @"action": @"tap", - @"options": @{ - @"ELEMENT": touchableView - } - }, - @{ - @"action": @"wait", - @"options": @{ - @"ms": @1000 - } - }, - @{ - @"action": @"release" - } - ] - - ]; - [self verifyGesture:gesture orientation:UIDeviceOrientationPortrait tapsCount:2 touchesCount:2]; -} - -@end diff --git a/WebDriverAgentTests/IntegrationTests/FBAppiumTouchActionsIntegrationTests.m b/WebDriverAgentTests/IntegrationTests/FBAppiumTouchActionsIntegrationTests.m deleted file mode 100644 index 51525e435e..0000000000 --- a/WebDriverAgentTests/IntegrationTests/FBAppiumTouchActionsIntegrationTests.m +++ /dev/null @@ -1,404 +0,0 @@ -/** - * Copyright (c) 2015-present, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under the BSD-style license found in the - * LICENSE file in the root directory of this source tree. An additional grant - * of patent rights can be found in the PATENTS file in the same directory. - */ - -#import - -#import "FBIntegrationTestCase.h" - -#import "XCUIElement.h" -#import "XCUIApplication+FBTouchAction.h" -#import "FBTestMacros.h" -#import "XCUIDevice+FBRotation.h" -#import "FBRunLoopSpinner.h" -#import "FBXCodeCompatibility.h" - -@interface FBAppiumTouchActionsIntegrationTestsPart1 : FBIntegrationTestCase -@end - -@interface FBAppiumTouchActionsIntegrationTestsPart2 : FBIntegrationTestCase -@property (nonatomic) XCUIElement *pickerWheel; -@end - - -@implementation FBAppiumTouchActionsIntegrationTestsPart1 - -- (void)verifyGesture:(NSArray *> *)gesture orientation:(UIDeviceOrientation)orientation -{ - [[XCUIDevice sharedDevice] fb_setDeviceInterfaceOrientation:orientation]; - NSError *error; - XCTAssertTrue([self.testedApplication fb_performAppiumTouchActions:gesture elementCache:nil error:&error]); - FBAssertWaitTillBecomesTrue(self.testedApplication.alerts.count > 0); -} - -- (void)setUp -{ - [super setUp]; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - [self launchApplication]; - [self goToAlertsPage]; - }); - [self clearAlert]; -} - -- (void)tearDown -{ - [self clearAlert]; - [self resetOrientation]; - [super tearDown]; -} - -- (void)testErroneousGestures -{ - XCUIElement *dstButton = self.testedApplication.buttons[FBShowAlertButtonName]; - - NSArray *> *> *invalidGestures = - @[ - // Empty chain - @[], - - // Chain element without 'action' key - @[@{ - @"options": @{ - @"ms": @100 - } - }, - ], - - // Empty chain because of cancel - @[@{ - @"action": @"moveTo", - @"options": @{ - @"ELEMENT": dstButton, - } - }, - @{ - @"action": @"cancel" - }, - ], - - // Chain with unknown action - @[@{ - @"action": @"tapP", - @"options": @{ - @"ELEMENT": dstButton, - } - }, - ], - - // Wait without preceeding coordinate - @[@{ - @"action": @"wait" - } - ], - - // Wait with negative duration - @[@{ - @"action": @"press", - @"options": @{ - @"x": @1, - @"y": @1 - } - }, - @{ - @"action": @"wait", - @"options": @{ - @"ms": @-1.0 - } - }, - ], - - // Release without preceeding coordinate - @[@{ - @"action": @"release" - }, - @{ - @"action": @"tap", - @"options": @{ - @"x": @1, - @"y": @1 - } - }, - ], - - // Press without coordinates - @[@{ - @"action": @"press" - } - ], - - // longPress with invalid coordinates - @[@{ - @"action": @"longPress", - @"options": @{ - @"x": @1 - } - }, - ], - - // longPress with negative duration - @[@{ - @"action": @"longPress", - @"options": @{ - @"x": @1, - @"y": @1, - @"duration": @-0.01 - } - }, - ], - - ]; - - for (NSArray *> *invalidGesture in invalidGestures) { - NSError *error; - XCTAssertFalse([self.testedApplication fb_performAppiumTouchActions:invalidGesture elementCache:nil error:&error]); - XCTAssertNotNil(error); - } -} - -- (void)testTap -{ - NSArray *> *gesture = - @[@{ - @"action": @"tap", - @"options": @{ - @"ELEMENT": self.testedApplication.buttons[FBShowAlertButtonName] - } - } - ]; - [self verifyGesture:gesture orientation:UIDeviceOrientationPortrait]; -} - -- (void)testTapByCoordinates -{ - CGRect elementRect = self.testedApplication.buttons[FBShowAlertButtonName].frame; - CGFloat x = elementRect.origin.x + elementRect.size.width / 2; - CGFloat y = elementRect.origin.y + elementRect.size.height / 2; - NSArray *> *gesture = - @[@{ - @"action": @"tap", - @"options": @{ - @"x": @(x), - @"y": @(y) - } - } - ]; - [self verifyGesture:gesture orientation:UIDeviceOrientationPortrait]; -} - -- (void)testDoubleTap -{ - NSArray *> *gesture = - @[@{ - @"action": @"tap", - @"options": @{ - @"ELEMENT": self.testedApplication.buttons[FBShowAlertButtonName], - @"count": @2 - } - }, - ]; - [self verifyGesture:gesture orientation:UIDeviceOrientationLandscapeLeft]; -} - -- (void)testPress -{ - NSArray *> *gesture = - @[@{ - @"action": @"press", - @"options": @{ - @"ELEMENT": self.testedApplication.buttons[FBShowAlertButtonName], - @"x": @1, - @"y": @1 - } - }, - @{ - @"action": @"wait", - @"options": @{ - @"ms": @300 - } - }, - @{ - @"action": @"wait", - @"options": @{ - @"ms": @300 - } - }, - @{ - @"action": @"wait", - @"options": @{ - @"ms": @300 - } - }, - @{ - @"action": @"release" - } - ]; - [self verifyGesture:gesture orientation:UIDeviceOrientationLandscapeRight]; -} - -- (void)testLongPress -{ - if (UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad) { - XCTSkip(@"Failed on Azure Pipeline. Local run succeeded."); - } - UIDeviceOrientation orientation = UIDeviceOrientationLandscapeLeft; - [[XCUIDevice sharedDevice] fb_setDeviceInterfaceOrientation:orientation]; - CGRect elementFrame = self.testedApplication.buttons[FBShowAlertButtonName].frame; - NSArray *> *gesture = - @[@{ - @"action": @"longPress", - @"options": @{ - @"x": @(elementFrame.origin.x + 1), - @"y": @(elementFrame.origin.y + 1), - @"duration": @5 - } - }, - @{ - @"action": @"wait", - @"options": @{ - @"ms": @500 - } - }, - @{ - @"action": @"release" - } - ]; - [self verifyGesture:gesture orientation:orientation]; -} - -@end - - -@implementation FBAppiumTouchActionsIntegrationTestsPart2 - -- (void)setUp -{ - [super setUp]; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^{ - [self launchApplication]; - [self goToAttributesPage]; - }); - self.pickerWheel = self.testedApplication.pickerWheels.allElementsBoundByIndex.firstObject; -} - -- (void)tearDown -{ - [self resetOrientation]; - [super tearDown]; -} - -- (void)verifyPickerWheelPositionChangeWithGesture:(NSArray *> *)gesture -{ - NSString *previousValue = self.pickerWheel.value; - NSError *error; - XCTAssertTrue([self.testedApplication fb_performAppiumTouchActions:gesture elementCache:nil error:&error]); - XCTAssertNil(error); - XCTAssertTrue([[[[FBRunLoopSpinner new] - timeout:2.0] - timeoutErrorMessage:@"Picker wheel value has not been changed after 2 seconds timeout"] - spinUntilTrue:^BOOL{ - return ![self.pickerWheel.fb_takeSnapshot.value isEqualToString:previousValue]; - } - error:&error]); - XCTAssertNil(error); -} - -- (void)testSwipePickerWheelWithElementCoordinates -{ - CGRect pickerFrame = self.pickerWheel.frame; - NSArray *> *gesture = - @[@{ - @"action": @"press", - @"options": @{ - @"ELEMENT": self.pickerWheel, - @"x": @(pickerFrame.size.width / 2), - @"y": @(pickerFrame.size.height / 2), - } - }, - @{ - @"action": @"wait", - @"options": @{ - @"ms": @500, - } - }, - @{ - @"action": @"moveTo", - @"options": @{ - @"ELEMENT": self.pickerWheel, - @"x": @(pickerFrame.size.width / 2), - @"y": @(pickerFrame.size.height), - } - }, - @{ - @"action": @"release" - } - ]; - [self verifyPickerWheelPositionChangeWithGesture:gesture]; -} - -- (void)testSwipePickerWheelWithRelativeCoordinates -{ - CGRect pickerFrame = self.pickerWheel.frame; - NSArray *> *gesture = - @[@{ - @"action": @"press", - @"options": @{ - @"ELEMENT": self.pickerWheel, - @"x": @(pickerFrame.size.width / 2), - @"y": @(pickerFrame.size.height / 2), - } - }, - @{ - @"action": @"wait", - @"options": @{ - @"ms": @500, - } - }, - @{ - @"action": @"moveTo", - @"options": @{ - @"x": @(pickerFrame.origin.x / 2), - @"y": @(pickerFrame.origin.y), - } - }, - @{ - @"action": @"release" - } - ]; - [self verifyPickerWheelPositionChangeWithGesture:gesture]; -} - -- (void)testSwipePickerWheelWithAbsoluteCoordinates -{ - CGRect pickerFrame = self.pickerWheel.frame; - NSArray *> *gesture = - @[@{ - @"action": @"longPress", - @"options": @{ - @"x": @(pickerFrame.origin.x + pickerFrame.size.width / 2), - @"y": @(pickerFrame.origin.y + pickerFrame.size.height / 2), - } - }, - @{ - @"action": @"moveTo", - @"options": @{ - @"x": @(pickerFrame.origin.x + pickerFrame.size.width / 2), - @"y": @(pickerFrame.origin.y + pickerFrame.size.height), - } - }, - @{ - @"action": @"release" - } - ]; - [self verifyPickerWheelPositionChangeWithGesture:gesture]; -} - -@end - From 77aeef7eec47a5bb4911b6a53d991d533c2b8b9e Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Mon, 12 Feb 2024 20:02:55 +0000 Subject: [PATCH 2/2] chore(release): 7.0.0 [skip ci] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## [7.0.0](https://github.com/appium/WebDriverAgent/compare/v6.1.1...v7.0.0) (2024-02-12) ### ⚠ BREAKING CHANGES * The following REST endpoints have been removed, use W3C actions instead: - /wda/touch/perform - /wda/touch/multi/perform ### Features * Remove obsolete MJSONWP touch actions ([#847](https://github.com/appium/WebDriverAgent/issues/847)) ([d77f640](https://github.com/appium/WebDriverAgent/commit/d77f640867155fddbbbc9575f0a77802602865e7)) --- CHANGELOG.md | 13 +++++++++++++ package.json | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae9968eeb9..d5321867bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,16 @@ +## [7.0.0](https://github.com/appium/WebDriverAgent/compare/v6.1.1...v7.0.0) (2024-02-12) + + +### ⚠ BREAKING CHANGES + +* The following REST endpoints have been removed, use W3C actions instead: +- /wda/touch/perform +- /wda/touch/multi/perform + +### Features + +* Remove obsolete MJSONWP touch actions ([#847](https://github.com/appium/WebDriverAgent/issues/847)) ([d77f640](https://github.com/appium/WebDriverAgent/commit/d77f640867155fddbbbc9575f0a77802602865e7)) + ## [6.1.1](https://github.com/appium/WebDriverAgent/compare/v6.1.0...v6.1.1) (2024-02-11) diff --git a/package.json b/package.json index c4f3cda479..928745924e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "appium-webdriveragent", - "version": "6.1.1", + "version": "7.0.0", "description": "Package bundling WebDriverAgent", "main": "./build/index.js", "scripts": {