Skip to content

Commit

Permalink
Expose ScrollOption
Browse files Browse the repository at this point in the history
  • Loading branch information
FriggaHel committed Dec 18, 2024
1 parent c859c5c commit 43e5be3
Showing 1 changed file with 52 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.saucelabs.visual.model;

import com.saucelabs.visual.graphql.type.ScrollOption;
import com.saucelabs.visual.graphql.type.SelectorIn;
import java.util.Arrays;
import java.util.List;
Expand All @@ -15,6 +16,7 @@ public class FullPageScreenshotConfig {
private int scrollLimit;
private String scrollElement;
private SelectorIn nativeClipSelector;
private ScrollOption scrollOption;

public FullPageScreenshotConfig(
int delayAfterScrollMs,
Expand All @@ -30,24 +32,46 @@ public FullPageScreenshotConfig(
hideScrollBars,
scrollLimit,
scrollElement,
null,
null);
}

public FullPageScreenshotConfig(
int delayAfterScrollMs,
Boolean disableCSSAnimation,
List<String> hideAfterFirstScroll,
Boolean hideScrollBars,
int scrollLimit,
String scrollElement,
SelectorIn nativeClipSelector) {
this(
delayAfterScrollMs,
disableCSSAnimation,
hideAfterFirstScroll,
hideScrollBars,
scrollLimit,
scrollElement,
nativeClipSelector,
null);
}

private FullPageScreenshotConfig(
int delayAfterScrollMs,
Boolean disableCSSAnimation,
List<String> hideAfterFirstScroll,
Boolean hideScrollBars,
int scrollLimit,
String scrollElement,
SelectorIn nativeClipSelector) {
SelectorIn nativeClipSelector,
ScrollOption scrollOption) {
this.delayAfterScrollMs = delayAfterScrollMs;
this.disableCSSAnimation = disableCSSAnimation;
this.hideAfterFirstScroll = hideAfterFirstScroll;
this.hideScrollBars = hideScrollBars;
this.scrollLimit = scrollLimit;
this.scrollElement = scrollElement;
this.nativeClipSelector = nativeClipSelector;
this.scrollOption = scrollOption;
}

public static class Builder {
Expand All @@ -58,6 +82,7 @@ public static class Builder {
private int scrollLimit;
private String scrollElement;
private SelectorIn nativeClipSelector;
private ScrollOption scrollOption;

public Builder withDelayAfterScrollMs(int delayAfterScrollMs) {
this.delayAfterScrollMs = delayAfterScrollMs;
Expand Down Expand Up @@ -106,6 +131,17 @@ public Builder withNativeClipSelector(SelectorIn nativeClipSelector) {
return this;
}

/**
* Only effective for native app testing
*
* @param scrollOption ScrollOption to select which scroll behavior Full-Page screenshot should have.
* @return Builder instance
*/
public Builder withScrollOption(ScrollOption scrollOption) {
this.scrollOption = scrollOption;
return this;
}

public FullPageScreenshotConfig build() {
return new FullPageScreenshotConfig(
delayAfterScrollMs,
Expand All @@ -114,7 +150,8 @@ public FullPageScreenshotConfig build() {
hideScrollBars,
scrollLimit,
scrollElement,
nativeClipSelector);
nativeClipSelector,
scrollOption);
}
}

Expand Down Expand Up @@ -183,4 +220,17 @@ public SelectorIn getNativeClipSelector() {
public void setNativeClipSelector(SelectorIn nativeClipSelector) {
this.nativeClipSelector = nativeClipSelector;
}

public ScrollOption getScrollOption() {
return scrollOption;
}

/**
* Only effective for native app testing
*
* @param scrollOption ScrollOption to use
*/
public void setScrollOption(ScrollOption scrollOption) {
this.scrollOption = scrollOption;
}
}

0 comments on commit 43e5be3

Please sign in to comment.