Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RNMobile] E2E Android - Use swipe gesture to scroll inserter menu #24338

Merged
merged 1 commit into from
Aug 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions packages/react-native-editor/__device-tests__/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,10 +446,19 @@ const swipeUp = async ( driver, element = undefined ) => {
const endX = startX;
const endY = startY + startY * -1 * 0.5;

await swipeFromTo( driver, { x: startX, y: startY }, { x: endX, y: endY } );
};

const defaultCoordinates = { x: 0, y: 0 };
const swipeFromTo = async (
driver,
from = defaultCoordinates,
to = defaultCoordinates
) => {
const action = await new wd.TouchAction( driver );
action.press( { x: startX, y: startY } );
action.press( from );
action.wait( 3000 );
action.moveTo( { x: endX, y: endY } );
action.moveTo( to );
action.release();
await action.perform();
};
Expand All @@ -464,12 +473,7 @@ const swipeDown = async ( driver ) => {
const endX = startX;
const endY = startY - startY * -1 * 0.5;

const action = await new wd.TouchAction( driver );
action.press( { x: startX, y: startY } );
action.wait( 3000 );
action.moveTo( { x: endX, y: endY } );
action.release();
await action.perform();
await swipeFromTo( driver, { x: startX, y: startY }, { x: endX, y: endY } );
};

const toggleHtmlMode = async ( driver, toggleOn ) => {
Expand Down Expand Up @@ -526,6 +530,7 @@ module.exports = {
tapPasteAboveElement,
swipeDown,
swipeUp,
swipeFromTo,
stopDriver,
toggleHtmlMode,
toggleOrientation,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
swipeDown,
typeString,
toggleHtmlMode,
swipeFromTo,
} from '../helpers/utils';

export default class EditorPage {
Expand Down Expand Up @@ -197,11 +198,17 @@ export default class EditorPage {
// Attempts to find the given block button in the block inserter control.
async findBlockButton( blockName ) {
if ( isAndroid() ) {
const size = await this.driver.getWindowSize();
const x = size.width / 2;
// Checks if the Block Button is available, and if not will scroll to the second half of the available buttons.
while (
! ( await this.driver.hasElementByAccessibilityId( blockName ) )
) {
await this.driver.pressKeycode( 20 ); // Press the Down arrow to force a scroll.
swipeFromTo(
this.driver,
{ x, y: size.height - 100 },
{ x, y: size.height - 450 }
);
}

return await this.driver.elementByAccessibilityId( blockName );
Expand Down