/** * Tests that editor can set content + selection correctly * * @param content * @throws OperationException */ protected void testContent(String content) throws OperationException { logger.trace().logXml("Testing: " + content); setContent(editor, content); }
/** * Tests that editor can set content + selection correctly * * @param content * @throws OperationException */ protected void testContent(String content) throws OperationException { logger.trace().logXml("Testing: " + content); setContent(editor, content); }
/** * Test that content makes editor at least minHeight pixels tall * * @param content * @param minHeight * @throws OperationException */ protected void testMinHeight(String content, int minHeight) throws OperationException { // Compute a message identifying the test String msg = content + " should be at least " + minHeight + " pixels tall"; logger.trace().logXml("Testing: " + msg); // Measure height setContent(editor, content); int height = editor.getWidget().getOffsetHeight(); // Assert assertTrue(msg, height >= minHeight); }
/** * Test that content makes editor at least minHeight pixels tall * * @param content * @param minHeight * @throws OperationException */ protected void testMinHeight(String content, int minHeight) throws OperationException { // Compute a message identifying the test String msg = content + " should be at least " + minHeight + " pixels tall"; logger.trace().logXml("Testing: " + msg); // Measure height setContent(editor, content); int height = editor.getWidget().getOffsetHeight(); // Assert assertTrue(msg, height >= minHeight); }
/** * Tests that firstContent makes editor roughly the same as secondContent * * @param firstContent * @param secondContent * @param maxDelta * @throws OperationException */ protected void testRoughlyEqualHeight(String firstContent, String secondContent, int maxDelta) throws OperationException { // Compute a message identifying the test String msg = firstContent + " should be within " + maxDelta + " pixel height of " + secondContent; logger.trace().logXml("Testing: " + msg); // Measure heights setContent(editor, firstContent); int firstHeight = editor.getWidget().getOffsetHeight(); setContent(editor, secondContent); int secondHeight = editor.getWidget().getOffsetHeight(); // Assert assertTrue(msg, Math.abs(firstHeight - secondHeight) <= maxDelta); }
/** * Tests that firstContent makes editor roughly the same as secondContent * * @param firstContent * @param secondContent * @param maxDelta * @throws OperationException */ protected void testRoughlyEqualHeight(String firstContent, String secondContent, int maxDelta) throws OperationException { // Compute a message identifying the test String msg = firstContent + " should be within " + maxDelta + " pixel height of " + secondContent; logger.trace().logXml("Testing: " + msg); // Measure heights setContent(editor, firstContent); int firstHeight = editor.getWidget().getOffsetHeight(); setContent(editor, secondContent); int secondHeight = editor.getWidget().getOffsetHeight(); // Assert assertTrue(msg, Math.abs(firstHeight - secondHeight) <= maxDelta); }
/** * Tests that applying an operation causes exception * TODO(user): consider testing for specific exception types * * @param startContent * @param operation */ private void testOperationFailure( String startContent, Nindo nindo) { // Compute a message identifying the test String msg = startContent + " + " + nindo + " => FAIL"; logger.trace().logXml("Testing: " + msg); try { // Execute the operation on starting content setContent(editor, startContent); DocOp docOp = getDocOpFromNindo(nindo); editor.getContent().consume(docOp); } catch (Throwable e) { // Test succeeds return; } // We didn't get the exception fail(msg); }
/** * Tests that applying an operation causes exception * TODO(user): consider testing for specific exception types * * @param startContent * @param operation */ private void testOperationFailure( String startContent, Nindo nindo) { // Compute a message identifying the test String msg = startContent + " + " + nindo + " => FAIL"; logger.trace().logXml("Testing: " + msg); try { // Execute the operation on starting content setContent(editor, startContent); DocOp docOp = getDocOpFromNindo(nindo); editor.getContent().consume(docOp); } catch (Throwable e) { // Test succeeds return; } // We didn't get the exception fail(msg); }
/** * Tests that firstContent makes editor the same height as secondContent * * @param firstContent * @param secondContent * @throws OperationException */ protected void testEqualHeight(String firstContent, String secondContent) throws OperationException { // Compute a message identifying the test String msg = firstContent + " should be same height as " + secondContent; logger.trace().logXml("Testing: " + msg); // Measure heights setContent(editor, firstContent); int firstHeight = editor.getWidget().getOffsetHeight(); setContent(editor, secondContent); int secondHeight = editor.getWidget().getOffsetHeight(); // Assert assertEquals(msg, firstHeight, secondHeight); }
/** * Tests that tallerContent makes editor taller than shorterContent * by at least minDelta * * @param tallerContent * @param shorterContent * @param minDelta * @throws OperationException */ protected void testTaller( String tallerContent, String shorterContent, int minDelta) throws OperationException { // Compute a message identifying the test String msg = tallerContent + " should be at least " + minDelta + " pixels taller than " + shorterContent; logger.trace().logXml("Testing: " + msg); // Measure heights setContent(editor, tallerContent); int tallerHeight = editor.getWidget().getOffsetHeight(); setContent(editor, shorterContent); int shorterHeight = editor.getWidget().getOffsetHeight(); // Assert assertTrue(msg, tallerHeight >= shorterHeight + minDelta); }
/** * Tests that firstContent makes editor the same height as secondContent * * @param firstContent * @param secondContent * @throws OperationException */ protected void testEqualHeight(String firstContent, String secondContent) throws OperationException { // Compute a message identifying the test String msg = firstContent + " should be same height as " + secondContent; logger.trace().logXml("Testing: " + msg); // Measure heights setContent(editor, firstContent); int firstHeight = editor.getWidget().getOffsetHeight(); setContent(editor, secondContent); int secondHeight = editor.getWidget().getOffsetHeight(); // Assert assertEquals(msg, firstHeight, secondHeight); }
/** * Tests that tallerContent makes editor taller than shorterContent * by at least minDelta * * @param tallerContent * @param shorterContent * @param minDelta * @throws OperationException */ protected void testTaller( String tallerContent, String shorterContent, int minDelta) throws OperationException { // Compute a message identifying the test String msg = tallerContent + " should be at least " + minDelta + " pixels taller than " + shorterContent; logger.trace().logXml("Testing: " + msg); // Measure heights setContent(editor, tallerContent); int tallerHeight = editor.getWidget().getOffsetHeight(); setContent(editor, shorterContent); int shorterHeight = editor.getWidget().getOffsetHeight(); // Assert assertTrue(msg, tallerHeight >= shorterHeight + minDelta); }
/** * Tests that applying an operation results in correct * content and selection * * @param startContent * @param nindo * @param expectedContent * @throws OperationException */ private void testOperation(String startContent, Nindo nindo, String expectedContent) throws OperationException { // Compute a message identifying the test String msg = startContent + " + " + nindo + " => " + expectedContent; logger.trace().logXml("Testing: " + msg); // Execute the operation on starting content setContent(editor, startContent); // Get a docOp out of the nindo DocOp docOp = getDocOpFromNindo(nindo); editor.getContent().consume(docOp); // Assert editor health (editor already does this in debug builds) if (!LogLevel.showDebug()) { EditorTestingUtil.checkHealth(editor); } // Assert result assertEditorContent(msg, expectedContent, editor); }
/** * Tests that applying an operation results in correct * content and selection * * @param startContent * @param nindo * @param expectedContent * @throws OperationException */ private void testOperation(String startContent, Nindo nindo, String expectedContent) throws OperationException { // Compute a message identifying the test String msg = startContent + " + " + nindo + " => " + expectedContent; logger.trace().logXml("Testing: " + msg); // Execute the operation on starting content setContent(editor, startContent); // Get a docOp out of the nindo DocOp docOp = getDocOpFromNindo(nindo); editor.getContent().consume(docOp); // Assert editor health (editor already does this in debug builds) if (!LogLevel.showDebug()) { EditorTestingUtil.checkHealth(editor); } // Assert result assertEditorContent(msg, expectedContent, editor); }
/** * Tests that a single call to handleKeyDown results in correct content * * @param startContent * @param expectedContent * @param keyName * @param editorEvent * @throws OperationException */ protected void testKeyDown(String startContent, String expectedContent, String keyName, EditorEvent editorEvent) throws OperationException { // Compute a message identifying the test String msg = abbreviations.expand(startContent) + " + " + keyName + " -> " + abbreviations.expand(expectedContent); logger.trace().logXml("Testing: " + msg); // Place content in editor, and simulate an enter hit setContent(editor, startContent); ((EditorImpl) editor).debugGetEventHandler().handleEvent(editorEvent); // Assert editor health (editor already does this in debug builds) if (!LogLevel.showDebug()) { EditorTestingUtil.checkHealth(editor); } // Assert result assertEditorContent(msg, expectedContent, editor); }
/** * Tests that a single call to handleKeyDown results in correct content * * @param startContent * @param expectedContent * @param keyName * @param editorEvent * @throws OperationException */ protected void testKeyDown(String startContent, String expectedContent, String keyName, EditorEvent editorEvent) throws OperationException { // Compute a message identifying the test String msg = abbreviations.expand(startContent) + " + " + keyName + " -> " + abbreviations.expand(expectedContent); logger.trace().logXml("Testing: " + msg); // Place content in editor, and simulate an enter hit setContent(editor, startContent); ((EditorImpl) editor).debugGetEventHandler().handleEvent(editorEvent); // Assert editor health (editor already does this in debug builds) if (!LogLevel.showDebug()) { EditorTestingUtil.checkHealth(editor); } // Assert result assertEditorContent(msg, expectedContent, editor); }