@Test(expected = IllegalArgumentException.class) public void testConstructor_CopyWithNull() throws Exception { new TextAttributes(null); fail("Expected an IllegalArgumentException to be thrown."); }
@Test public void testSetTypeface_Null() throws Exception { TextAttributes attributes = new TextAttributes(); attributes.setTypeface(null); assertEquals(null, attributes.typeface); }
@Test public void testSetEnableDepthTest() throws Exception { TextAttributes attributes = new TextAttributes(); boolean enable = false; attributes.setEnableDepthTest(enable); assertEquals(enable, attributes.enableDepthTest); }
@Test public void testSetTextSize() throws Exception { TextAttributes attributes = new TextAttributes(); float size = 2.5f; attributes.setTextSize(size); assertEquals(size, attributes.textSize, 0.0f); }
@Test(expected = IllegalArgumentException.class) public void testSet_WithNull() throws Exception { TextAttributes attributes = new TextAttributes(); attributes.set(null); fail("Expected an IllegalArgumentException to be thrown."); }
@Test public void testGetTextSize() throws Exception { TextAttributes attributes = new TextAttributes(); float size = 2.5f; attributes.textSize = size; assertEquals(size, attributes.getTextSize(), 1.0e-15); }
@Test public void testGetEnableOutline() throws Exception { TextAttributes attributes = new TextAttributes(); boolean enable = false; attributes.enableOutline = enable; assertEquals(enable, attributes.isEnableOutline()); }
@Test public void testGetOutlineWidth() throws Exception { TextAttributes attributes = new TextAttributes(); float width = 0.0f; attributes.outlineWidth = width; assertEquals(width, attributes.getOutlineWidth(), 1.0e-15); }
@Test public void testGetTypeface_Null() throws Exception { TextAttributes attributes = new TextAttributes(); attributes.typeface = null; assertEquals(null, attributes.getTypeface()); }
@Test public void testSetEnableOutline() throws Exception { TextAttributes attributes = new TextAttributes(); boolean enable = false; attributes.setEnableOutline(enable); assertEquals(enable, attributes.enableOutline); }
@Test public void testSetOutlineWidth() throws Exception { TextAttributes attributes = new TextAttributes(); float width = 0.0f; attributes.setOutlineWidth(width); assertEquals(width, attributes.outlineWidth, 0.0f); } }
@Test public void testGetEnableDepthTest() throws Exception { TextAttributes attributes = new TextAttributes(); boolean enable = false; attributes.enableDepthTest = enable; assertEquals(enable, attributes.isEnableDepthTest()); }
@Test public void testGetTypeface() throws Exception { TextAttributes attributes = new TextAttributes(); Typeface typeface = Typeface.defaultFromStyle(Typeface.NORMAL); attributes.typeface = typeface; assertEquals(typeface, attributes.getTypeface()); }
@Test public void testSetTypeface() throws Exception { TextAttributes attributes = new TextAttributes(); Typeface typeface = Typeface.defaultFromStyle(Typeface.NORMAL); attributes.setTypeface(typeface); assertEquals(typeface, attributes.typeface); }
@Test public void testGetTextColor() throws Exception { TextAttributes attributes = new TextAttributes(); Color black = new Color(0, 0, 0, 1); attributes.textColor = black; assertEquals(black, attributes.getTextColor()); }
@Test public void testGetTextOffset() throws Exception { TextAttributes attributes = new TextAttributes(); Offset lowerLeft = new Offset(WorldWind.OFFSET_PIXELS, 0, WorldWind.OFFSET_PIXELS, 0); attributes.textOffset = lowerLeft; assertEquals(lowerLeft, attributes.getTextOffset()); }
@Test public void testSetTextColor() throws Exception { TextAttributes attributes = new TextAttributes(); Color black = new Color(0, 0, 0, 1); attributes.setTextColor(black); // Verify that the object is an equivalent deep copy. assertEquals(black, attributes.textColor); assertTrue(black != attributes.textColor); }
@Test public void testNullToNonNullAttributesSet() { String text = "Testing"; RenderContext.TextCacheKey textCacheKeyOne = new RenderContext.TextCacheKey().set(text, null); RenderContext.TextCacheKey textCacheKeyTwo = new RenderContext.TextCacheKey().set(text, null); assertTrue("TextCacheKey null to non-null equals pre", textCacheKeyOne.equals(textCacheKeyTwo)); assertTrue("TextCacheKey null to non-null hashcode pre", textCacheKeyOne.hashCode() == textCacheKeyTwo.hashCode()); TextAttributes textAttributes = new TextAttributes(); textAttributes.setOutlineWidth(5); textCacheKeyTwo.set(text, textAttributes); assertFalse("TextCacheKey null to non-null equals post", textCacheKeyOne.equals(textCacheKeyTwo)); assertFalse("TextCacheKey null to non-null hashcode post", textCacheKeyOne.hashCode() == textCacheKeyTwo.hashCode()); }
@Test public void testSetTextOffset() throws Exception { TextAttributes attributes = new TextAttributes(); Offset lowerLeft = new Offset(WorldWind.OFFSET_PIXELS, 0, WorldWind.OFFSET_PIXELS, 0); attributes.setTextOffset(lowerLeft); // Verify that the object is an equivalent deep copy. assertEquals(lowerLeft, attributes.textOffset); assertTrue(lowerLeft != attributes.textOffset); }
@Test public void testNonNullToNullAttributesSet() { String text = "Testing"; TextAttributes textAttributes = new TextAttributes(); textAttributes.setOutlineWidth(5); RenderContext.TextCacheKey textCacheKeyOne = new RenderContext.TextCacheKey().set(text, textAttributes); RenderContext.TextCacheKey textCacheKeyTwo = new RenderContext.TextCacheKey().set(text, textAttributes); assertTrue("TextCacheKey non-null to null equals pre", textCacheKeyOne.equals(textCacheKeyTwo)); assertTrue("TextCacheKey non-null to null hashcode pre", textCacheKeyOne.hashCode() == textCacheKeyTwo.hashCode()); textCacheKeyTwo.set(text, null); assertFalse("TextCacheKey non-null to null equals post", textCacheKeyOne.equals(textCacheKeyTwo)); assertFalse("TextCacheKey non-null to null hashcode post", textCacheKeyOne.hashCode() == textCacheKeyTwo.hashCode()); }