Skip to content

Commit

Permalink
fix(ios): use application size to determine touch cooridnates
Browse files Browse the repository at this point in the history
  • Loading branch information
drauggres committed Oct 27, 2021
1 parent 9c85cd8 commit ee481ec
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/app/applDevice/WdaConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import ScreenInfo from '../ScreenInfo';
import { WsQVHackClient } from './client/WsQVHackClient';

interface WdaScreen {
statusBarSize: { width: number; height: number };
scale: number;
width: number;
height: number;
}

export default class WdaConnection {
Expand Down Expand Up @@ -80,7 +80,7 @@ export default class WdaConnection {
wdaScreen: WdaScreen,
position: Position,
): Point | undefined {
const { statusBarSize } = wdaScreen;
const { width } = wdaScreen;
// ignore the locked video orientation, the events will apply in coordinates considered in the physical device orientation
const { videoSize, deviceRotation, contentRect } = screenInfo;
const { right, left, bottom, top } = contentRect;
Expand All @@ -90,7 +90,7 @@ export default class WdaConnection {
} else {
shortSide = right - left;
}
const scale = shortSide / statusBarSize.width;
const scale = shortSide / width;

// reverse the video rotation to apply the events
const devicePosition = position.rotate(deviceRotation);
Expand Down
7 changes: 4 additions & 3 deletions src/server/appl-device/services/WDARunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ export class WDARunner extends TypedEmitter<WDARunnerEvents> {
if (cached) {
return cached;
}
const info = await driver.getScreenInfo();
this.cachedScreenInfo.set(udid, info);
return info;
const el = await driver.findElement('xpath', '//XCUIElementTypeApplication');
const size = await driver.getSize(el);
this.cachedScreenInfo.set(udid, size);
return size;
}

protected name: string;
Expand Down
9 changes: 5 additions & 4 deletions typings/appium-xcuitest-driver/build/lib/driver.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@ declare interface Gesture {
x?: number;
y?: number;
ms?: number;
}
};
}

declare class XCUITestDriver extends BaseDriver {
constructor (opts: Record<string, any>, shouldValidateCaps: boolean);
constructor(opts: Record<string, any>, shouldValidateCaps: boolean);
public createSession(...args: any): Promise<any>;
public findElement(strategy: string, selector: string): Promise<any>;
public getSize(element: any): Promise<{ width: number; height: number } | undefined>;
public getScreenInfo(): Promise<any>;
public performTouch(gestures: Gesture[]): Promise<any>;
public mobilePressButton(args: {name: string}): Promise<any>;
public mobilePressButton(args: { name: string }): Promise<any>;
public stop(): Promise<void>;
public deleteSession(): Promise<void>;
}


export default XCUITestDriver;
export { XCUITestDriver };

0 comments on commit ee481ec

Please sign in to comment.