-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77aafe7
commit 6a44daf
Showing
1 changed file
with
53 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package ca.mcgill.cs.jetuml.views; | ||
|
||
import static ca.mcgill.cs.jetuml.testutils.GeometryUtils.osDependent; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotSame; | ||
import static org.junit.jupiter.api.Assertions.assertSame; | ||
|
||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import ca.mcgill.cs.jetuml.geom.Dimension; | ||
import ca.mcgill.cs.jetuml.views.StringViewer.Alignment; | ||
import ca.mcgill.cs.jetuml.views.StringViewer.TextDecoration; | ||
|
||
public class TestStringViewer { | ||
|
||
private StringViewer topCenter; | ||
private StringViewer topCenterPadded; | ||
private StringViewer topCenterBold; | ||
private StringViewer bottomCenterPadded; | ||
|
||
@BeforeEach | ||
public void setup() | ||
{ | ||
topCenter = StringViewer.get(Alignment.TOP_CENTER); | ||
topCenterPadded = StringViewer.get(Alignment.TOP_CENTER, TextDecoration.PADDED); | ||
topCenterBold = StringViewer.get(Alignment.TOP_CENTER, TextDecoration.BOLD); | ||
bottomCenterPadded = StringViewer.get(Alignment.BOTTOM_CENTER, TextDecoration.PADDED); | ||
} | ||
|
||
|
||
@Test | ||
public void testFlyweightProperty() | ||
{ | ||
StringViewer stringViewer = StringViewer.get(Alignment.TOP_CENTER); | ||
|
||
assertNotSame(topCenterPadded, stringViewer); | ||
assertNotSame(bottomCenterPadded, stringViewer); | ||
assertSame(topCenter, stringViewer); | ||
} | ||
|
||
@Test | ||
public void testDimensionEmptyPaddedNoPaddedBold() | ||
{ | ||
assertEquals(topCenter.getDimension(""), new Dimension(0, 0)); | ||
assertEquals(topCenterPadded.getDimension(""), new Dimension(0, 0)); | ||
assertEquals(topCenter.getDimension("Display String"), new Dimension(osDependent(69, 69, 69), osDependent(12, 12, 12))); | ||
assertEquals(topCenterBold.getDimension("Display String"), new Dimension(osDependent(69, 69, 69), osDependent(12, 12, 12))); | ||
assertEquals(topCenterPadded.getDimension("Display String"), new Dimension(osDependent(83, 83, 83), osDependent(26, 26, 26))); | ||
} | ||
|
||
|
||
} |