/* * AppleCommander - An Apple ][ image utility. * Copyright (C) 2002 by Robert Greene * robgreene at users.sourceforge.net * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package com.webcodepro.applecommander.test; import java.io.IOException; import java.util.List; import junit.framework.TestCase; import com.webcodepro.applecommander.storage.ApplesoftFileFilter; import com.webcodepro.applecommander.storage.BinaryFileFilter; import com.webcodepro.applecommander.storage.Disk; import com.webcodepro.applecommander.storage.FileEntry; import com.webcodepro.applecommander.storage.FormattedDisk; import com.webcodepro.applecommander.storage.GraphicsFileFilter; import com.webcodepro.applecommander.storage.IntegerBasicFileFilter; import com.webcodepro.applecommander.storage.TextFileFilter; import com.webcodepro.applecommander.storage.FormattedDisk.DiskUsage; /** * Test DiskHelper and its related Apple2 classes. *

* Date created: Oct 3, 2002 11:35:26 PM * @author: Rob Greene */ public class DiskHelperTest extends TestCase { public DiskHelperTest(String name) { super(name); } public static void main(String[] args) { junit.textui.TestRunner.run(DiskHelperTest.class); } public void testLoadDos33() throws IOException { FormattedDisk disk = showDirectory("C:/My Apple2/Disks/DOS 3.3.po"); assertApplesoftFile(disk, "HELLO"); assertIntegerFile(disk, "ANIMALS"); assertTextFile(disk, "APPLE PROMS"); assertBinaryFile(disk, "BOOT13"); } public void testLoadMaster() throws IOException { showDirectory("C:/My Apple2/Disks/MASTER.DSK"); } public void testLoadGalacticAttack1() throws IOException { showDirectory("C:/My Apple2/Disks/galatt.dsk"); } public void testLoadProdos() throws IOException { FormattedDisk disk = showDirectory("C:/My Apple2/Disks/Prodos.dsk"); assertApplesoftFile(disk, "COPY.ME"); assertBinaryFile(disk, "SETTINGS"); assertBinaryFile(disk, "PRODOS"); } public void testLoadMarbleMadness() throws IOException { showDirectory("C:/My Apple2/Disks/Marble Madness (1985)(Electronic Arts).2mg"); } public void testLoadHd1() throws IOException { showDirectory("C:/My Apple2/ApplePC/hd1.hdv"); } public void testRdosBoot() throws IOException { showDirectory("C:/My Apple2/Disks/RDOSboot.dsk"); } public void testSsiSave() throws IOException { showDirectory("C:/My Apple2/Disks/SSIsave.dsk"); } public void testPhan2d1() throws IOException { FormattedDisk disk = showDirectory("C:/My Apple2/Disks/phan2d1.dsk"); assertApplesoftFile(disk, "PHANTASIE II"); assertBinaryFile(disk, "TWN21"); assertTextFile(disk, "ITEM"); assertGraphicsFile(disk, "ICE DRAGON"); } public void testPhan2d2() throws IOException { showDirectory("C:/My Apple2/Disks/phan2d2.dsk"); } public void testPhantasie1() throws IOException { showDirectory("C:/My Apple2/Disks/Phantasie1.dsk"); } public void testPhantasie2() throws IOException { showDirectory("C:/My Apple2/Disks/Phantasie2.dsk"); } public void testCavernsOfFreitag() throws IOException { FormattedDisk disk = showDirectory("C:/My Apple2/Disks/CavernsOfFreitag.dsk"); assertGraphicsFile(disk, "TITLE.PIC"); } protected FormattedDisk showDirectory(String imageName) throws IOException { Disk disk = new Disk(imageName); FormattedDisk formattedDisk = disk.getFormattedDisk(); System.out.println(); System.out.println(formattedDisk.getDiskName()); List files = formattedDisk.getFiles(); if (files != null) { showFiles(files, ""); } System.out.println(formattedDisk.getFreeSpace() + " bytes free."); System.out.println(formattedDisk.getUsedSpace() + " bytes used."); System.out.println("This disk " + (formattedDisk.canHaveDirectories() ? "does" : "does not") + " support directories."); System.out.println("This disk is formatted in the " + formattedDisk.getFormat() + " format."); System.out.println(); showDiskUsage(formattedDisk); return formattedDisk; } protected void showFiles(List files, String indent) { for (int i=0; i 0 && i % 80 == 0) System.out.println(); usage.next(); System.out.print(usage.isFree() ? "." : "U"); i++; } System.out.println(); } else { for (int y=dimensions[0]-1; y>=0; y--) { for (int x=0; x