/** * Tests the case where there are no settings in the OutputBehaviors object to load when the * window is created */ public void testLoadNoSettings() { MainWindow oWindow = new MainWindow(); oWindow.setVisible(false); GUIManager oManager = oWindow.m_oDataManager; String sFileName = null; try { sFileName = writeXMLFile1(); oManager.inputXMLParameterFile(sFileName); OutputBehaviors oParent = oManager.getOutputBehaviors(); DetailedOutput oDetailed = (DetailedOutput) oParent.getDetailedOutput(); JDialog jFake = new JDialog(); DetailedOutputGridSetup oTester = new DetailedOutputGridSetup(jFake, oDetailed); // Verify that there are no choices in the grid assertEquals(1, oTester.m_jGridListCombo.getItemCount()); String sChoice = (String) oTester.m_jGridListCombo.getItemAt(0); assertTrue(sChoice.startsWith("---")); // Verify that there is nothing in data members assertEquals(0, oTester.m_jDataMemberListModel.getSize()); // Verify that there is nothing in the "what saved" box assertEquals(0, oTester.m_jSaveListModel.getSize()); } catch (ModelException oErr) { fail("TestLoadNoSettings failed with message " + oErr.getMessage()); } finally { new File(sFileName).delete(); } }
/** * Tests the case where there are settings in the OutputBehaviors object to load when the window * is created */ public void testLoadSettings() { MainWindow oWindow = new MainWindow(); oWindow.setVisible(false); GUIManager oManager = oWindow.m_oDataManager; String sFileName = null; try { sFileName = writeXMLFile1(); oManager.inputXMLParameterFile(sFileName); OutputBehaviors oParent = oManager.getOutputBehaviors(); DetailedOutput oOutput = oParent.getDetailedOutput(); JDialog jFake = new JDialog(); // Create some settings to load DetailedGridSettings oSettings = new DetailedGridSettings("Test Grid 1"); oSettings.addChar("Char1", "Test Char 1"); oSettings.addInt("Integer 1", "Test Integer 1"); oSettings.addInt("Integer 2", "Test Integer 2"); oSettings.setSaveFrequency(2); oOutput.addDetailedGridSettings(oSettings); oSettings = null; oSettings = new DetailedGridSettings("Test Grid 2"); oSettings.addBool("Bool1", "Test Bool 1"); oSettings.addChar("Char 1", "Test Char 1"); oSettings.setSaveFrequency(2); oOutput.addDetailedGridSettings(oSettings); DetailedOutputGridSetup oTester = new DetailedOutputGridSetup(jFake, oOutput); // Verify that there are 2 choices in the grid /* assertEquals(3, oTester.jGridListCombo.getItemCount()); String sChoice = (String) oTester.jGridListCombo.getItemAt(0); assertTrue(sChoice.startsWith("---")); sChoice = (String) oTester.jGridListCombo.getItemAt(1); assertTrue(sChoice.equals("Test Grid 1")); sChoice = (String) oTester.jGridListCombo.getItemAt(2); assertTrue(sChoice.equals("Test Grid 2")); //Verify that there is nothing in data members assertEquals(0, oTester.jDataMemberListModel.getSize()); //Choose the no-grid line and verify that there's nothing in data members oTester.jGridListCombo.setSelectedIndex(0); assertEquals(0, oTester.jDataMemberListModel.getSize()); //Choose the first grid and verify the number of data members oTester.jGridListCombo.setSelectedIndex(1); assertEquals(3, oTester.jDataMemberListModel.getSize()); //Choose the second grid and verify the number of data members oTester.jGridListCombo.setSelectedIndex(2); assertEquals(2, oTester.jDataMemberListModel.getSize()); */ // Verify that there are two lines in the "what saved" box assertEquals(2, oTester.m_jSaveListModel.getSize()); } catch (ModelException oErr) { fail("TestLoadSettings failed with message " + oErr.getMessage()); } }