Skip to content

Commit

Permalink
Revert "Fix Android device tests for AndroidX migration (#1125)"
Browse files Browse the repository at this point in the history
This reverts commit 82de3b63811a35ae9f56f3bb1018bbffddeef41f.
  • Loading branch information
hypest committed Oct 23, 2019
1 parent 9a58dd2 commit ae8c383
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 42 deletions.
23 changes: 2 additions & 21 deletions __device-tests__/helpers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,28 +114,9 @@ const setupDriver = async () => {

await driver.setImplicitWaitTimeout( 2000 );
await timer( 3000 );
await driver.setOrientation( 'PORTRAIT' );

// Proxy driver to patch functions on Android
// This is needed to adapt to changes in the way accessibility ids are being
// assigned after migrating to AndroidX and React Native 0.60. See:
// https://github.com/wordpress-mobile/gutenberg-mobile/pull/1112#issuecomment-501165250
// for more details.
return new Proxy( driver, {
get: ( original, property ) => {
const propertiesToPatch = [
'elementByAccessibilityId',
'hasElementByAccessibilityId',
];
if ( isAndroid() && ( propertiesToPatch.includes( property ) ) ) {
return async function( value, cb ) {
// Add a comma and a space to all ids
return await original[ property ]( `${ value }, `, cb );
};
}
return original[ property ];
},
} );
await driver.setOrientation( 'PORTRAIT' );
return driver;
};

const stopDriver = async ( driver: wd.PromiseChainWebdriver ) => {
Expand Down
27 changes: 7 additions & 20 deletions __device-tests__/pages/editor-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,6 @@ export default class EditorPage {
headingBlockName = 'Heading';
imageBlockName = 'Image';

// This is needed to adapt to changes in the way accessibility ids are being
// assigned after migrating to AndroidX and React Native 0.60. See:
// https://github.com/wordpress-mobile/gutenberg-mobile/pull/1112#issuecomment-501165250
// for more details.
accessibilityIdSuffix = '';

constructor( driver: wd.PromiseChainWebdriver ) {
this.driver = driver;
this.accessibilityIdKey = 'name';
Expand All @@ -35,7 +29,6 @@ export default class EditorPage {
if ( isAndroid() ) {
this.accessibilityIdXPathAttrib = 'content-desc';
this.accessibilityIdKey = 'contentDescription';
this.accessibilityIdSuffix = ', ';
}
}

Expand Down Expand Up @@ -105,7 +98,7 @@ export default class EditorPage {
}

async getTextViewForHtmlViewContent() {
const accessibilityId = `html-view-content${ this.accessibilityIdSuffix }`;
const accessibilityId = 'html-view-content';
let blockLocator = `//*[@${ this.accessibilityIdXPathAttrib }="${ accessibilityId }"]`;

if ( ! isAndroid() ) {
Expand Down Expand Up @@ -176,13 +169,11 @@ export default class EditorPage {
if ( ! await this.hasBlockAtPosition( position, blockName ) ) {
throw Error( `No Block at position ${ position }` );
}
const parentId = `${ blockName } Block. Row ${ position }.${ this.accessibilityIdSuffix }`;
const parentLocator = `//*[@${ this.accessibilityIdXPathAttrib }="${ parentId }"]`;

const blockId = `Move block up from row ${ position } to row ${ position - 1 }${ this.accessibilityIdSuffix }`;
const parentLocator = `//*[@${ this.accessibilityIdXPathAttrib }="${ blockName } Block. Row ${ position }."]`;
let blockLocator = `${ parentLocator }/following-sibling::*`;
blockLocator += isAndroid() ? '' : '//*';
blockLocator += `[@${ this.accessibilityIdXPathAttrib }="${ blockId }"]`;
blockLocator += `[@${ this.accessibilityIdXPathAttrib }="Move block up from row ${ position } to row ${ position - 1 }"]`;
const moveUpButton = await this.driver.elementByXPath( blockLocator );
await moveUpButton.click();
}
Expand All @@ -193,13 +184,10 @@ export default class EditorPage {
throw Error( `No Block at position ${ position }` );
}

const parentId = `${ blockName } Block. Row ${ position }.`;
const parentLocator = `//*[contains(@${ this.accessibilityIdXPathAttrib }, "${ parentId }")]`;

const blockId = `Move block down from row ${ position } to row ${ position + 1 }${ this.accessibilityIdSuffix }`;
const parentLocator = `//*[contains(@${ this.accessibilityIdXPathAttrib }, "${ blockName } Block. Row ${ position }.")]`;
let blockLocator = `${ parentLocator }/following-sibling::*`;
blockLocator += isAndroid() ? '' : '//*';
blockLocator += `[@${ this.accessibilityIdXPathAttrib }="${ blockId }"]`;
blockLocator += `[@${ this.accessibilityIdXPathAttrib }="Move block down from row ${ position } to row ${ position + 1 }"]`;
const moveDownButton = await this.driver.elementByXPath( blockLocator );
await moveDownButton.click();
}
Expand All @@ -211,14 +199,13 @@ export default class EditorPage {
throw Error( `No Block at position ${ position }` );
}

const parentId = `${ blockName } Block. Row ${ position }.`;
const parentLocator = `//*[contains(@${ this.accessibilityIdXPathAttrib }, "${ parentId }")]`;
const parentLocator = `//*[contains(@${ this.accessibilityIdXPathAttrib }, "${ blockName } Block. Row ${ position }.")]`;
let removeBlockLocator = `${ parentLocator }/following-sibling::*`;
removeBlockLocator += isAndroid() ? '' : '//*';
let removeButtonIdentifier = `Remove block at row ${ position }`;

if ( isAndroid() ) {
removeButtonIdentifier += `, Double tap to remove the block${ this.accessibilityIdSuffix }`;
removeButtonIdentifier += ', Double tap to remove the block';
const block = await this.getBlockAtPosition( position, blockName );
let checkList = await this.driver.elementsByXPath( removeBlockLocator );
while ( checkList.length === 0 ) {
Expand Down
1 change: 0 additions & 1 deletion ios/gutenberg.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,6 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
Expand Down

0 comments on commit ae8c383

Please sign in to comment.