Package org.joshy.sketch.actions.io

Source Code of org.joshy.sketch.actions.io.OpenActionTest

package org.joshy.sketch.actions.io;

import org.joshy.gfx.Core;
import org.joshy.gfx.util.u;
import org.joshy.sketch.actions.OpenAction;
import org.joshy.sketch.canvas.SketchCanvas;
import org.joshy.sketch.model.SNode;
import org.joshy.sketch.model.SketchDocument;
import org.joshy.sketch.modes.vector.VectorDocContext;
import org.joshy.sketch.modes.vector.VectorModeHelper;
import org.junit.Before;
import org.junit.Test;

/** A test for the OpenAction
*/
public class OpenActionTest {

    @Before public void doSetup() throws Exception {
        Core.setTesting(true);
        Core.init();
        Core.getShared();
    }

    /*
    TODO:  this was probably broken when we switched to the zip file format
    //do a basic test of loading a page
    @Test public void simpleTest() throws Exception {
        VectorModeHelper helper = new VectorModeHelper(null);
        VectorDocContext context = helper.createDocContext(null);
        SketchCanvas canvas = new SketchCanvas(context);
        OpenAction action = new OpenAction(null);
        u.p("Url = " + this.getClass().getResource("simple.xml"));
        action.load(this.getClass().getResourceAsStream("simple.xml"),null,"simple.xml",null);
        SketchDocument doc = canvas.getDocument();
        u.p("canvas doc = " + doc);
        for(SketchDocument.SketchPage page : doc.getPages()) {
            u.p("page");
            for(SNode shape : page.getNodes()) {
                u.p("  shape = " + shape);
            }
        }
    }
    */

    //test loading version -1 and auto-upgrading it to version 0
    @Test public void versionN1to0Test() throws Exception {
        u.p("running a version upgrade test");
        VectorModeHelper helper = new VectorModeHelper(null);
        VectorDocContext context = helper.createDocContext(null);
        SketchCanvas canvas = new SketchCanvas(context);
        OpenAction action = new OpenAction(null);
        u.p("Url = " + this.getClass().getResource("oldVersion_-1.xml"));
        action.load(this.getClass().getResourceAsStream("oldVersion_-1.xml"),null,"oldVersion_-1.xml",null);
        SketchDocument doc = canvas.getDocument();
        u.p("canvas doc = " + doc);
        for(SNode shape : doc.getCurrentPage().getNodes()) {
            u.p("shape = " + shape);
        }
    }
}
TOP

Related Classes of org.joshy.sketch.actions.io.OpenActionTest

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.