11package aquality .selenium .core .configurations ;
22
3+ import aquality .selenium .core .logging .Logger ;
34import aquality .selenium .core .utilities .ISettingsFile ;
45import com .google .inject .Inject ;
56
67import javax .imageio .ImageIO ;
8+ import java .io .File ;
9+ import java .io .IOException ;
710import java .util .Arrays ;
811
912/**
1215 */
1316public class VisualConfiguration implements IVisualConfiguration {
1417 private String imageFormat ;
18+ private Integer maxFullFileNameLength ;
19+ private Float defaultThreshold ;
20+ private Integer comparisonWidth ;
21+ private Integer comparisonHeight ;
22+ private String pathToDumps ;
23+
1524 private final ISettingsFile settingsFile ;
1625
1726 /**
@@ -37,4 +46,57 @@ public String getImageFormat() {
3746 }
3847 return imageFormat ;
3948 }
49+
50+ @ Override
51+ public int getMaxFullFileNameLength () {
52+ if (maxFullFileNameLength == null ) {
53+ maxFullFileNameLength = Integer .valueOf (
54+ settingsFile .getValueOrDefault ("/visualization/maxFullFileNameLength" , 255 ).toString ());
55+ }
56+ return maxFullFileNameLength ;
57+ }
58+
59+ @ Override
60+ public float getDefaultThreshold () {
61+ if (defaultThreshold == null ) {
62+ defaultThreshold = Float .valueOf (
63+ settingsFile .getValueOrDefault ("/visualization/defaultThreshold" , 0.012f ).toString ());
64+ }
65+ return defaultThreshold ;
66+ }
67+
68+ @ Override
69+ public int getComparisonWidth () {
70+ if (comparisonWidth == null ) {
71+ comparisonWidth = Integer .valueOf (
72+ settingsFile .getValueOrDefault ("/visualization/comparisonWidth" , 16 ).toString ());
73+ }
74+ return comparisonWidth ;
75+ }
76+
77+ @ Override
78+ public int getComparisonHeight () {
79+ if (comparisonHeight == null ) {
80+ comparisonHeight = Integer .valueOf (
81+ settingsFile .getValueOrDefault ("/visualization/comparisonHeight" , 16 ).toString ());
82+ }
83+ return comparisonHeight ;
84+ }
85+
86+ @ Override
87+ public String getPathToDumps () {
88+ if (pathToDumps == null ) {
89+ pathToDumps = settingsFile .getValueOrDefault (".visualization.pathToDumps" , "./src/test/resources/VisualDumps/" ).toString ();
90+ if (pathToDumps .startsWith ("." )) {
91+ try {
92+ pathToDumps = new File (pathToDumps ).getCanonicalPath ();
93+ } catch (IOException e ) {
94+ String errorMessage = "Failed to resolve path to dumps: " + e .getMessage ();
95+ Logger .getInstance ().fatal (errorMessage , e );
96+ throw new IllegalArgumentException (errorMessage , e );
97+ }
98+ }
99+ }
100+ return pathToDumps ;
101+ }
40102}
0 commit comments