public static void main(String[] args) { TestEditor test = new TestEditor(Long.class); test.testValue(0l, "0"); test.testValue(null, null); test.testText("1", 1l); test.testText(null, null); }
public X10DocProviderTest_Parameterized(IFile file) throws Exception { super(); this.file = file; editor = new TestEditor(file); editor.getAst(); hh = new HoverHelper(editor.language); }
/** * Starts the TestEditor for author with name <Code>FAuthorname</Code> and codebase <Code>home * </Code> and sets it visible. */ private void startEditor() { // Gets the path of the system String path = home.getPath(); String pathttemp = path.substring(1, path.length()); int index = pathttemp.indexOf("/"); index++; // Gets the folder of the TestEditor tool dirname = path.substring(0, index); if (dirname.equals("/TestEditor")) dirname = ""; // Gets the Course object from the server courseVector = getCoursesAndConceptsNames(); // Gets the icons path used by TestEditor. String iconTestEditorAndItemsPath = this.getIconAndItemsPath(); iconTestEditorPath = iconTestEditorAndItemsPath.substring(0, iconTestEditorAndItemsPath.indexOf("\n")); itemsPath = iconTestEditorAndItemsPath.substring(iconTestEditorAndItemsPath.indexOf("\n") + 1); itemsPath = itemsPath.substring(0, itemsPath.indexOf("\n")); // If there is no courses, a error message is showed to the user // and ends the TestEditor if (courseVector == null || courseVector.isEmpty()) { String message = "ERROR: A problem exists with its author user, " + "\n"; message += "it is possible that you exist as author, " + "\n"; message += "but don't have assigned any course, please add courses to its list."; JOptionPane.showMessageDialog(this, message, "Without Courses", JOptionPane.ERROR_MESSAGE); System.exit(0); } // Creates the TestEditor object TestEditor testEditor = new TestEditor( userLogin, userPassword, courseVector, home, this.dirname, this.iconTestEditorPath, this.itemsPath); // Defines its size and location Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int minimumWidth = 800; int minimumHeight = 600; if (minimumWidth > screenSize.width) { minimumWidth = screenSize.width; } if (minimumHeight > screenSize.height) { minimumHeight = screenSize.height; } testEditor.setLocation(0, 0); testEditor.setSize(screenSize.width, screenSize.height); testEditor.setMinimumSize(new Dimension(minimumWidth, minimumHeight)); // Opens it maximized testEditor.setExtendedState(JFrame.MAXIMIZED_BOTH); // Shows to the user testEditor.toFront(); // Puts it on the front testEditor.setVisible(true); }
@Test public void testGetDocumentation() throws Exception { File actual = new File( project .getFile( new Path("actual") .append(file.getProjectRelativePath().removeFirstSegments(1)) .removeFileExtension() .addFileExtension("txt")) .getLocation() .toPortableString()); actual.getParentFile().mkdirs(); FileChannel fchan = new FileOutputStream(actual).getChannel(); BufferedWriter bf = new BufferedWriter(Channels.newWriter(fchan, "UTF-8")); try { for (int offset = 0; offset < editor.document.getLength(); offset++) { Point loc = editor.getLocation(offset); Shell shell = new Shell(); SourceViewer viewer = new SourceViewer(shell, null, 0); IAnnotationModel model = new AnnotationModel(); model.connect(editor.document); viewer.setDocument(editor.document, model); String doc = hh.getHoverHelpAt(editor.parseController, viewer, offset); if (doc != null && doc.length() > 0) { loc = editor.getLocation(offset); bf.write("" + loc.x + "," + loc.y + ": "); bf.write(doc); bf.newLine(); } } } finally { bf.close(); fchan.close(); } File expected = new File( project .getFile( new Path("expected") .append(file.getProjectRelativePath().removeFirstSegments(1)) .removeFileExtension() .addFileExtension("txt")) .getLocation() .toPortableString()); Assert.assertTrue( "The data file containing the expected results for " + file.getLocation() + " does not exist. If you just added this file to the test suite be sure to verify the contents of " + actual.getPath() + " and copy it into the expected folder in the test suite.", expected.exists()); int result = FileUtils.compareLinesOf(actual, expected); Assert.assertTrue("Actual differs from expected at line " + result, result == -1); }