From 40fd0061c3d9deefd7e0274d9dbb023caae81749 Mon Sep 17 00:00:00 2001 From: yvsvarma Date: Wed, 8 Jan 2025 23:21:40 -0600 Subject: [PATCH 1/9] Enhance PageSize class to support for predefined and custom Paper Sizes --- .../org/openqa/selenium/print/PageSize.java | 105 +++++++++++++----- 1 file changed, 79 insertions(+), 26 deletions(-) diff --git a/java/src/org/openqa/selenium/print/PageSize.java b/java/src/org/openqa/selenium/print/PageSize.java index c9c3d78908b12..9ca2b9810760a 100644 --- a/java/src/org/openqa/selenium/print/PageSize.java +++ b/java/src/org/openqa/selenium/print/PageSize.java @@ -25,30 +25,83 @@ public class PageSize { private final double height; private final double width; - public PageSize() { - // Initialize with defaults. A4 paper size defaults in cms. - this.height = 27.94; - this.width = 21.59; - } - - public PageSize(double height, double width) { - this.height = height; - this.width = width; - } - - public double getHeight() { - return height; - } - - public double getWidth() { - return width; - } - - public Map toMap() { - final Map options = new HashMap<>(7); - options.put("height", getHeight()); - options.put("width", getWidth()); - - return options; - } + // Default Constructor (A4 by default) + public PageSize() { + this(PaperSize.A4); // Delegate to predefined size constructor + } + + // Custom Size Constructor + public PageSize(double height, double width) { + this.height = height; + this.width = width; + } + + // Constructor for Predefined Sizes A4,A6,LEGAL,TABLOID using PaperSize Enum + public PageSize(PaperSize paperSize) { + this(paperSize.getHeight(), paperSize.getWidth()); // Delegate to custom size constructor + } + + // Factory Methods for Predefined Sizes + public static PageSize A4() { + return new PageSize(PaperSize.A4); + } + + public static PageSize A6() { + return new PageSize(PaperSize.A6); + } + + public static PageSize LEGAL() { + return new PageSize(PaperSize.LEGAL); + } + + public static PageSize TABLOID() { + return new PageSize(PaperSize.TABLOID); + } + + // Getters for Height and Width + public double getHeight() { + return height; + } + + public double getWidth() { + return width; + } + + // Convert to Map (for serialization or configuration) + public Map toMap() { + final Map options = new HashMap<>(); + options.put("height", getHeight()); + options.put("width", getWidth()); + return options; + } + + // Enum for Predefined Sizes + public enum PaperSize { + A4(27.94, 21.59), + A6(14.8, 10.5), + LEGAL(35.56, 21.59), + TABLOID(43.18, 27.94); + + private final double height; + private final double width; + + PaperSize(double height, double width) { + this.height = height; + this.width = width; + } + + public double getHeight() { + return height; + } + + public double getWidth() { + return width; + } + } + + @Override + public String toString() { + return String.format("PageSize[height=%.2f, width=%.2f]", height, width); +} + } From 270717d17096ed4a1195ee25e5bf70759624c29d Mon Sep 17 00:00:00 2001 From: yvsvarma Date: Sat, 11 Jan 2025 13:22:59 -0600 Subject: [PATCH 2/9] Addressed review comments by updating PageSize constants for direct reference instead of method calls --- .../org/openqa/selenium/print/PageSize.java | 69 ++++--------------- 1 file changed, 13 insertions(+), 56 deletions(-) diff --git a/java/src/org/openqa/selenium/print/PageSize.java b/java/src/org/openqa/selenium/print/PageSize.java index 9ca2b9810760a..758c2e8c0db05 100644 --- a/java/src/org/openqa/selenium/print/PageSize.java +++ b/java/src/org/openqa/selenium/print/PageSize.java @@ -21,41 +21,23 @@ import java.util.Map; public class PageSize { - private final double height; private final double width; - // Default Constructor (A4 by default) - public PageSize() { - this(PaperSize.A4); // Delegate to predefined size constructor - } + // Predefined constants + public static final PageSize A4 = new PageSize(27.94, 21.59); + public static final PageSize LEGAL = new PageSize(35.56, 21.59); + public static final PageSize TABLOID = new PageSize(43.18, 27.94); + public static final PageSize LETTER = new PageSize(27.94, 21.59); - // Custom Size Constructor public PageSize(double height, double width) { this.height = height; this.width = width; } - // Constructor for Predefined Sizes A4,A6,LEGAL,TABLOID using PaperSize Enum - public PageSize(PaperSize paperSize) { - this(paperSize.getHeight(), paperSize.getWidth()); // Delegate to custom size constructor - } - - // Factory Methods for Predefined Sizes - public static PageSize A4() { - return new PageSize(PaperSize.A4); - } - - public static PageSize A6() { - return new PageSize(PaperSize.A6); - } - - public static PageSize LEGAL() { - return new PageSize(PaperSize.LEGAL); - } - - public static PageSize TABLOID() { - return new PageSize(PaperSize.TABLOID); + // Default constructor (e.g., default to A4) + public PageSize() { + this(A4.getHeight(), A4.getWidth()); } // Getters for Height and Width @@ -67,41 +49,16 @@ public double getWidth() { return width; } - // Convert to Map (for serialization or configuration) public Map toMap() { - final Map options = new HashMap<>(); - options.put("height", getHeight()); - options.put("width", getWidth()); - return options; - } - - // Enum for Predefined Sizes - public enum PaperSize { - A4(27.94, 21.59), - A6(14.8, 10.5), - LEGAL(35.56, 21.59), - TABLOID(43.18, 27.94); - - private final double height; - private final double width; - - PaperSize(double height, double width) { - this.height = height; - this.width = width; - } - - public double getHeight() { - return height; - } - - public double getWidth() { - return width; - } + Map map = new HashMap<>(); + map.put("width", width); + map.put("height", height); + return map; } @Override public String toString() { - return String.format("PageSize[height=%.2f, width=%.2f]", height, width); + return "PageSize[width=" + this.getWidth() + ", height=" + this.getHeight() + "]"; } } From f24cf749782d24327c30512b2fb95afd4884fbc9 Mon Sep 17 00:00:00 2001 From: yvsvarma Date: Sat, 11 Jan 2025 14:15:40 -0600 Subject: [PATCH 3/9] added comment on units for the pagesize --- java/src/org/openqa/selenium/print/PageSize.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/java/src/org/openqa/selenium/print/PageSize.java b/java/src/org/openqa/selenium/print/PageSize.java index 758c2e8c0db05..53670519186e6 100644 --- a/java/src/org/openqa/selenium/print/PageSize.java +++ b/java/src/org/openqa/selenium/print/PageSize.java @@ -25,11 +25,11 @@ public class PageSize { private final double width; // Predefined constants - public static final PageSize A4 = new PageSize(27.94, 21.59); - public static final PageSize LEGAL = new PageSize(35.56, 21.59); - public static final PageSize TABLOID = new PageSize(43.18, 27.94); - public static final PageSize LETTER = new PageSize(27.94, 21.59); - + public static final PageSize A4 = new PageSize(27.94, 21.59); // A4 size in cm + public static final PageSize LEGAL = new PageSize(35.56, 21.59); // Legal size in cm + public static final PageSize TABLOID = new PageSize(43.18, 27.94); // Tabloid size in cm + public static final PageSize LETTER = new PageSize(27.94, 21.59); // Letter size in cm + public PageSize(double height, double width) { this.height = height; this.width = width; From 5efe4f81482460744d21035c4401f6624c30cf91 Mon Sep 17 00:00:00 2001 From: yvsvarma Date: Sat, 11 Jan 2025 18:48:53 -0600 Subject: [PATCH 4/9] Updating PageSizeTest to verify new PageSize constants and functionality --- java/test/org/openqa/selenium/print/PageSizeTest.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/java/test/org/openqa/selenium/print/PageSizeTest.java b/java/test/org/openqa/selenium/print/PageSizeTest.java index 07a85dc60301e..934579f66b93c 100644 --- a/java/test/org/openqa/selenium/print/PageSizeTest.java +++ b/java/test/org/openqa/selenium/print/PageSizeTest.java @@ -26,8 +26,8 @@ class PageSizeTest { // Defaults assertion - private static final double HEIGHT = 27.94; - private static final double WIDTH = 21.59; + private static final double HEIGHT = 27.94; //Size in cm + private static final double WIDTH = 21.59; //Size in cm @Test void setsDefaultHeightWidth() { @@ -35,5 +35,10 @@ void setsDefaultHeightWidth() { assertThat(pageSize.getHeight()).isEqualTo(HEIGHT); assertThat(pageSize.getWidth()).isEqualTo(WIDTH); + + PageSize pageSizeLegal = PageSize.LEGAL; + assertThat(pageSizeLegal.getHeight()).isEqualTo(HEIGHT); + assertThat(pageSizeLegal.getWidth()).isEqualTo(WIDTH); + } } From c1a7eb363c431ae38c0efe666269d6233e4916eb Mon Sep 17 00:00:00 2001 From: yvsvarma Date: Mon, 13 Jan 2025 02:03:40 -0600 Subject: [PATCH 5/9] addressing review comments --- .../org/openqa/selenium/print/PageSize.java | 53 ++++++++++--------- .../openqa/selenium/print/PageSizeTest.java | 38 ++++++++++--- 2 files changed, 58 insertions(+), 33 deletions(-) diff --git a/java/src/org/openqa/selenium/print/PageSize.java b/java/src/org/openqa/selenium/print/PageSize.java index 53670519186e6..f6d48ccd42b09 100644 --- a/java/src/org/openqa/selenium/print/PageSize.java +++ b/java/src/org/openqa/selenium/print/PageSize.java @@ -24,41 +24,42 @@ public class PageSize { private final double height; private final double width; - // Predefined constants - public static final PageSize A4 = new PageSize(27.94, 21.59); // A4 size in cm + // Reference for predefined page size constants: https://www.agooddaytoprint.com/page/paper-size-chart-faq + public static final PageSize A4 = new PageSize(29.7, 21.0); // A4 size in cm public static final PageSize LEGAL = new PageSize(35.56, 21.59); // Legal size in cm public static final PageSize TABLOID = new PageSize(43.18, 27.94); // Tabloid size in cm public static final PageSize LETTER = new PageSize(27.94, 21.59); // Letter size in cm - - public PageSize(double height, double width) { - this.height = height; - this.width = width; - } - // Default constructor (e.g., default to A4) - public PageSize() { - this(A4.getHeight(), A4.getWidth()); - } + public PageSize() { + // Initialize with defaults. A4 paper size defaults in cms. + this.height = 27.94; + this.width = 21.59; + } - // Getters for Height and Width - public double getHeight() { - return height; - } + public PageSize(double height, double width) { + this.height = height; + this.width = width; + } - public double getWidth() { - return width; - } + public double getHeight() { + return height; + } - public Map toMap() { - Map map = new HashMap<>(); - map.put("width", width); - map.put("height", height); - return map; - } + public double getWidth() { + return width; + } + + public Map toMap() { + final Map options = new HashMap<>(7); + options.put("height", getHeight()); + options.put("width", getWidth()); + + return options; + } @Override public String toString() { return "PageSize[width=" + this.getWidth() + ", height=" + this.getHeight() + "]"; -} + } -} +} \ No newline at end of file diff --git a/java/test/org/openqa/selenium/print/PageSizeTest.java b/java/test/org/openqa/selenium/print/PageSizeTest.java index 934579f66b93c..12ba77bc48303 100644 --- a/java/test/org/openqa/selenium/print/PageSizeTest.java +++ b/java/test/org/openqa/selenium/print/PageSizeTest.java @@ -26,8 +26,8 @@ class PageSizeTest { // Defaults assertion - private static final double HEIGHT = 27.94; //Size in cm - private static final double WIDTH = 21.59; //Size in cm + private static final double HEIGHT = 27.94; + private static final double WIDTH = 21.59; @Test void setsDefaultHeightWidth() { @@ -35,10 +35,34 @@ void setsDefaultHeightWidth() { assertThat(pageSize.getHeight()).isEqualTo(HEIGHT); assertThat(pageSize.getWidth()).isEqualTo(WIDTH); - - PageSize pageSizeLegal = PageSize.LEGAL; - assertThat(pageSizeLegal.getHeight()).isEqualTo(HEIGHT); - assertThat(pageSizeLegal.getWidth()).isEqualTo(WIDTH); + } + + @Test + void verifiesPageSizeA4() { + PageSize pageSize = PageSize.A4; + assertThat(pageSize.getHeight()).isEqualTo(HEIGHT); + assertThat(pageSize.getWidth()).isEqualTo(WIDTH); + } + @Test + void verifiesPageSizeLegal() { + PageSize pageSize = PageSize.LEGAL; + assertThat(pageSize.getHeight()).isEqualTo(HEIGHT); + assertThat(pageSize.getWidth()).isEqualTo(WIDTH); } -} + + @Test + void verifiesPageSizeLetter() { + PageSize pageSize = PageSize.LETTER; + assertThat(pageSize.getHeight()).isEqualTo(HEIGHT); + assertThat(pageSize.getWidth()).isEqualTo(WIDTH); + } + + @Test + void verifiesPageSizeTabloid() { + PageSize pageSize = PageSize.TABLOID; + assertThat(pageSize.getHeight()).isEqualTo(HEIGHT); + assertThat(pageSize.getWidth()).isEqualTo(WIDTH); + } + +} \ No newline at end of file From a0d57bec5bd7ee46436ee378821fba209d6378cf Mon Sep 17 00:00:00 2001 From: yvsvarma Date: Wed, 15 Jan 2025 09:34:47 -0600 Subject: [PATCH 6/9] Addressed review comments: Added prefixed constants to PageSize and updated tests to validate predefined sizes. --- .../org/openqa/selenium/print/PageSize.java | 22 ++++++---- .../openqa/selenium/print/PageSizeTest.java | 44 ++++++++----------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/java/src/org/openqa/selenium/print/PageSize.java b/java/src/org/openqa/selenium/print/PageSize.java index f6d48ccd42b09..8b7a594c3d864 100644 --- a/java/src/org/openqa/selenium/print/PageSize.java +++ b/java/src/org/openqa/selenium/print/PageSize.java @@ -25,15 +25,14 @@ public class PageSize { private final double width; // Reference for predefined page size constants: https://www.agooddaytoprint.com/page/paper-size-chart-faq - public static final PageSize A4 = new PageSize(29.7, 21.0); // A4 size in cm - public static final PageSize LEGAL = new PageSize(35.56, 21.59); // Legal size in cm - public static final PageSize TABLOID = new PageSize(43.18, 27.94); // Tabloid size in cm - public static final PageSize LETTER = new PageSize(27.94, 21.59); // Letter size in cm + public static final PageSize ISO_A4 = new PageSize(29.7, 21.0); // ISO_A4 size in cm + public static final PageSize US_LEGAL = new PageSize(35.56, 21.59); // US_LEGAL size in cm + public static final PageSize ANSI_TABLOID = new PageSize(43.18, 27.94); // ANSI_TABLOID size in cm + public static final PageSize US_LETTER = new PageSize(27.94, 21.59); // US_LETTER size in cm public PageSize() { - // Initialize with defaults. A4 paper size defaults in cms. - this.height = 27.94; - this.width = 21.59; + // Initialize with defaults. ISO_A4 paper size defaults in cms. + this(ISO_A4.getHeight(), ISO_A4.getWidth()); } public PageSize(double height, double width) { @@ -49,6 +48,13 @@ public double getWidth() { return width; } + public static PageSize setPageSize(PageSize pageSize) { + if (pageSize == null) { + throw new IllegalArgumentException("Page size cannot be null"); + } + return new PageSize(pageSize.getHeight(), pageSize.getWidth()); + } + public Map toMap() { final Map options = new HashMap<>(7); options.put("height", getHeight()); @@ -60,6 +66,6 @@ public Map toMap() { @Override public String toString() { return "PageSize[width=" + this.getWidth() + ", height=" + this.getHeight() + "]"; - } + } } \ No newline at end of file diff --git a/java/test/org/openqa/selenium/print/PageSizeTest.java b/java/test/org/openqa/selenium/print/PageSizeTest.java index 12ba77bc48303..cdf762b5afc2b 100644 --- a/java/test/org/openqa/selenium/print/PageSizeTest.java +++ b/java/test/org/openqa/selenium/print/PageSizeTest.java @@ -25,44 +25,38 @@ @Tag("UnitTests") class PageSizeTest { - // Defaults assertion - private static final double HEIGHT = 27.94; - private static final double WIDTH = 21.59; - - @Test - void setsDefaultHeightWidth() { + @Test + void setsDefaultHeightWidth() { PageSize pageSize = new PageSize(); - - assertThat(pageSize.getHeight()).isEqualTo(HEIGHT); - assertThat(pageSize.getWidth()).isEqualTo(WIDTH); + assertThat(pageSize.getHeight()).isEqualTo(29.7); + assertThat(pageSize.getWidth()).isEqualTo(21.0); } - @Test + @Test void verifiesPageSizeA4() { - PageSize pageSize = PageSize.A4; - assertThat(pageSize.getHeight()).isEqualTo(HEIGHT); - assertThat(pageSize.getWidth()).isEqualTo(WIDTH); + PageSize pageSize = PageSize.setPageSize(PageSize.ISO_A4); + assertThat(pageSize.getHeight()).isEqualTo(29.7); + assertThat(pageSize.getWidth()).isEqualTo(21.0); } - @Test + @Test void verifiesPageSizeLegal() { - PageSize pageSize = PageSize.LEGAL; - assertThat(pageSize.getHeight()).isEqualTo(HEIGHT); - assertThat(pageSize.getWidth()).isEqualTo(WIDTH); + PageSize pageSize = PageSize.setPageSize(PageSize.US_LEGAL); + assertThat(pageSize.getHeight()).isEqualTo(35.56); + assertThat(pageSize.getWidth()).isEqualTo(21.59); } - @Test + @Test void verifiesPageSizeLetter() { - PageSize pageSize = PageSize.LETTER; - assertThat(pageSize.getHeight()).isEqualTo(HEIGHT); - assertThat(pageSize.getWidth()).isEqualTo(WIDTH); + PageSize pageSize = PageSize.setPageSize(PageSize.US_LETTER); + assertThat(pageSize.getHeight()).isEqualTo(27.94); + assertThat(pageSize.getWidth()).isEqualTo(21.59); } @Test void verifiesPageSizeTabloid() { - PageSize pageSize = PageSize.TABLOID; - assertThat(pageSize.getHeight()).isEqualTo(HEIGHT); - assertThat(pageSize.getWidth()).isEqualTo(WIDTH); + PageSize pageSize = PageSize.setPageSize(PageSize.ANSI_TABLOID); + assertThat(pageSize.getHeight()).isEqualTo(43.18); + assertThat(pageSize.getWidth()).isEqualTo(27.94); } - } \ No newline at end of file From bd8bfa99c1340e511466d8cfaf8289884a15a0b9 Mon Sep 17 00:00:00 2001 From: yvsvarma Date: Sat, 18 Jan 2025 09:17:49 -0600 Subject: [PATCH 7/9] updating after format.sh run --- .../org/openqa/selenium/print/PageSize.java | 20 ++++++++--------- .../openqa/selenium/print/PageSizeTest.java | 22 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/java/src/org/openqa/selenium/print/PageSize.java b/java/src/org/openqa/selenium/print/PageSize.java index b7e260af3c2c9..a673fda24ec45 100644 --- a/java/src/org/openqa/selenium/print/PageSize.java +++ b/java/src/org/openqa/selenium/print/PageSize.java @@ -26,16 +26,17 @@ public class PageSize { private final double height; private final double width; - // Reference for predefined page size constants: https://www.agooddaytoprint.com/page/paper-size-chart-faq - public static final PageSize ISO_A4 = new PageSize(29.7, 21.0); // ISO_A4 size in cm - public static final PageSize US_LEGAL = new PageSize(35.56, 21.59); // US_LEGAL size in cm - public static final PageSize ANSI_TABLOID = new PageSize(43.18, 27.94); // ANSI_TABLOID size in cm - public static final PageSize US_LETTER = new PageSize(27.94, 21.59); // US_LETTER size in cm + // Reference for predefined page size constants: + // https://www.agooddaytoprint.com/page/paper-size-chart-faq + public static final PageSize ISO_A4 = new PageSize(29.7, 21.0); // ISO_A4 size in cm + public static final PageSize US_LEGAL = new PageSize(35.56, 21.59); // US_LEGAL size in cm + public static final PageSize ANSI_TABLOID = new PageSize(43.18, 27.94); // ANSI_TABLOID size in cm + public static final PageSize US_LETTER = new PageSize(27.94, 21.59); // US_LETTER size in cm public PageSize() { // Initialize with defaults. ISO_A4 paper size defaults in cms. this(ISO_A4.getHeight(), ISO_A4.getWidth()); - } + } public PageSize(double height, double width) { this.height = height; @@ -65,9 +66,8 @@ public Map toMap() { return options; } - @Override - public String toString() { + @Override + public String toString() { return "PageSize[width=" + this.getWidth() + ", height=" + this.getHeight() + "]"; } - -} \ No newline at end of file +} diff --git a/java/test/org/openqa/selenium/print/PageSizeTest.java b/java/test/org/openqa/selenium/print/PageSizeTest.java index cdf762b5afc2b..695e16dedbac6 100644 --- a/java/test/org/openqa/selenium/print/PageSizeTest.java +++ b/java/test/org/openqa/selenium/print/PageSizeTest.java @@ -25,38 +25,38 @@ @Tag("UnitTests") class PageSizeTest { - @Test - void setsDefaultHeightWidth() { + @Test + void setsDefaultHeightWidth() { PageSize pageSize = new PageSize(); assertThat(pageSize.getHeight()).isEqualTo(29.7); assertThat(pageSize.getWidth()).isEqualTo(21.0); } - @Test - void verifiesPageSizeA4() { + @Test + void verifiesPageSizeA4() { PageSize pageSize = PageSize.setPageSize(PageSize.ISO_A4); assertThat(pageSize.getHeight()).isEqualTo(29.7); assertThat(pageSize.getWidth()).isEqualTo(21.0); } - @Test - void verifiesPageSizeLegal() { + @Test + void verifiesPageSizeLegal() { PageSize pageSize = PageSize.setPageSize(PageSize.US_LEGAL); assertThat(pageSize.getHeight()).isEqualTo(35.56); assertThat(pageSize.getWidth()).isEqualTo(21.59); } - @Test - void verifiesPageSizeLetter() { + @Test + void verifiesPageSizeLetter() { PageSize pageSize = PageSize.setPageSize(PageSize.US_LETTER); assertThat(pageSize.getHeight()).isEqualTo(27.94); assertThat(pageSize.getWidth()).isEqualTo(21.59); } - @Test - void verifiesPageSizeTabloid() { + @Test + void verifiesPageSizeTabloid() { PageSize pageSize = PageSize.setPageSize(PageSize.ANSI_TABLOID); assertThat(pageSize.getHeight()).isEqualTo(43.18); assertThat(pageSize.getWidth()).isEqualTo(27.94); } -} \ No newline at end of file +} From 4d367b24f0d2e042a2121249ddf70406867b7149 Mon Sep 17 00:00:00 2001 From: yvsvarma Date: Wed, 22 Jan 2025 00:47:15 -0600 Subject: [PATCH 8/9] addressing review comments to simplify accessing pagesize --- .../openqa/selenium/print/PageSizeTest.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/java/test/org/openqa/selenium/print/PageSizeTest.java b/java/test/org/openqa/selenium/print/PageSizeTest.java index 695e16dedbac6..deef7d99f7217 100644 --- a/java/test/org/openqa/selenium/print/PageSizeTest.java +++ b/java/test/org/openqa/selenium/print/PageSizeTest.java @@ -34,29 +34,30 @@ void setsDefaultHeightWidth() { @Test void verifiesPageSizeA4() { - PageSize pageSize = PageSize.setPageSize(PageSize.ISO_A4); - assertThat(pageSize.getHeight()).isEqualTo(29.7); - assertThat(pageSize.getWidth()).isEqualTo(21.0); + PrintOptions printOptions = new PrintOptions(); + printOptions.setPageSize(PageSize.ISO_A4); + assertThat(printOptions.getPageSize().getHeight()).isEqualTo(29.7); + assertThat(printOptions.getPageSize().getWidth()).isEqualTo(21.0); } @Test void verifiesPageSizeLegal() { - PageSize pageSize = PageSize.setPageSize(PageSize.US_LEGAL); - assertThat(pageSize.getHeight()).isEqualTo(35.56); - assertThat(pageSize.getWidth()).isEqualTo(21.59); + printOptions.setPageSize(PageSize.US_LEGAL); + assertThat(printOptions.getPageSize().getHeight()).isEqualTo(35.56); + assertThat(printOptions.getPageSize().getWidth()).isEqualTo(21.59); } @Test void verifiesPageSizeLetter() { - PageSize pageSize = PageSize.setPageSize(PageSize.US_LETTER); - assertThat(pageSize.getHeight()).isEqualTo(27.94); - assertThat(pageSize.getWidth()).isEqualTo(21.59); + printOptions.setPageSize(PageSize.US_LETTER); + assertThat(printOptions.getPageSize().getHeight()).isEqualTo(27.94); + assertThat(printOptions.getPageSize().getWidth()).isEqualTo(21.59); } @Test void verifiesPageSizeTabloid() { - PageSize pageSize = PageSize.setPageSize(PageSize.ANSI_TABLOID); - assertThat(pageSize.getHeight()).isEqualTo(43.18); - assertThat(pageSize.getWidth()).isEqualTo(27.94); + printOptions.setPageSize(PageSize.ANSI_TABLOID); + assertThat(printOptions.getPageSize().getHeight()).isEqualTo(43.18); + assertThat(printOptions.getPageSize().getWidth()).isEqualTo(27.94); } } From f5f6d5a410b4967d55648fe2818b7c66bfad8ae9 Mon Sep 17 00:00:00 2001 From: Puja Jagani Date: Thu, 23 Jan 2025 12:36:29 +0530 Subject: [PATCH 9/9] Update PageSizeTest.java --- java/test/org/openqa/selenium/print/PageSizeTest.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/java/test/org/openqa/selenium/print/PageSizeTest.java b/java/test/org/openqa/selenium/print/PageSizeTest.java index deef7d99f7217..ec8240f73c309 100644 --- a/java/test/org/openqa/selenium/print/PageSizeTest.java +++ b/java/test/org/openqa/selenium/print/PageSizeTest.java @@ -19,12 +19,20 @@ import static org.assertj.core.api.Assertions.assertThat; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @Tag("UnitTests") class PageSizeTest { + private PrintOptions printOptions; + + @BeforeEach + void setUp() { + printOptions = new PrintOptions(); + } + @Test void setsDefaultHeightWidth() { PageSize pageSize = new PageSize(); @@ -34,7 +42,7 @@ void setsDefaultHeightWidth() { @Test void verifiesPageSizeA4() { - PrintOptions printOptions = new PrintOptions(); + printOptions.setPageSize(PageSize.ISO_A4); assertThat(printOptions.getPageSize().getHeight()).isEqualTo(29.7); assertThat(printOptions.getPageSize().getWidth()).isEqualTo(21.0);