testimageprimitive.java

来自「考勤管理系统源码」· Java 代码 · 共 79 行

JAVA
79
字号
package com.wiley.compBooks.EJwithUML.Base.HtmlPrimitives.ContentElements;import junit.framework.*;import com.wiley.compBooks.EJwithUML.Base.TestUtilities.*;import com.wiley.compBooks.EJwithUML.Base.HtmlPrimitives.Core.*;import java.io.*;public class TestImagePrimitive extends TestCase{  private TestFileSet testFileSet;  public TestImagePrimitive(String name) throws IOException  {    super(name);    testFileSet = new TestFileSet("C:/EJwithUML2e/UnitTestResults/HtmlPrimitives/ContentElements/ImagePrimitive/");  }  public void testSimpleImage() throws IOException  {    StringBuffer buffer = new StringBuffer();    ImagePrimitive image = new ImagePrimitive("./pic.jpg");    image.buildContent(buffer);    boolean match = testFileSet.fileMatchesGold("SimpleImage.html", buffer.toString());    assertEquals("SimpleImage", match, true);  }  public void testSizedImage() throws IOException  {    StringBuffer buffer = new StringBuffer();    ImagePrimitive image = new ImagePrimitive("./pic.jpg");    image.setSize(50, 50);    image.buildContent(buffer);    boolean match = testFileSet.fileMatchesGold("SizedImage.html", buffer.toString());    assertEquals("SizedImage", match, true);  }  public void testAlternateTextImage() throws IOException  {    StringBuffer buffer = new StringBuffer();    ImagePrimitive image = new ImagePrimitive("./pic.jpg");    image.setAlternateText("A fairly pointless but hopefully diverting picture.");    image.buildContent(buffer);    boolean match = testFileSet.fileMatchesGold("AlternateText.html", buffer.toString());    assertEquals("AlternateText", match, true);  }  public void testStyledImage() throws IOException  {    StringBuffer buffer = new StringBuffer();    ImagePrimitive image = new ImagePrimitive("./pic.jpg");    image.setStyle(Style.NORMAL_IMAGE);    image.buildContent(buffer);    boolean match = testFileSet.fileMatchesGold("StyledImage.html", buffer.toString());    assertEquals("StyledImage", match, true);  }  public void testComplexImage() throws IOException  {    StringBuffer buffer = new StringBuffer();    ImagePrimitive image = new ImagePrimitive("./pic.jpg");    image.setAlternateText("A fairly pointless but hopefully diverting picture.");    image.setSize(50,50);    image.setStyle(Style.NORMAL_IMAGE);    image.buildContent(buffer);    boolean match = testFileSet.fileMatchesGold("ComplexImage.html", buffer.toString());    assertEquals("ComplexImage", match, true);  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?