Skip to content

refactor(compare): add waitOnCreatingInitialSnapshot #231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/appium-driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,9 @@ export class AppiumDriver {
// First time capture
if (!existsSync(pathExpectedImage)) {
const pathActualImage = resolvePath(this._storageByDeviceName, imageName.replace(".", "_actual."));
if (this.imageHelper.waitOnCreatingInitialSnapshot > 0) {
await this.driver.wait(this.imageHelper.waitOnCreatingInitialSnapshot);
}
await this.takeScreenshot(pathActualImage);

if (rect) {
Expand Down
2 changes: 2 additions & 0 deletions lib/image-helper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ export declare class ImageHelper {
private _args;
private _imageCropRect;
private _blockOutAreas;
private _waitOnCreatingInitialSnapshot;
constructor(_args: INsCapabilities);
waitOnCreatingInitialSnapshot: number;
imageCropRect: IRectangle;
blockOutAreas: IRectangle[];
imageOutputLimit(): ImageOptions;
Expand Down
13 changes: 12 additions & 1 deletion lib/image-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,19 @@ export class ImageHelper {

private _imageCropRect: IRectangle;
private _blockOutAreas: IRectangle[];
private _waitOnCreatingInitialSnapshot: number;

constructor(private _args: INsCapabilities) {
}

get waitOnCreatingInitialSnapshot() {
return this._waitOnCreatingInitialSnapshot;
}

set waitOnCreatingInitialSnapshot(waitOnCreatingInitialSnapshot: number) {
this._waitOnCreatingInitialSnapshot = waitOnCreatingInitialSnapshot;
}

get imageCropRect(): IRectangle {
return this._imageCropRect;
}
Expand Down Expand Up @@ -103,9 +112,11 @@ export class ImageHelper {

if (typeThreshold == ImageOptions.percent) {
valueThreshold = Math.floor(valueThreshold * 100);
console.log(`Using ${valueThreshold}\ ${typeThreshold} tolerance`);
} else {
console.log(`Using ${valueThreshold} tolerance`);
}

console.log(`Using ${valueThreshold}\ ${typeThreshold} tolerance`);
const result = this.runDiff(diff, output);
this._blockOutAreas = undefined;
return result;
Expand Down