Skip to content

Commit

Permalink
[RNMobile] E2E Android - Use swipe gesture to scroll inserter menu (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
dratwas authored Aug 4, 2020
1 parent 32b658f commit 8feb391
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
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

0 comments on commit 8feb391

Please sign in to comment.