/*
 * FileCloseActionTest.java
 * JUnit based test
 *
 * Created on September 24, 2010, 3:45 PM
 */

package org.opensim.view.actions;

import junit.framework.*;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.actions.CallableSystemAction;
import org.opensim.modeling.Model;
import org.opensim.view.FileSaveModelAction;
import org.opensim.view.ModelSettingsSerializer;
import org.opensim.view.SingleModelGuiElements;
import org.opensim.view.experimentaldata.ModelForExperimentalData;
import org.opensim.view.pub.OpenSimDB;
import org.opensim.view.pub.ViewDB;

/**
 *
 * @author Ayman
 */
public class FileCloseActionTest extends TestCase {
    
    public FileCloseActionTest(String testName) {
        super(testName);
    }

    protected void setUp() throws Exception {
    }

    protected void tearDown() throws Exception {
    }

    /**
     * Test of closeModel method, of class org.opensim.view.actions.FileCloseAction.
     */
    public void testCloseModel() {
        System.out.println("closeModel");
        
        Model model = null;
        
        boolean expResult = true;
        boolean result = FileCloseAction.closeModel(model);
        assertEquals(expResult, result);
        
        // TODO review the generated test code and remove the default call to fail.
        fail("The test case is a prototype.");
    }

    /**
     * Test of performAction method, of class org.opensim.view.actions.FileCloseAction.
     */
    public void testPerformAction() {
        System.out.println("performAction");
        
        FileCloseAction instance = new FileCloseAction();
        
        instance.performAction();
        
        // TODO review the generated test code and remove the default call to fail.
        fail("The test case is a prototype.");
    }

    /**
     * Test of getName method, of class org.opensim.view.actions.FileCloseAction.
     */
    public void testGetName() {
        System.out.println("getName");
        
        FileCloseAction instance = new FileCloseAction();
        
        String expResult = "";
        String result = instance.getName();
        assertEquals(expResult, result);
        
        // TODO review the generated test code and remove the default call to fail.
        fail("The test case is a prototype.");
    }

    /**
     * Test of getHelpCtx method, of class org.opensim.view.actions.FileCloseAction.
     */
    public void testGetHelpCtx() {
        System.out.println("getHelpCtx");
        
        FileCloseAction instance = new FileCloseAction();
        
        HelpCtx expResult = null;
        HelpCtx result = instance.getHelpCtx();
        assertEquals(expResult, result);
        
        // TODO review the generated test code and remove the default call to fail.
        fail("The test case is a prototype.");
    }

    /**
     * Test of isEnabled method, of class org.opensim.view.actions.FileCloseAction.
     */
    public void testIsEnabled() {
        System.out.println("isEnabled");
        
        FileCloseAction instance = new FileCloseAction();
        
        boolean expResult = true;
        boolean result = instance.isEnabled();
        assertEquals(expResult, result);
        
        // TODO review the generated test code and remove the default call to fail.
        fail("The test case is a prototype.");
    }
    
}

@@ -150,223 +150,124 @@
 rt j
-unit.framework.*;%0D%0Aimport org.openide.DialogDisplayer;%0D%0Aimport org.openide.NotifyDescriptor;%0D%0Aimport org.openide.util.HelpCtx;%0D%0Aimport org.openide.util.NbBundle;%0D%0Aimport org.openide.util.actions.CallableSystemAction
+ava.io.IOException;%0D%0Aimport junit.framework.*;%0D%0Aimport org.openide.util.Exceptions;%0D%0Aimport org.openide.util.HelpCtx
 ;%0D%0Ai
@@ -333,190 +333,69 @@
 File
-SaveModelAction;%0D%0Aimport org.o
+O
 pen
+O
 sim
-.view.ModelSettingsSerializer;%0D%0Aimport org.opensim.view.SingleModelGuiElements;%0D%0Aimport org.opensim.view.experimentaldata.ModelForExperimentalData
+ModelAction;%0D%0Aimport org.opensim.view.TestEnvironment
 ;%0D%0Ai
@@ -436,45 +436,8 @@
 DB;%0D
-%0Aimport org.opensim.view.pub.ViewDB;%0D
 %0A%0D%0A/
@@ -863,24 +863,43 @@
 eModel() %7B%0D%0A
+        try %7B%0D%0A    
         Syst
@@ -929,32 +929,36 @@
 del%22);%0D%0A        
+    
 %0D%0A        Model 
@@ -955,37 +955,330 @@
     
-Model model = null;%0D%0A        
+    System.out.println(%22testLoadModel_Model()%22);%0D%0A            Model aModel = new Model(TestEnvironment.getModelPath());%0D%0A            System.out.println(%22model path=%22+TestEnvironment.getModelPath());%0D%0A            //aModel= new Model(modelPath);%0D%0A            FileOpenOsimModelAction instance = new FileOpenOsimModelAction();
 %0D%0A  
@@ -1275,32 +1275,36 @@
 ion();%0D%0A        
+    
 boolean expResul
@@ -1314,32 +1314,36 @@
  true;%0D%0A        
+    
 boolean result =
@@ -1342,16 +1342,145 @@
 result =
+ instance.loadModel(aModel, true);%0D%0A            Model mdl = OpenSimDB.getInstance().getCurrentModel();%0D%0A            %0D%0A           
  FileClo
@@ -1500,19 +1500,17 @@
 eModel(m
-ode
+d
 l);%0D%0A   
@@ -1506,32 +1506,36 @@
 (mdl);%0D%0A        
+    
 assertEquals(exp
@@ -1531,33 +1531,63 @@
 tEquals(
-expResult, result
+OpenSimDB.getInstance().getCurrentModel(), null
 );%0D%0A    
@@ -1582,34 +1582,42 @@
 null);%0D%0A        
-%0D%0A
+    %0D%0A    
         // TODO 
@@ -1697,46 +1697,133 @@
     
-fail(%22The test case is a prototype.%22);
+%7D catch (IOException ex) %7B%0D%0A            Exceptions.printStackTrace(ex);%0D%0A            fail(%22Exception is thrown.%22);%0D%0A        %7D
 %0D%0A  
@@ -3630,35 +3630,36 @@
 ean expResult = 
-tru
+fals
 e;%0D%0A        bool
@@ -3843,46 +3843,8 @@
     
-fail(%22The test case is a prototype.%22);
 %0D%0A  

Fix GUI test case for FileCloseActionTest