-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a couple of utility methods to PageSize. Brought equals and toS…
…tring in line with other model classes
- Loading branch information
Showing
2 changed files
with
114 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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
61 changes: 61 additions & 0 deletions
61
sejda-model/src/test/java/org/sejda/model/PageSizeTest.java
This file contains 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,61 @@ | ||
package org.sejda.model; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
/** | ||
* Test class for {@link PageSize}. | ||
* <p> | ||
* This class tests the functionality of the `rotate` method in `PageSize` class, which swaps the width and height, | ||
* effectively changing the page's orientation between portrait and landscape. | ||
*/ | ||
public class PageSizeTest { | ||
|
||
@Test | ||
public void testToPortraitFromLandscape() { | ||
var landscape = new PageSize(200, 100, "Landscape"); | ||
var result = landscape.toPortrait(); | ||
|
||
assertFalse(result.isLandscape()); | ||
assertEquals(100, result.getWidth()); | ||
assertEquals(200, result.getHeight()); | ||
assertNotEquals(landscape, result); | ||
} | ||
|
||
@Test | ||
public void testToPortraitFromPortrait() { | ||
var portrait = new PageSize(100, 200, "Portrait"); | ||
var result = portrait.toPortrait(); | ||
|
||
assertFalse(result.isLandscape()); | ||
assertEquals(100, result.getWidth()); | ||
assertEquals(200, result.getHeight()); | ||
assertEquals(portrait, result); | ||
} | ||
|
||
@Test | ||
public void testToLandscapeFromPortrait() { | ||
var portrait = new PageSize(100, 200, "Portrait"); | ||
var result = portrait.toLandscape(); | ||
|
||
assertTrue(result.isLandscape()); | ||
assertEquals(200, result.getWidth()); | ||
assertEquals(100, result.getHeight()); | ||
assertNotEquals(portrait, result); | ||
} | ||
|
||
@Test | ||
public void testToLandscapeFromLandscape() { | ||
var landscape = new PageSize(200, 100, "Landscape"); | ||
var result = landscape.toLandscape(); | ||
|
||
assertTrue(result.isLandscape()); | ||
assertEquals(200, result.getWidth()); | ||
assertEquals(100, result.getHeight()); | ||
assertEquals(landscape, result); | ||
} | ||
} |