Skip to content

Commit a10689e

Browse files
fix: deep clone of cropRect from options
1 parent f67c7d0 commit a10689e

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

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 || {};

0 commit comments

Comments
 (0)