Skip to content

Commit 0d832c4

Browse files
Merge pull request #252 from NativeScript/svetoslavtsenov/fix-rectangles
fix: deep clone of cropRect from options
2 parents 7246bce + c5aa24e commit 0d832c4

9 files changed

+29
-36
lines changed

Diff for: lib/appium-driver.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
export declare const should: any;
21
import { ElementHelper } from "./element-helper";
32
import { SearchOptions } from "./search-options";
43
import { UIElement } from "./ui-element";

Diff for: lib/appium-driver.ts

-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
import * as wd from "wd";
22
import * as webdriverio from "webdriverio";
3-
const chai = require("chai");
4-
const chaiAsPromised = require("chai-as-promised");
5-
chai.use(chaiAsPromised);
6-
export const should = chai.should();
7-
chaiAsPromised.transferPromiseness = wd.transferPromiseness;
83

94
import { ElementHelper } from "./element-helper";
105
import { SearchOptions } from "./search-options";

Diff for: lib/image-helper.d.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ export interface IImageCompareOptions {
1717
*/
1818
toleranceType?: ImageOptions;
1919
/**
20-
* Wait miliseconds before capture creating image
21-
* Default value is 2000
20+
* Wait milliseconds before capture creating image
21+
* Default value is 5000
2222
*/
2323
waitBeforeCreatingInitialImageCapture?: number;
2424
/**
@@ -43,14 +43,14 @@ export interface IImageCompareOptions {
4343
keepOriginalImageSize?: boolean;
4444
/**
4545
* Default value is set to false. nativescript-dev-appium will recalculate view port for iOS
46-
* so that the top/y will start from the end of status bar
46+
* so that the top/y will start from the end of the status bar
4747
* So far appium calculates it even more and some part of safe areas are missed
4848
*/
4949
keepAppiumViewportRect?: boolean;
5050
/**
51-
* Defines if an image is device specific or only by platform.
52-
* Default value is true and the image will be saved in device specific directory.
53-
* If value is set to false, image will be saved under ios or android folder.
51+
* Defines if an image is device-specific or only by the platform.
52+
* Default value is true and the image will be saved in device-specific directory.
53+
* If the value is set to false, the image will be saved under ios or android folder.
5454
*/
5555
isDeviceSpecific?: boolean;
5656
/**

Diff for: lib/image-helper.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ export interface IImageCompareOptions {
2929
toleranceType?: ImageOptions;
3030

3131
/**
32-
* Wait miliseconds before capture creating image
33-
* Default value is 2000
32+
* Wait milliseconds before capture creating image
33+
* Default value is 5000
3434
*/
3535
waitBeforeCreatingInitialImageCapture?: number;
3636

@@ -53,23 +53,23 @@ export interface IImageCompareOptions {
5353

5454
/**
5555
* Default value is set to true which means that nativescript-dev-appium will save the image
56-
* in original size and compare only the part which cropRectangle specifies.
56+
* in original size and compare only the part which cropRectangle specifies.
5757
* If false, the image size will be reduced and saved by the dimensions of cropRectangle.
5858
*/
5959
keepOriginalImageSize?: boolean;
6060

6161

6262
/**
6363
* Default value is set to false. nativescript-dev-appium will recalculate view port for iOS
64-
* so that the top/y will start from the end of status bar
64+
* so that the top/y will start from the end of the status bar
6565
* So far appium calculates it even more and some part of safe areas are missed
6666
*/
6767
keepAppiumViewportRect?: boolean;
6868

6969
/**
70-
* Defines if an image is device specific or only by platform.
71-
* Default value is true and the image will be saved in device specific directory.
72-
* If value is set to false, image will be saved under ios or android folder.
70+
* Defines if an image is device-specific or only by the platform.
71+
* Default value is true and the image will be saved in device-specific directory.
72+
* If the value is set to false, the image will be saved under ios or android folder.
7373
*/
7474
isDeviceSpecific?: boolean;
7575

@@ -98,7 +98,9 @@ export class ImageHelper {
9898
};
9999

100100
constructor(private _args: INsCapabilities, private _driver: AppiumDriver) {
101-
this._defaultOptions.cropRectangle = (this._args.appiumCaps && this._args.appiumCaps.viewportRect) || this._args.device.viewportRect;
101+
if (this._args.device.viewportRect) {
102+
ImageHelper.fullClone(this._args.device.viewportRect, this._defaultOptions.cropRectangle)
103+
}
102104
if (!this._defaultOptions.cropRectangle
103105
|| !isNumber(this._defaultOptions.cropRectangle.y)) {
104106
this._defaultOptions.cropRectangle = this._defaultOptions.cropRectangle || {};

Diff for: lib/parser.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
import { LogImageType } from "./enums/log-image-type";
2-
export declare const projectDir: string, projectBinary: string, pluginRoot: string, pluginBinary: string, port: number, verbose: boolean, appiumCapsLocation: string, testFolder: string, runType: string, isSauceLab: boolean, appPath: string, storage: string, testReports: string, devMode: boolean, ignoreDeviceController: boolean, wdaLocalPort: number, path: string, relaxedSecurity: boolean, cleanApp: boolean, attachToDebug: boolean, sessionId: string, startSession: boolean, capabilitiesName: string, imagesPath: string, startDeviceOptions: string, deviceTypeOrPlatform: string, device: import("mobile-devices-controller/lib/device").IDevice, driverConfig: any, logImageTypes: LogImageType[], appiumCaps: any;
2+
export declare const projectDir: string, projectBinary: string, pluginRoot: string, pluginBinary: string, port: number, verbose: boolean, appiumCapsLocation: string, testFolder: string, runType: string, isSauceLab: boolean, appPath: string, storage: string, testReports: string, devMode: boolean, ignoreDeviceController: boolean, wdaLocalPort: number, path: string, relaxedSecurity: boolean, cleanApp: boolean, attachToDebug: boolean, sessionId: string, startSession: boolean, capabilitiesName: string, imagesPath: string, startDeviceOptions: string, deviceTypeOrPlatform: string, device: any, driverConfig: any, logImageTypes: LogImageType[], appiumCaps: any;

Diff for: lib/ui-element.ts

+9-11
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class UIElement {
4949
* This method is not working very good with UiAutomator2
5050
* It is better to use click instead.
5151
*/
52-
52+
5353
public async tap() {
5454
if (this._args.automationName == AutomationName.UiAutomator2) {
5555
return await this.tapCenter();
@@ -242,16 +242,14 @@ export class UIElement {
242242
*/
243243
public async getActualRectangle() {
244244
const actRect = await this.getRectangle();
245-
if (this._args.isIOS) {
246-
const density = this._args.device.config.density;
247-
if (density) {
248-
actRect.x *= density;
249-
actRect.y *= density;
250-
actRect.width *= density;
251-
actRect.height *= density;
252-
} else {
253-
throw new Error("Device's density is undefined!");
254-
}
245+
const density = this._args.device.config.density;
246+
if (density) {
247+
actRect.x *= density;
248+
actRect.y *= density;
249+
actRect.width *= density;
250+
actRect.height *= density;
251+
} else {
252+
throw new Error("Device's density is undefined!");
255253
}
256254
return actRect;
257255
}

Diff for: package.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "nativescript-dev-appium",
3-
"version": "6.0.0",
3+
"version": "6.1.0",
44
"description": "A NativeScript plugin to help integrate and run Appium tests",
55
"author": "NativeScript",
66
"license": "MIT",
@@ -33,8 +33,6 @@
3333
"dependencies": {
3434
"app-root-path": "~2.1.0",
3535
"blink-diff": "~1.0.13",
36-
"chai": "~4.2.0",
37-
"chai-as-promised": "~7.1.0",
3836
"frame-comparer": "^2.0.1",
3937
"glob": "^7.1.0",
4038
"inquirer": "^6.2.0",

Diff for: samples/e2e-ts/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"experimentalDecorators": true,
66
"emitDecoratorMetadata": true,
77
"importHelpers": false,
8+
"sourceMap": true,
89
"types": [ ],
910
"lib": [
1011
"es2015",

Diff for: samples/e2e-ts/typescript.mocha.sample.e2e-spec.mochawesome.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { AppiumDriver, createDriver, SearchOptions, nsCapabilities } from "nativ
22
import { assert } from "chai";
33
const addContext = require('mochawesome/addContext');
44

5-
describe("sample scenario", () => {
5+
describe("sample scenario", async function(){
66
let driver: AppiumDriver;
77

88
before(async function(){

0 commit comments

Comments
 (0)