1 33 34 package edu.rice.cs.drjava.model.print; 35 36 import edu.rice.cs.drjava.DrJavaTestCase; 37 import junit.framework.Test; 38 import junit.framework.TestSuite; 39 40 import java.awt.*; 41 import java.awt.image.BufferedImage ; 42 import java.awt.print.PageFormat ; 43 import java.awt.print.Printable ; 44 45 49 public final class DrJavaBookTest extends DrJavaTestCase { 50 51 private DrJavaBook book = null; 52 53 56 public DrJavaBookTest(String name) { super(name); } 57 58 61 public static Test suite() { return new TestSuite(DrJavaBookTest.class); } 62 63 public void setUp() throws Exception { 64 super.setUp(); 65 book = new DrJavaBook("import java.io.*;", "simple_file.java", new PageFormat ()); 66 } 67 68 public void tearDown() throws Exception { 69 book = null; 70 super.tearDown(); 71 } 72 73 public void testGetNumberOfPages() { 74 assertEquals("testGetNumberOfPages:", new Integer (1), new Integer (book.getNumberOfPages())); 75 } 76 77 public void testGetPageFormat() { 78 assertEquals("testGetPageFormat:", PageFormat.PORTRAIT, book.getPageFormat(0).getOrientation()); 79 } 80 81 public void testGetPrintable() { 82 Graphics g = (new BufferedImage (100, 100, BufferedImage.TYPE_INT_RGB)).getGraphics(); 83 Printable p = book.getPrintable(0); 84 try { 85 assertEquals("testGetPrintable:", new Integer (Printable.PAGE_EXISTS), 86 new Integer (p.print(g, new PageFormat (), 0))); 87 } 88 catch(Exception e) { fail("testGetPrintable: Unexpected exception!\n" + e); } 89 90 try { 91 p = book.getPrintable(99); 92 fail("previous operation should throw an IndexOutOfBoundsException"); 93 } 94 catch(IndexOutOfBoundsException e) { 95 96 } 97 } 98 } | Popular Tags |