-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[dotnet] Allow setting of PageDimensions and PageMargins in PrintOptions directly #14593
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
nvborisenko
merged 15 commits into
SeleniumHQ:trunk
from
shbenzer:missing_setters_in_cs_printoptions
Oct 16, 2024
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
1aee887
Added Missing Setters to C# PrintOptions Class
shbenzer b7d44c7
Merge branch 'trunk' into missing_setters_in_cs_printoptions
shbenzer 9660fd2
Merge branch 'trunk' into missing_setters_in_cs_printoptions
shbenzer d3e9f1d
updated inline xml documentation
shbenzer c8be92b
Merge branch 'trunk' into missing_setters_in_cs_printoptions
shbenzer 2a14dca
added handling for nulls in ToDictionary()
shbenzer 7e21b68
optimized to avoid allocation)
shbenzer 0372a8d
Added PrintOptions tests
shbenzer 9999f72
converted, and slightly enhanced JUnit tests, to NUnit
shbenzer 0e75a52
Rework one test
nvborisenko 79f90bf
Will not rework after AI
nvborisenko c778b0d
Merge branch 'trunk' into missing_setters_in_cs_printoptions
shbenzer b84d54b
Removed ability to set PAgeSize or PageMargins as null... added tests…
shbenzer 19a7c21
Fix it and forget
nvborisenko aeaeb13
Merge branch 'trunk' into missing_setters_in_cs_printoptions
nvborisenko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| using NUnit.Framework; | ||
| using System; | ||
|
|
||
| namespace OpenQA.Selenium | ||
| { | ||
| [TestFixture] | ||
| public class PrintTest : DriverTestFixture | ||
| { | ||
| private const string MagicString = "JVBER"; | ||
| private ISupportsPrint printer; | ||
|
|
||
| [SetUp] | ||
| public void LocalSetUp() | ||
| { | ||
| Assert.That(driver, Is.InstanceOf<ISupportsPrint>(), $"Driver does not support {nameof(ISupportsPrint)}."); | ||
|
|
||
| printer = driver as ISupportsPrint; | ||
|
|
||
| driver.Navigate().GoToUrl(this.printPage); | ||
| } | ||
|
|
||
| [Test] | ||
| public void CanPrintPage() | ||
| { | ||
| var pdf = printer.Print(new PrintOptions()); | ||
|
|
||
| Assert.That(pdf.AsBase64EncodedString, Does.Contain(MagicString)); | ||
| } | ||
|
|
||
| [Test] | ||
| public void CanPrintTwoPages() | ||
| { | ||
| var options = new PrintOptions(); | ||
|
|
||
| options.AddPageRangeToPrint("1-2"); | ||
|
|
||
| var pdf = printer.Print(options); | ||
|
|
||
| Assert.That(pdf.AsBase64EncodedString, Does.Contain(MagicString)); | ||
| } | ||
|
|
||
| [Test] | ||
| public void CanPrintWithMostParams() | ||
| { | ||
| var options = new PrintOptions() | ||
| { | ||
| Orientation = PrintOrientation.Landscape, | ||
| ScaleFactor = 0.5, | ||
| PageDimensions = new PrintOptions.PageSize { Width = 200, Height = 100 }, | ||
| PageMargins = new PrintOptions.Margins { Top = 1, Bottom = 1, Left = 2, Right = 2 }, | ||
| OutputBackgroundImages = true, | ||
| ShrinkToFit = false | ||
| }; | ||
|
|
||
| options.AddPageRangeToPrint("1-3"); | ||
|
|
||
| var pdf = printer.Print(options); | ||
|
|
||
| Assert.That(pdf.AsBase64EncodedString, Does.Contain(MagicString)); | ||
| } | ||
|
|
||
| [Test] | ||
| public void PageSizeCannotBeNull() | ||
| { | ||
| Assert.That(() => new PrintOptions { PageDimensions = null }, Throws.InstanceOf<ArgumentNullException>()); | ||
| } | ||
|
|
||
| [Test] | ||
| public void MarginsCannotBeNull() | ||
| { | ||
| Assert.That(() => new PrintOptions { PageMargins = null }, Throws.InstanceOf<ArgumentNullException>()); | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.