Skip to content
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

[java] Enhance PageSize class to support for predefined and custom Paper Sizes #15052

Merged
merged 27 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
40fd006
Enhance PageSize class to support for predefined and custom Paper Sizes
yvsvarma Jan 9, 2025
270717d
Addressed review comments by updating PageSize constants for direct r…
yvsvarma Jan 11, 2025
f24cf74
added comment on units for the pagesize
yvsvarma Jan 11, 2025
5efe4f8
Updating PageSizeTest to verify new PageSize constants and functionality
yvsvarma Jan 12, 2025
91ee7f4
Merge branch 'trunk' into print-page-size-options
yvsvarma Jan 12, 2025
569f9d1
Merge branch 'trunk' into print-page-size-options
yvsvarma Jan 12, 2025
c1a7eb3
addressing review comments
yvsvarma Jan 13, 2025
520b8e1
Merge branch 'trunk' into print-page-size-options
yvsvarma Jan 15, 2025
a0d57be
Addressed review comments: Added prefixed constants to PageSize and u…
yvsvarma Jan 15, 2025
896791e
Merge branch 'trunk' into print-page-size-options
yvsvarma Jan 16, 2025
5ed619d
Merge branch 'trunk' into print-page-size-options
yvsvarma Jan 16, 2025
0eae862
Merge branch 'trunk' into print-page-size-options
pujagani Jan 16, 2025
0ee9e1b
Merge branch 'trunk' into print-page-size-options
yvsvarma Jan 17, 2025
96c3073
Merge branch 'trunk' into print-page-size-options
yvsvarma Jan 18, 2025
bd8bfa9
updating after format.sh run
yvsvarma Jan 18, 2025
a1b98b2
Merge branch 'trunk' into print-page-size-options
yvsvarma Jan 18, 2025
f94a814
Merge branch 'trunk' into print-page-size-options
yvsvarma Jan 19, 2025
23cc376
Merge branch 'trunk' into print-page-size-options
yvsvarma Jan 19, 2025
ed745a6
Merge branch 'trunk' into print-page-size-options
VietND96 Jan 19, 2025
608e4ba
Merge branch 'trunk' into print-page-size-options
yvsvarma Jan 20, 2025
9df94fa
Merge branch 'trunk' into print-page-size-options
VietND96 Jan 20, 2025
1194a13
Merge branch 'trunk' into print-page-size-options
yvsvarma Jan 21, 2025
100f9ee
Merge branch 'trunk' into print-page-size-options
yvsvarma Jan 22, 2025
4d367b2
addressing review comments to simplify accessing pagesize
yvsvarma Jan 22, 2025
6cbb99c
Merge branch 'trunk' into print-page-size-options
yvsvarma Jan 23, 2025
f5f6d5a
Update PageSizeTest.java
pujagani Jan 23, 2025
50a0547
Merge branch 'trunk' into print-page-size-options
yvsvarma Jan 23, 2025
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
17 changes: 14 additions & 3 deletions java/src/org/openqa/selenium/print/PageSize.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,20 @@
import java.util.Map;

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 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() {
// 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;
Expand All @@ -51,4 +56,10 @@ public Map<String, Object> toMap() {

return options;
}
}

@Override
public String toString() {
return "PageSize[width=" + this.getWidth() + ", height=" + this.getHeight() + "]";
}

}
yvsvarma marked this conversation as resolved.
Show resolved Hide resolved
31 changes: 30 additions & 1 deletion java/test/org/openqa/selenium/print/PageSizeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,33 @@ void setsDefaultHeightWidth() {
assertThat(pageSize.getHeight()).isEqualTo(HEIGHT);
assertThat(pageSize.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);
}

}
yvsvarma marked this conversation as resolved.
Show resolved Hide resolved