Package org.epic.perleditor.editors

Source Code of org.epic.perleditor.editors.TestEditorAssociation

package org.epic.perleditor.editors;

import java.io.File;

import org.eclipse.jface.text.IDocument;

public class TestEditorAssociation extends BasePDETestCase
{
    public void testOpen() throws Exception
    {  
        // This test checks whether opening files with a strange extension
        // which are associated with the PerlEditor works as expected.

        assertOkay(openEditor("EPICTest/test_EditorAssociation.pre"));
    }
   
    public void testOpenExternal() throws Exception
    {
        // Same as above, this time with a file located outside
        // of the workspace
       
        final File tmpFile = File.createTempFile(
            "EPIC-TestEditorAssociation", ".pl");

        try
        {
            writeToFile(tmpFile, "#!/usr/bin/perl\nprint 'Hello, world!';");
            assertOkay(openEditor(tmpFile));
        }
        finally
        {
            tmpFile.delete();
        }       
    }
   
    private void assertOkay(PerlEditor editor) throws Exception
    {
        try
        {
            IDocument doc = editor.getViewer().getDocument();
            assertTrue(PartitionTypes.getPerlPartitioner(doc) instanceof PerlPartitioner);           
            assertTrue(editor.getViewer().getAnnotationModel() instanceof PerlSourceAnnotationModel);
        }
        finally
        {
            closeEditor(editor);
        }
    }  
}
TOP

Related Classes of org.epic.perleditor.editors.TestEditorAssociation

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.