Logo Search packages:      
Sourcecode: pauker version File versions  Download package

void pauker::program::gui::swing::OpenTest::testOpen (  )  throws Exception [inline]

runs the test

Exceptions:
java.lang.Exception 

Definition at line 43 of file OpenTest.java.

                                            {

        assertFalse("Only screenshots are generated!",
                Screenshots.UPDATE_SCREENSHOTS);

        ResourceBundle strings = ResourceBundle.getBundle("pauker/Strings");

        // get path of test lesson
        String internalPath = "/testLessons/1.pau.gz";
        String testFilePath = getClass().getResource(internalPath).getPath();
        File testFile = new File(testFilePath);

        ClassReference classReference = new ClassReference(
                "pauker.program.gui.swing.PaukerFrame");
        classReference.startApplication(new String[]{testFilePath});
        frameOperator = new JFrameOperator();
        final JButtonOperator newButtonOperator = new JButtonOperator(
                frameOperator, new NameComponentChooser("newButton"));
        JLabelOperator summaryLabelOperator = new JLabelOperator(
                frameOperator, new NameComponentChooser("summaryLabel"));
        fileMenuOperator = new JMenuOperator(
                frameOperator, new NameComponentChooser("fileMenu"));
        JButtonOperator saveButtonOperator = new JButtonOperator(
                frameOperator, new NameComponentChooser("saveButton"));
        JMenuOperator extraMenuOperator = new JMenuOperator(
                frameOperator, new NameComponentChooser("extraMenu"));
        JListOperator batchListOperator = new JListOperator(
                frameOperator, new NameComponentChooser("batchList"));

        // check, if command line open was successfull
        String summaryString = strings.getString("SummaryLabel");
        String formattedSummary = MessageFormat.format(summaryString,
                Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(1));
        assertEquals(formattedSummary, summaryLabelOperator.getText());

        // ensure that toolbar is visible
        extraMenuOperator.doClick();
        JCheckBoxMenuItemOperator showToolBarMenuItem =
                new JCheckBoxMenuItemOperator(frameOperator);
        showToolBarMenuItem.setSelected(true);

        Tools.doClick(newButtonOperator);

        // test opening via menu item
        openFile(testFile, false);
        summaryLabelOperator.waitText(formattedSummary);

        // test merging of lessons
        fileMenuOperator.doClick();
        JMenuItemOperator openMenuItemOperator = new JMenuItemOperator(
                frameOperator, new NameComponentChooser("openMenuItem"));
        openMenuItemOperator.push();
        JDialogOperator openFileDialogOperator = new JDialogOperator();
        JFileChooserOperator fileChooserOperator = new JFileChooserOperator();
        fileChooserOperator.setSelectedFile(testFile);
        JCheckBoxOperator mergingCheckBoxOperator = new JCheckBoxOperator(
                openFileDialogOperator, 
                new NameComponentChooser("mergingCheckBox"));
        mergingCheckBoxOperator.setSelected(true);
        JButtonOperator openButtonOperator = new JButtonOperator(
                openFileDialogOperator, new NameComponentChooser("openButton"));
        Tools.doClick(openButtonOperator);
        formattedSummary = MessageFormat.format(summaryString,
                Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(2));
        assertEquals(formattedSummary, summaryLabelOperator.getText());
        saveButtonOperator.waitComponentEnabled();
        Tools.clickComponentOperator(summaryLabelOperator);
        batchListOperator.waitComponentShowing(true);
        assertEquals("summary batch was not correctly updated when merging " +
                "lessons!", 2, batchListOperator.getModel().getSize());

        newButtonOperator.pushNoBlock();
        JDialogOperator dialogOperator = new JDialogOperator();
        JButtonOperator dontSaveButtonOperator = new JButtonOperator(
                dialogOperator, strings.getString("DontSave"));
        Tools.doClick(dontSaveButtonOperator);

        // test recent file menu
        fileMenuOperator.doClick();
        JMenuOperator recentFilesMenuOperator = new JMenuOperator(
                frameOperator, new NameComponentChooser("recentFilesMenu"));
        recentFilesMenuOperator.doClick();
        JMenuItemOperator recentFilesMenuItem1Operator = new JMenuItemOperator(
                (JMenuItem) recentFilesMenuOperator.getMenuComponent(0));
        Tools.clickComponentOperator(recentFilesMenuItem1Operator);
        formattedSummary = MessageFormat.format(summaryString,
                Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(1));
        summaryLabelOperator.waitText(formattedSummary);

        // try opening unzipped xml lesson
        internalPath = "/testLessons/Laender-Hauptstaedte.xml";
        testFilePath = getClass().getResource(internalPath).getPath();
        testFile = new File(testFilePath);
        openFile(testFile, true);
        formattedSummary = MessageFormat.format(summaryString,
                Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(191));
        assertEquals(formattedSummary, summaryLabelOperator.getText());

        // test that selecting a file that is no Pauker lesson is shown
        // in the file chooser accessory
        internalPath = "/testLessons/noPaukerLesson.txt";
        String noLessonPath = getClass().getResource(internalPath).getPath();
        File noLessonFile = new File(noLessonPath);

        // select a lesson
        testAccessory(testFile, true);
        testAccessory(noLessonFile, false);
        testAccessory(testFile, true);
        testAccessory(noLessonFile, false);

        // try opening a CSV file
        internalPath = "/testLessons/Test.csv";
        String csvLessonPath = getClass().getResource(internalPath).getPath();
        File csvLessonFile = new File(csvLessonPath);
        testAccessory(csvLessonFile, true);
    }


Generated by  Doxygen 1.6.0   Back to index