Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 376602a

Browse files
Merge branch 'svetoslavtsenov/gestures' of https://github.com/NativeScript/nativescript-dev-appium into svetoslavtsenov/gestures
2 parents baa4ff1 + 03a0832 commit 376602a

File tree

4 files changed

+30
-30
lines changed

4 files changed

+30
-30
lines changed

‎lib/appium-driver.d.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ export declare class AppiumDriver {
2323
private _isAlive;
2424
private _locators;
2525
private _storageByPlatform;
26-
private _defaultToleranceType;
27-
private _defaultTolerance;
2826
private constructor();
2927
readonly imageHelper: ImageHelper;
3028
defaultWaitTime: number;
@@ -38,8 +36,6 @@ export declare class AppiumDriver {
3836
readonly isAndroid: boolean;
3937
readonly isIOS: boolean;
4038
readonly driver: any;
41-
defaultToleranceType: ImageOptions;
42-
defaultTolerance: number;
4339
/**
4440
* Get the storage where test results from image comparison is logged. The path should be reports/app nam/device name
4541
*/

‎lib/appium-driver.ts

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ export class AppiumDriver {
5858
private _isAlive: boolean = false;
5959
private _locators: Locator;
6060
private _storageByPlatform: string;
61-
private _defaultToleranceType: ImageOptions = ImageOptions.percent;
62-
private _defaultTolerance: number = 0;
6361

6462
private constructor(private _driver: any, private _wd, private _webio: any, private _driverConfig, private _args: INsCapabilities) {
6563
this._elementHelper = new ElementHelper(this._args);
@@ -121,22 +119,6 @@ export class AppiumDriver {
121119
return this._driver;
122120
}
123121

124-
get defaultToleranceType(): ImageOptions {
125-
return this._defaultToleranceType;
126-
}
127-
128-
set defaultToleranceType(toleranceType: ImageOptions) {
129-
this._defaultToleranceType = toleranceType;
130-
}
131-
132-
get defaultTolerance(): number {
133-
return this._defaultTolerance;
134-
}
135-
136-
set defaultTolerance(tolerance: number) {
137-
this._defaultTolerance = tolerance;
138-
}
139-
140122
/**
141123
* Get the storage where test results from image comparison is logged. The path should be reports/app nam/device name
142124
*/
@@ -635,11 +617,11 @@ export class AppiumDriver {
635617
return await this.driver.getSessionId();
636618
}
637619

638-
public async compareElement(element: UIElement, imageName?: string, tolerance: number = this._defaultTolerance, timeOutSeconds: number = 3, toleranceType: ImageOptions = this._defaultToleranceType) {
620+
public async compareElement(element: UIElement, imageName?: string, tolerance: number = this.imageHelper.defaultTolerance, timeOutSeconds: number = 3, toleranceType: ImageOptions = this.imageHelper.defaultToleranceType) {
639621
return await this.compareRectangle(await element.getActualRectangle(), imageName, timeOutSeconds, tolerance, toleranceType);
640622
}
641623

642-
public async compareRectangle(rect: IRectangle, imageName?: string, timeOutSeconds: number = 3, tolerance: number = this._defaultTolerance, toleranceType: ImageOptions = this._defaultToleranceType) {
624+
public async compareRectangle(rect: IRectangle, imageName?: string, timeOutSeconds: number = 3, tolerance: number = this.imageHelper.defaultTolerance, toleranceType: ImageOptions = this.imageHelper.defaultToleranceType) {
643625
imageName = imageName || this.imageHelper.testName;
644626
const options = this.imageHelper.extendOptions({
645627
imageName: imageName,
@@ -653,7 +635,7 @@ export class AppiumDriver {
653635
return await this.imageHelper.compare(options);
654636
}
655637

656-
public async compareScreen(imageName?: string, timeOutSeconds: number = 3, tolerance: number = this._defaultTolerance, toleranceType: ImageOptions = this._defaultToleranceType) {
638+
public async compareScreen(imageName?: string, timeOutSeconds: number = 3, tolerance: number = this.imageHelper.defaultTolerance, toleranceType: ImageOptions = this.imageHelper.defaultToleranceType) {
657639
imageName = imageName || this.imageHelper.testName;
658640
const options = this.imageHelper.extendOptions({
659641
imageName: imageName,

‎lib/image-helper.d.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ export declare class ImageHelper {
6464
private _blockOutAreas;
6565
private _imagesResults;
6666
private _options;
67+
private _defaultToleranceType;
68+
private _defaultTolerance;
6769
private _defaultOptions;
6870
constructor(_args: INsCapabilities, _driver: AppiumDriver);
6971
static readonly pngFileExt = ".png";
@@ -80,6 +82,8 @@ export declare class ImageHelper {
8082
delta: number;
8183
options: IImageCompareOptions;
8284
blockOutAreas: IRectangle[];
85+
defaultToleranceType: ImageOptions;
86+
defaultTolerance: number;
8387
compareScreen(options?: IImageCompareOptions): Promise<boolean>;
8488
compareElement(element: UIElement, options?: IImageCompareOptions): Promise<boolean>;
8589
compareRectangle(cropRectangle: IRectangle, options?: IImageCompareOptions): Promise<boolean>;

‎lib/image-helper.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ export class ImageHelper {
8383
private _blockOutAreas: IRectangle[];
8484
private _imagesResults = new Map<string, boolean>();
8585
private _options: IImageCompareOptions = {};
86+
private _defaultToleranceType: ImageOptions = ImageOptions.percent;
87+
private _defaultTolerance: number = 0;
8688
private _defaultOptions: IImageCompareOptions = {
8789
timeOutSeconds: 2,
8890
tolerance: 0,
@@ -148,6 +150,22 @@ export class ImageHelper {
148150
this._blockOutAreas = rectangles;
149151
}
150152

153+
get defaultToleranceType(): ImageOptions {
154+
return this._defaultToleranceType;
155+
}
156+
157+
set defaultToleranceType(toleranceType: ImageOptions) {
158+
this._defaultToleranceType = toleranceType;
159+
}
160+
161+
get defaultTolerance(): number {
162+
return this._defaultTolerance;
163+
}
164+
165+
set defaultTolerance(tolerance: number) {
166+
this._defaultTolerance = tolerance;
167+
}
168+
151169
public async compareScreen(options?: IImageCompareOptions) {
152170
options = this.extendOptions(options);
153171
options.imageName = this.increaseImageName(options.imageName || this.testName, options);
@@ -314,13 +332,13 @@ export class ImageHelper {
314332

315333
public compareImages(options: IImageCompareOptions, actual: string, expected: string, output: string) {
316334
const clipRect = {
317-
x: this.options.cropRectangle.x,
318-
y: this.options.cropRectangle.y,
319-
width: this.options.cropRectangle.width,
320-
height: this.options.cropRectangle.height
335+
x: options.cropRectangle.x,
336+
y: options.cropRectangle.y,
337+
width: options.cropRectangle.width,
338+
height: options.cropRectangle.height
321339
}
322340

323-
if (!this.options.keepOriginalImageSize) {
341+
if (!options.keepOriginalImageSize) {
324342
clipRect.x = 0;
325343
clipRect.y = 0;
326344
clipRect.width = undefined;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /